From 269e275cb0f465a4198087639b666373fc9b5842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 6 Feb 2015 23:46:14 +0100 Subject: [PATCH] smart placement of unregularily max'd clients 1. if a client has oversize, ensure to keep the titlebar in sight 2. if a maximized client *almost* covers the entire maximization area, users can easily be trapped to click into the missing pixels, thus the client below. Therfore the clients is then stuffed into one corner, with preference to the titlebar edge and the screen area (ie. *away* from panels and towards actual screen borders because of fitt's law) BUG: 349935 REVIEW: 124286 FIXED-IN: 5.4 --- geometry.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/geometry.cpp b/geometry.cpp index a47c5676d7..bde47ee73a 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2374,6 +2374,35 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust) r.moveRight(qMin(clientArea.right(), r.right())); } else { r.moveCenter(clientArea.center()); + const bool closeHeight = r.height() > 97*clientArea.height()/100; + const bool closeWidth = r.width() > 97*clientArea.width() /100; + const bool overHeight = r.height() > clientArea.height(); + const bool overWidth = r.width() > clientArea.width(); + if (closeWidth || closeHeight) { + Position titlePos = titlebarPosition(); + const QRect screenArea = workspace()->clientArea(ScreenArea, clientArea.center(), desktop()); + if (closeHeight) { + bool tryBottom = titlePos == PositionBottom; + if ((overHeight && titlePos == PositionTop) || + screenArea.top() == clientArea.top()) + r.setTop(clientArea.top()); + else + tryBottom = true; + if (tryBottom && + (overHeight || screenArea.bottom() == clientArea.bottom())) + r.setBottom(clientArea.bottom()); + } + if (closeWidth) { + bool tryLeft = titlePos == PositionLeft; + if ((overWidth && titlePos == PositionRight) || + screenArea.right() == clientArea.right()) + r.setRight(clientArea.right()); + else + tryLeft = true; + if (tryLeft && (overWidth || screenArea.left() == clientArea.left())) + r.setLeft(clientArea.left()); + } + } } r.moveTopLeft(rules()->checkPosition(r.topLeft())); }