Added center resize. Resizes all corners at the same time.
This commit is contained in:
parent
98209ba704
commit
6d42d1cf5e
4 changed files with 50 additions and 17 deletions
|
@ -90,6 +90,7 @@ public:
|
|||
enum ResizeModel {
|
||||
BOTTOMRESIZE = 0,
|
||||
QUADRANTRESIZE,
|
||||
CENTERRESIZE,
|
||||
DEFAULTRESIZE = BOTTOMRESIZE };
|
||||
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ std::string FbTk::Resource<BScreen::ResizeModel>::getString() const {
|
|||
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 @@ setFromString(char const *strval) {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -2814,9 +2814,12 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
|
|||
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,20 +2838,44 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
|
|||
|
||||
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) {
|
||||
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) {
|
||||
switch (m_resize_corner) {
|
||||
case LEFTTOP:
|
||||
m_last_resize_w = frame().width() - dx;
|
||||
m_last_resize_x = frame().x() + dx;
|
||||
} else {
|
||||
m_last_resize_w = frame().width() + dx;
|
||||
}
|
||||
// no break, use code below too
|
||||
case RIGHTTOP:
|
||||
m_last_resize_h = frame().height() - dy;
|
||||
m_last_resize_y = frame().y() + dy;
|
||||
break;
|
||||
case LEFTBOTTOM:
|
||||
m_last_resize_w = frame().width() - dx;
|
||||
m_last_resize_x = frame().x() + 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);
|
||||
|
||||
|
|
|
@ -137,7 +137,8 @@ public:
|
|||
LEFTTOP,
|
||||
LEFTBOTTOM,
|
||||
RIGHTBOTTOM,
|
||||
RIGHTTOP
|
||||
RIGHTTOP,
|
||||
ALLCORNERS
|
||||
};
|
||||
|
||||
typedef struct _blackbox_hints {
|
||||
|
|
Loading…
Reference in a new issue