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

This commit is contained in:
markt 2007-03-16 23:11:56 +00:00
parent 84e9f97085
commit ca1ca328cf
5 changed files with 23 additions and 8 deletions

View file

@ -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

View file

@ -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) {

View file

@ -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);

View file

@ -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;

View file

@ -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);