From daca07edafc2e75eb9ee04d35fe80759308a8583 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 11 Dec 2007 19:31:24 +0000 Subject: added edge resize modes --- ChangeLog | 3 +++ src/FbWinFrameTheme.cc | 4 ++++ src/FbWinFrameTheme.hh | 8 ++++++++ src/Window.cc | 55 +++++++++++++++++++++++--------------------------- 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2cbf181..b95d844 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ (Format: Year/Month/Day) Changes for 1.0.1: *07/12/11: + * Added new resize modes for key command StartResizing: NearestEdge, Left, + Right, Top, Bottom (Mark) + Window.cc * Only allow one menu to be open at a time (Mark) FbTk/Menu.cc/hh *07/12/09: diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc index 6f7f9ef..33a45a8 100644 --- a/src/FbWinFrameTheme.cc +++ b/src/FbWinFrameTheme.cc @@ -69,6 +69,10 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num): m_cursor_lower_right_angle = XCreateFontCursor(disp, XC_lr_angle); m_cursor_upper_right_angle = XCreateFontCursor(disp, XC_ur_angle); m_cursor_upper_left_angle = XCreateFontCursor(disp, XC_ul_angle); + m_cursor_left_side = XCreateFontCursor(disp, XC_left_side); + m_cursor_top_side = XCreateFontCursor(disp, XC_top_side); + m_cursor_right_side = XCreateFontCursor(disp, XC_right_side); + m_cursor_bottom_side = XCreateFontCursor(disp, XC_bottom_side); reconfigTheme(); } diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index 04d6ee4..a48f8b6 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -78,6 +78,10 @@ public: inline Cursor lowerRightAngleCursor() const { return m_cursor_lower_right_angle; } inline Cursor upperLeftAngleCursor() const { return m_cursor_upper_left_angle; } inline Cursor upperRightAngleCursor() const { return m_cursor_upper_right_angle; } + inline Cursor leftSideCursor() const { return m_cursor_left_side; } + inline Cursor rightSideCursor() const { return m_cursor_right_side; } + inline Cursor topSideCursor() const { return m_cursor_top_side; } + inline Cursor bottomSideCursor() const { return m_cursor_bottom_side; } inline Shape::ShapePlace shapePlace() const { return *m_shape_place; } inline const BorderTheme &border() const { return m_border; } @@ -114,6 +118,10 @@ private: Cursor m_cursor_lower_right_angle; Cursor m_cursor_upper_left_angle; Cursor m_cursor_upper_right_angle; + Cursor m_cursor_left_side; + Cursor m_cursor_right_side; + Cursor m_cursor_top_side; + Cursor m_cursor_bottom_side; unsigned char m_focused_alpha; unsigned char m_unfocused_alpha; diff --git a/src/Window.cc b/src/Window.cc index 2997794..65afd67 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2788,20 +2788,23 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { int dx = me.x - m_button_grab_x; int dy = me.y - m_button_grab_y; - 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: + if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || + m_resize_corner == LEFT) { + m_last_resize_w = frame().width() - dx; + m_last_resize_x = frame().x() + dx; + } + if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP || + m_resize_corner == TOP) { 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: + } + if (m_resize_corner == LEFTBOTTOM || m_resize_corner == BOTTOM || + m_resize_corner == RIGHTBOTTOM) + m_last_resize_h = frame().height() + dy; + if (m_resize_corner == RIGHTBOTTOM || m_resize_corner == RIGHTTOP || + m_resize_corner == RIGHT) + m_last_resize_w = frame().width() + dx; + if (m_resize_corner == ALLCORNERS) { // dx or dy must be at least 2 if (abs(dx) >= 2 || abs(dy) >= 2) { // take max and make it even @@ -2813,21 +2816,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { m_last_resize_x = frame().x() - diff/2; m_last_resize_y = frame().y() - diff/2; } - break; - default: // kill warning - 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); @@ -3402,7 +3391,7 @@ FluxboxWindow::ResizeDirection FluxboxWindow::getResizeDirection(int x, int y, if (model == CENTERRESIZE) return ALLCORNERS; if (model == NEARESTEDGERESIZE) { - if (abs(cy - abs(y - cy)) > abs(cx - abs(x - cx))) // y is nearest + if (cy - abs(y - cy) < cx - abs(x - cx)) // y is nearest return (y > cy) ? BOTTOM : TOP; return (x > cx) ? RIGHT : LEFT; } @@ -3437,6 +3426,10 @@ void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme().upperLeftAngleCursor() : (m_resize_corner == RIGHTTOP) ? frame().theme().upperRightAngleCursor() : (m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() : + (m_resize_corner == LEFT) ? frame().theme().leftSideCursor() : + (m_resize_corner == RIGHT) ? frame().theme().rightSideCursor() : + (m_resize_corner == TOP) ? frame().theme().topSideCursor() : + (m_resize_corner == BOTTOM) ? frame().theme().bottomSideCursor() : frame().theme().lowerLeftAngleCursor(); grabPointer(fbWindow().window(), @@ -3724,11 +3717,13 @@ void FluxboxWindow::fixsize(int *user_w, int *user_h, bool maximizing) { m_last_resize_h = dh + decoration_height; // move X if necessary - if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) { + if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || + m_resize_corner == LEFT) { m_last_resize_x = frame().x() + frame().width() - m_last_resize_w; } - if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) { + if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP || + m_resize_corner == TOP) { m_last_resize_y = frame().y() + frame().height() - m_last_resize_h; } -- cgit v0.11.2