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
This commit is contained in:
Thomas Lübking 2015-02-06 23:46:14 +01:00
parent eb71b47db4
commit 269e275cb0

View file

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