diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2008-10-15 06:31:10 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2008-10-15 06:31:10 (GMT) |
commit | 3441261346fcee4efb6ba27764384d141b2c4f7e (patch) | |
tree | a7adb9a72878e94df9a90247caf184cc7d9794fd /src/Window.cc | |
parent | 9bd64010135e26f97fa4d4d551737847fedfbcdd (diff) | |
download | fluxbox_pavel-3441261346fcee4efb6ba27764384d141b2c4f7e.zip fluxbox_pavel-3441261346fcee4efb6ba27764384d141b2c4f7e.tar.bz2 |
don't allow resizing to negative dimensions
this fixes a problem when the user resizes a window over the opposite border.
as a result a signed overflow occured which lead to quite huge windows.
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/Window.cc b/src/Window.cc index d23bf44..4b4d1dc 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -2433,19 +2433,15 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2433 | int borderw = frame().window().borderWidth(); | 2433 | int borderw = frame().window().borderWidth(); |
2434 | //!! TODO(tabs): the below test ought to be in FbWinFrame | 2434 | //!! TODO(tabs): the below test ought to be in FbWinFrame |
2435 | // if mouse is currently on the window border, ignore it | 2435 | // if mouse is currently on the window border, ignore it |
2436 | if ( ! insideBorder(frame(), | 2436 | if ( ! insideBorder(frame(), me.x_root, me.y_root, borderw) && |
2437 | me.x_root, me.y_root, borderw) && | ||
2438 | ( !frame().externalTabMode() || | 2437 | ( !frame().externalTabMode() || |
2439 | ! insideBorder(frame().tabcontainer(), | 2438 | ! insideBorder(frame().tabcontainer(), me.x_root, me.y_root, borderw) ) |
2440 | me.x_root, me.y_root, borderw) ) | ||
2441 | 2439 | ||
2442 | || // or if mouse was on border when it was last clicked | 2440 | || // or if mouse was on border when it was last clicked |
2443 | 2441 | ||
2444 | ! insideBorder(frame(), | 2442 | ! insideBorder(frame(), m_last_button_x, m_last_button_y, borderw) && |
2445 | m_last_button_x, m_last_button_y, borderw) && | ||
2446 | ( ! frame().externalTabMode() || | 2443 | ( ! frame().externalTabMode() || |
2447 | ! insideBorder(frame().tabcontainer(), | 2444 | ! insideBorder(frame().tabcontainer(), m_last_button_x, m_last_button_y, borderw ) ) ) { |
2448 | m_last_button_x, m_last_button_y, borderw ) ) ) { | ||
2449 | return; | 2445 | return; |
2450 | } | 2446 | } |
2451 | } | 2447 | } |
@@ -2563,11 +2559,12 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2563 | 2559 | ||
2564 | int old_resize_x = m_last_resize_x; | 2560 | int old_resize_x = m_last_resize_x; |
2565 | int old_resize_y = m_last_resize_y; | 2561 | int old_resize_y = m_last_resize_y; |
2566 | unsigned int old_resize_w = m_last_resize_w; | 2562 | int old_resize_w = m_last_resize_w; |
2567 | unsigned int old_resize_h = m_last_resize_h; | 2563 | int old_resize_h = m_last_resize_h; |
2568 | 2564 | ||
2569 | int dx = me.x - m_button_grab_x; | 2565 | int dx = me.x - m_button_grab_x; |
2570 | int dy = me.y - m_button_grab_y; | 2566 | int dy = me.y - m_button_grab_y; |
2567 | |||
2571 | if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || | 2568 | if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || |
2572 | m_resize_corner == LEFT) { | 2569 | m_resize_corner == LEFT) { |
2573 | m_last_resize_w = frame().width() - dx; | 2570 | m_last_resize_w = frame().width() - dx; |
@@ -2598,7 +2595,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2598 | } | 2595 | } |
2599 | } | 2596 | } |
2600 | 2597 | ||
2601 | fixsize(); | 2598 | fixSize(); |
2602 | frame().displaySize(m_last_resize_w, m_last_resize_h); | 2599 | frame().displaySize(m_last_resize_w, m_last_resize_h); |
2603 | 2600 | ||
2604 | if (old_resize_x != m_last_resize_x || | 2601 | if (old_resize_x != m_last_resize_x || |
@@ -3107,7 +3104,7 @@ void FluxboxWindow::startResizing(int x, int y, ReferenceCorner dir) { | |||
3107 | m_last_resize_w = frame().width(); | 3104 | m_last_resize_w = frame().width(); |
3108 | m_last_resize_h = frame().height(); | 3105 | m_last_resize_h = frame().height(); |
3109 | 3106 | ||
3110 | fixsize(); | 3107 | fixSize(); |
3111 | frame().displaySize(m_last_resize_w, m_last_resize_h); | 3108 | frame().displaySize(m_last_resize_w, m_last_resize_h); |
3112 | 3109 | ||
3113 | parent().drawRectangle(screen().rootTheme()->opGC(), | 3110 | parent().drawRectangle(screen().rootTheme()->opGC(), |
@@ -3127,7 +3124,7 @@ void FluxboxWindow::stopResizing(bool interrupted) { | |||
3127 | screen().hideGeometry(); | 3124 | screen().hideGeometry(); |
3128 | 3125 | ||
3129 | if (!interrupted) { | 3126 | if (!interrupted) { |
3130 | fixsize(); | 3127 | fixSize(); |
3131 | 3128 | ||
3132 | moveResize(m_last_resize_x, m_last_resize_y, | 3129 | moveResize(m_last_resize_x, m_last_resize_y, |
3133 | m_last_resize_w, m_last_resize_h); | 3130 | m_last_resize_w, m_last_resize_h); |
@@ -3375,8 +3372,21 @@ bool FluxboxWindow::isTransient() const { | |||
3375 | 3372 | ||
3376 | int FluxboxWindow::initialState() const { return m_client->initial_state; } | 3373 | int FluxboxWindow::initialState() const { return m_client->initial_state; } |
3377 | 3374 | ||
3378 | void FluxboxWindow::fixsize() { | 3375 | void FluxboxWindow::fixSize() { |
3379 | frame().applySizeHints(m_last_resize_w, m_last_resize_h); | 3376 | |
3377 | // m_last_resize_w / m_last_resize_h could be negative | ||
3378 | // due to user interactions. check here and limit | ||
3379 | unsigned int w = 1; | ||
3380 | unsigned int h = 1; | ||
3381 | if (m_last_resize_w > 0) | ||
3382 | w = m_last_resize_w; | ||
3383 | if (m_last_resize_h > 0) | ||
3384 | h = m_last_resize_h; | ||
3385 | |||
3386 | frame().applySizeHints(w, h); | ||
3387 | |||
3388 | m_last_resize_w = w; | ||
3389 | m_last_resize_h = h; | ||
3380 | 3390 | ||
3381 | // move X if necessary | 3391 | // move X if necessary |
3382 | if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || | 3392 | if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || |