From ca1ca328cff53d909bd59e49f830499f084e64fa Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 16 Mar 2007 23:11:56 +0000 Subject: maximizing window with aspect ratio caused windows to be made larger than the screen --- ChangeLog | 3 +++ src/WinClient.cc | 17 ++++++++++++++--- src/WinClient.hh | 3 ++- src/Window.cc | 6 +++--- src/Window.hh | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61b94cf..7ef710e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/WinClient.cc b/src/WinClient.cc index 458ac01..bb8a25c 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -772,7 +772,8 @@ void closestPointToLine(double &ret_x, double &ret_y, * 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 @@ void WinClient::applySizeHints(int &width, int &height, * 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 @@ void WinClient::applySizeHints(int &width, int &height, 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) { diff --git a/src/WinClient.hh b/src/WinClient.hh index 8e8747c..40daa8e 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -90,7 +90,8 @@ public: * 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); diff --git a/src/Window.cc b/src/Window.cc index e471d6e..8e6b887 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1711,7 +1711,7 @@ void FluxboxWindow::maximize(int type) { 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::changeBlackboxHints(const BlackboxHints &net) { } -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 @@ void FluxboxWindow::fixsize(int *user_w, int *user_h) { // 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; diff --git a/src/Window.hh b/src/Window.hh index 1e55fb5..3206fdd 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -472,7 +472,7 @@ private: // 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); -- cgit v0.11.2