all repos — fluxbox @ ca1ca328cff53d909bd59e49f830499f084e64fa

custom fork of the fluxbox windowmanager

maximizing window with aspect ratio caused windows to be made larger than the screen
markt markt
commit

ca1ca328cff53d909bd59e49f830499f084e64fa

parent

84e9f9708546526ce12269b31bec6f0459f0852f

5 files changed, 23 insertions(+), 8 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,9 @@

(Format: Year/Month/Day) Changes for 1.0rc3: *07/03/16: + * Maximizing a window with aspect ratio requirements was making windows too + large (thanks Tomas Janousek) + Window.cc/hh WinClient.cc/hh * Added key command to open a custom menu file (thanks Matteo Galiazzo) - :CustomMenu /path/to/file FbCommands.cc/hh FbCommandFactory.cc
M src/WinClient.ccsrc/WinClient.cc

@@ -772,7 +772,8 @@ *

* See ICCCM section 4.1.2.3 */ void WinClient::applySizeHints(int &width, int &height, - int *display_width, int *display_height) { + int *display_width, int *display_height, + bool maximizing) { int i = width, j = height;

@@ -810,6 +811,10 @@ * the target aspect ratio (consider them as x,y coordinates)

* Consider that the aspect ratio is a line, and the current * w/h is a point, so we're just using the formula for * shortest distance from a point to a line! + * + * When maximizing, we must not increase any of the sizes, because we + * would end up with the window partly off a screen, so a simpler formula + * is used in that case. */ if (min_aspect_y > 0 && max_aspect_y > 0 &&

@@ -829,10 +834,16 @@ if (max > 0 && min > 0 && actual > 0) { // don't even try otherwise

bool changed = false; if (actual < min) { changed = true; - closestPointToLine(widthd, heightd, widthd, heightd, min); + if (maximizing) + heightd = widthd / min; + else + closestPointToLine(widthd, heightd, widthd, heightd, min); } else if (actual > max) { changed = true; - closestPointToLine(widthd, heightd, widthd, heightd, max); + if (maximizing) + widthd = heightd * max; + else + closestPointToLine(widthd, heightd, widthd, heightd, max); } if (changed) {
M src/WinClient.hhsrc/WinClient.hh

@@ -90,7 +90,8 @@ * display_* give the values that would be displayed

* to the user when resizing. * We use pointers for display_* since they are optional. */ - void applySizeHints(int &width, int &height, int *display_width = 0, int *display_height = 0); + void applySizeHints(int &width, int &height, int *display_width = 0, + int *display_height = 0, bool maximizing = false); void setGroupLeftWindow(Window win);
M src/Window.ccsrc/Window.cc

@@ -1711,7 +1711,7 @@ m_last_resize_h = new_h;

ResizeDirection old_resize_corner = m_resize_corner; m_resize_corner = NOCORNER; - fixsize(); + fixsize(0, 0, true); m_resize_corner = old_resize_corner; moveResize(m_last_resize_x, m_last_resize_y, m_last_resize_w, m_last_resize_h);

@@ -3779,7 +3779,7 @@

} -void FluxboxWindow::fixsize(int *user_w, int *user_h) { +void FluxboxWindow::fixsize(int *user_w, int *user_h, bool maximizing) { int titlebar_height = (decorations.titlebar ? frame().titlebar().height() + frame().titlebar().borderWidth() : 0);

@@ -3795,7 +3795,7 @@

// dy = new height (w/o decorations), similarly int dh = m_last_resize_h - decoration_height; - m_client->applySizeHints(dw, dh, user_w, user_h); + m_client->applySizeHints(dw, dh, user_w, user_h, maximizing); // update last resize m_last_resize_w = dw;
M src/Window.hhsrc/Window.hh

@@ -472,7 +472,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(int *user_w = 0, int *user_h = 0); + void fixsize(int *user_w = 0, int *user_h = 0, bool maximizing = false); void moveResizeClient(WinClient &client, int x, int y, unsigned int width, unsigned int height); /// sends configurenotify to all clients void sendConfigureNotify(bool send_to_netizens = true);