all repos — fluxbox @ 3441261346fcee4efb6ba27764384d141b2c4f7e

custom fork of the fluxbox windowmanager

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.
Mathias Gumz akira at fluxbox dot org
commit

3441261346fcee4efb6ba27764384d141b2c4f7e

parent

9bd64010135e26f97fa4d4d551737847fedfbcdd

3 files changed, 34 insertions(+), 22 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,8 @@

(Format: Year/Month/Day) Changes for 1.1.2 *08/10/15: + * Don't allow resizing to negative dimensions (Mathias) + Window.cc/hh * Ignore XRandr events that don't change the screen size (Mark) Screen.cc FbTk/FbWindow.cc/hh *08/10/13:
M src/Window.ccsrc/Window.cc

@@ -2433,19 +2433,15 @@

int borderw = frame().window().borderWidth(); //!! TODO(tabs): the below test ought to be in FbWinFrame // if mouse is currently on the window border, ignore it - if ( ! insideBorder(frame(), - me.x_root, me.y_root, borderw) && + if ( ! insideBorder(frame(), me.x_root, me.y_root, borderw) && ( !frame().externalTabMode() || - ! insideBorder(frame().tabcontainer(), - me.x_root, me.y_root, borderw) ) + ! insideBorder(frame().tabcontainer(), me.x_root, me.y_root, borderw) ) || // or if mouse was on border when it was last clicked - ! insideBorder(frame(), - m_last_button_x, m_last_button_y, borderw) && + ! insideBorder(frame(), m_last_button_x, m_last_button_y, borderw) && ( ! frame().externalTabMode() || - ! insideBorder(frame().tabcontainer(), - m_last_button_x, m_last_button_y, borderw ) ) ) { + ! insideBorder(frame().tabcontainer(), m_last_button_x, m_last_button_y, borderw ) ) ) { return; } }

@@ -2563,11 +2559,12 @@ } else if (resizing) {

int old_resize_x = m_last_resize_x; int old_resize_y = m_last_resize_y; - unsigned int old_resize_w = m_last_resize_w; - unsigned int old_resize_h = m_last_resize_h; + int old_resize_w = m_last_resize_w; + int old_resize_h = m_last_resize_h; int dx = me.x - m_button_grab_x; int dy = me.y - m_button_grab_y; + if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || m_resize_corner == LEFT) { m_last_resize_w = frame().width() - dx;

@@ -2598,7 +2595,7 @@ m_last_resize_y = frame().y() - diff/2;

} } - fixsize(); + fixSize(); frame().displaySize(m_last_resize_w, m_last_resize_h); if (old_resize_x != m_last_resize_x ||

@@ -3107,7 +3104,7 @@ m_last_resize_y = frame().y();

m_last_resize_w = frame().width(); m_last_resize_h = frame().height(); - fixsize(); + fixSize(); frame().displaySize(m_last_resize_w, m_last_resize_h); parent().drawRectangle(screen().rootTheme()->opGC(),

@@ -3127,7 +3124,7 @@

screen().hideGeometry(); if (!interrupted) { - fixsize(); + fixSize(); moveResize(m_last_resize_x, m_last_resize_y, m_last_resize_w, m_last_resize_h);

@@ -3375,8 +3372,21 @@ }

int FluxboxWindow::initialState() const { return m_client->initial_state; } -void FluxboxWindow::fixsize() { - frame().applySizeHints(m_last_resize_w, m_last_resize_h); +void FluxboxWindow::fixSize() { + + // m_last_resize_w / m_last_resize_h could be negative + // due to user interactions. check here and limit + unsigned int w = 1; + unsigned int h = 1; + if (m_last_resize_w > 0) + w = m_last_resize_w; + if (m_last_resize_h > 0) + h = m_last_resize_h; + + frame().applySizeHints(w, h); + + m_last_resize_w = w; + m_last_resize_h = h; // move X if necessary if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM ||
M src/Window.hhsrc/Window.hh

@@ -507,7 +507,7 @@

// modifies left and top if snap is necessary void doSnapping(int &left, int &top); // user_w/h return the values that should be shown to the user - void fixsize(); + void fixSize(); void moveResizeClient(WinClient &client); /// sends configurenotify to all clients void sendConfigureNotify();

@@ -547,7 +547,7 @@

int m_button_grab_x, m_button_grab_y; // handles last button press event for move int m_last_resize_x, m_last_resize_y; // handles last button press event for resize int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving - unsigned int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" + int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" timeval m_last_keypress_time;

@@ -562,16 +562,16 @@ typedef std::map<WinClient *, IconButton *> Client2ButtonMap;

Client2ButtonMap m_labelbuttons; SizeHints m_size_hint; - struct _decorations { - bool titlebar, handle, border, iconify, - maximize, close, menu, sticky, shade, tab, enabled; + struct { + bool titlebar:1, handle:1, border:1, iconify:1, + maximize:1, close:1, menu:1, sticky:1, shade:1, tab:1, enabled:1; } decorations; std::vector<WinButton::Type> m_titlebar_buttons[2]; bool m_toggled_decos; - struct _functions { - bool resize, move, iconify, maximize, close, tabable; + struct { + bool resize:1, move:1, iconify:1, maximize:1, close:1, tabable:1; } functions; typedef FbTk::ConstObjectAccessor<bool, FocusControl> BoolAcc;