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 | |
parent | 9bd64010135e26f97fa4d4d551737847fedfbcdd (diff) | |
download | fluxbox-3441261346fcee4efb6ba27764384d141b2c4f7e.zip fluxbox-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')
-rw-r--r-- | src/Window.cc | 40 | ||||
-rw-r--r-- | src/Window.hh | 14 |
2 files changed, 32 insertions, 22 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 || |
diff --git a/src/Window.hh b/src/Window.hh index 97ece55..bf177b4 100644 --- a/src/Window.hh +++ b/src/Window.hh | |||
@@ -507,7 +507,7 @@ private: | |||
507 | // modifies left and top if snap is necessary | 507 | // modifies left and top if snap is necessary |
508 | void doSnapping(int &left, int &top); | 508 | void doSnapping(int &left, int &top); |
509 | // user_w/h return the values that should be shown to the user | 509 | // user_w/h return the values that should be shown to the user |
510 | void fixsize(); | 510 | void fixSize(); |
511 | void moveResizeClient(WinClient &client); | 511 | void moveResizeClient(WinClient &client); |
512 | /// sends configurenotify to all clients | 512 | /// sends configurenotify to all clients |
513 | void sendConfigureNotify(); | 513 | void sendConfigureNotify(); |
@@ -547,7 +547,7 @@ private: | |||
547 | int m_button_grab_x, m_button_grab_y; // handles last button press event for move | 547 | int m_button_grab_x, m_button_grab_y; // handles last button press event for move |
548 | int m_last_resize_x, m_last_resize_y; // handles last button press event for resize | 548 | int m_last_resize_x, m_last_resize_y; // handles last button press event for resize |
549 | int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving | 549 | int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving |
550 | unsigned int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" | 550 | int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" |
551 | 551 | ||
552 | timeval m_last_keypress_time; | 552 | timeval m_last_keypress_time; |
553 | 553 | ||
@@ -562,16 +562,16 @@ private: | |||
562 | Client2ButtonMap m_labelbuttons; | 562 | Client2ButtonMap m_labelbuttons; |
563 | 563 | ||
564 | SizeHints m_size_hint; | 564 | SizeHints m_size_hint; |
565 | struct _decorations { | 565 | struct { |
566 | bool titlebar, handle, border, iconify, | 566 | bool titlebar:1, handle:1, border:1, iconify:1, |
567 | maximize, close, menu, sticky, shade, tab, enabled; | 567 | maximize:1, close:1, menu:1, sticky:1, shade:1, tab:1, enabled:1; |
568 | } decorations; | 568 | } decorations; |
569 | 569 | ||
570 | std::vector<WinButton::Type> m_titlebar_buttons[2]; | 570 | std::vector<WinButton::Type> m_titlebar_buttons[2]; |
571 | bool m_toggled_decos; | 571 | bool m_toggled_decos; |
572 | 572 | ||
573 | struct _functions { | 573 | struct { |
574 | bool resize, move, iconify, maximize, close, tabable; | 574 | bool resize:1, move:1, iconify:1, maximize:1, close:1, tabable:1; |
575 | } functions; | 575 | } functions; |
576 | 576 | ||
577 | typedef FbTk::ConstObjectAccessor<bool, FocusControl> BoolAcc; | 577 | typedef FbTk::ConstObjectAccessor<bool, FocusControl> BoolAcc; |