Added center resize. Resizes all corners at the same time.
fluxgen fluxgen
4 files changed,
48 insertions(+),
15 deletions(-)
M
src/Screen.hh
→
src/Screen.hh
@@ -90,6 +90,7 @@
enum ResizeModel { BOTTOMRESIZE = 0, QUADRANTRESIZE, + CENTERRESIZE, DEFAULTRESIZE = BOTTOMRESIZE };
M
src/ScreenResources.cc
→
src/ScreenResources.cc
@@ -58,6 +58,8 @@ case BScreen::QUADRANTRESIZE:
return std::string("Quadrant"); case BScreen::BOTTOMRESIZE: return std::string("Bottom"); + case BScreen::CENTERRESIZE: + return std::string("Center"); } return std::string("Default");@@ -70,6 +72,8 @@ if (strcasecmp(strval, "Bottom") == 0) {
m_value = BScreen::BOTTOMRESIZE; } else if (strcasecmp(strval, "Quadrant") == 0) { m_value = BScreen::QUADRANTRESIZE; + } else if (strcasecmp(strval, "Center") == 0) { + m_value = BScreen::CENTERRESIZE; } else m_value = BScreen::DEFAULTRESIZE; }
M
src/Window.cc
→
src/Window.cc
@@ -2814,9 +2814,12 @@ if (me.window == frame().gripRight())
m_resize_corner = RIGHTBOTTOM; else if (me.window == frame().gripLeft()) m_resize_corner = LEFTBOTTOM; - else if (screen().getResizeModel() != BScreen::QUADRANTRESIZE) - m_resize_corner = RIGHTBOTTOM; - else if (me.x < cx) + else if (screen().getResizeModel() != BScreen::QUADRANTRESIZE) { + if (screen().getResizeModel() == BScreen::CENTERRESIZE) + m_resize_corner = ALLCORNERS; + else + m_resize_corner = RIGHTBOTTOM; + } else if (me.x < cx) m_resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM; else m_resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM;@@ -2835,21 +2838,45 @@ int gx = 0, gy = 0;
int dx = me.x - m_button_grab_x; int dy = me.y - m_button_grab_y; - - if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) { + switch (m_resize_corner) { + case LEFTTOP: + m_last_resize_w = frame().width() - dx; + m_last_resize_x = frame().x() + dx; + // no break, use code below too + case RIGHTTOP: m_last_resize_h = frame().height() - dy; m_last_resize_y = frame().y() + dy; - } else { - m_last_resize_h = frame().height() + dy; - } - - if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) { + break; + case LEFTBOTTOM: m_last_resize_w = frame().width() - dx; m_last_resize_x = frame().x() + dx; - } else { - m_last_resize_w = frame().width() + dx; - } + break; + case ALLCORNERS: + // dx or dy must be at least 2 + if (abs(dx) >= 2 || abs(dy) >= 2) { + // take max and make it even + int diff = 2 * (max(dx, dy) / 2); + m_last_resize_h = frame().height() + diff; + + m_last_resize_w = frame().width() + diff; + m_last_resize_x = frame().x() - diff/2; + m_last_resize_y = frame().y() - diff/2; + } + break; + }; + + // if not on top or all corner then move bottom + + if (!(m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP || + m_resize_corner == ALLCORNERS)) + m_last_resize_h = frame().height() + dy; + + // if not top or left bottom or all corners then move right side + if (!(m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || + m_resize_corner == ALLCORNERS)) + m_last_resize_w = frame().width() + dx; + fixsize(&gx, &gy); if (old_resize_x != m_last_resize_x ||@@ -3692,7 +3719,7 @@
// move X if necessary if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) { m_last_resize_x = frame().x() + frame().width() - m_last_resize_w; - } + } if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) { m_last_resize_y = frame().y() + frame().height() - m_last_resize_h;
M
src/Window.hh
→
src/Window.hh
@@ -137,7 +137,8 @@ enum ResizeCorner {
LEFTTOP, LEFTBOTTOM, RIGHTBOTTOM, - RIGHTTOP + RIGHTTOP, + ALLCORNERS }; typedef struct _blackbox_hints {