From 6b148f1866d88f9d33dd8ce7e3bb97def46753f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sat, 12 Nov 2011 21:39:06 +0100 Subject: [PATCH] Move maximization when managing client Maximization of oversized windows must happen BEFORE keepInArea() is called because that will through resizeWithChecks() lead to an artificial constrainment to the WorkArea which is the combination of all screens minus all struts this fails if only one screen struts and as a result the window is no more bigger than FullArea which is used as maximization enforcing condition. (Maximization must also happen AFTER placement, because otherwise the window will eventually be maximized to the wrong MaximizeArea - Screens(s) - (local) struts depending on xinerama settings) BUG:285967 CCBUG:286146 CCBUG:183694 FIXED-IN:4.8 --- manage.cpp | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/manage.cpp b/manage.cpp index fe1086cf4c..1877a3d96b 100644 --- a/manage.cpp +++ b/manage.cpp @@ -373,6 +373,38 @@ bool Client::manage(Window w, bool isMapped) placementDone = true; } + // bugs #285967, #286146, #183694 + // geometry() now includes the requested size and the decoration and is at the correct screen/position (hopefully) + // Maximization for oversized windows must happen NOW. + // If we effectively pass keepInArea(), the window will resizeWithChecks() - i.e. constrained + // to the combo of all screen MINUS all struts on the edges + // If only one screen struts, this will affect screens as a side-effect, the window is artificailly shrinked + // below the screen size and as result no more maximized what breaks KMainWindow's stupid width+1, height+1 hack + // TODO: get KMainWindow a correct state storage what will allow to store the restore size as well. + + if (!session) { // has a better handling of this + geom_restore = geometry(); // Remember restore geometry + if (isMaximizable() && (width() >= area.width() || height() >= area.height())) { + // Window is too large for the screen, maximize in the + // directions necessary + if (width() >= area.width() && height() >= area.height()) { + dontKeepInArea = true; + maximize(Client::MaximizeFull); + geom_restore = QRect(); // Use placement when unmaximizing + } else if (width() >= area.width()) { + maximize(Client::MaximizeHorizontal); + geom_restore = QRect(); // Use placement when unmaximizing + geom_restore.setY(y()); // But only for horizontal direction + geom_restore.setHeight(height()); + } else if (height() >= area.height()) { + maximize(Client::MaximizeVertical); + geom_restore = QRect(); // Use placement when unmaximizing + geom_restore.setX(x()); // But only for vertical direction + geom_restore.setWidth(width()); + } + } + } + if ((!isSpecialWindow() || isToolbar()) && isMovable() && !dontKeepInArea) keepInArea(area, partial_keep_in_area); @@ -438,26 +470,6 @@ bool Client::manage(Window w, bool isMapped) geom_fs_restore = session->fsrestore; } } else { - geom_restore = geometry(); // Remember restore geometry - if (isMaximizable() && (width() >= area.width() || height() >= area.height())) { - // Window is too large for the screen, maximize in the - // directions necessary - if (width() >= area.width() && height() >= area.height()) { - maximize(Client::MaximizeFull); - geom_restore = QRect(); // Use placement when unmaximizing - } else if (width() >= area.width()) { - maximize(Client::MaximizeHorizontal); - geom_restore = QRect(); // Use placement when unmaximizing - geom_restore.setY(y()); // But only for horizontal direction - geom_restore.setHeight(height()); - } else if (height() >= area.height()) { - maximize(Client::MaximizeVertical); - geom_restore = QRect(); // Use placement when unmaximizing - geom_restore.setX(x()); // But only for vertical direction - geom_restore.setWidth(width()); - } - } - // Window may want to be maximized // done after checking that the window isn't larger than the workarea, so that // the restore geometry from the checks above takes precedence, and window