add stricter heuristics to initial maximization

instead of just checking whether the decorated client will be bigger
than the workarea and take that as reason to maximize it, we will not do
so if it's smaller than the full are and the managed client bigger than
the screen (because it makes sense for the user to move it around and the
requested dimension is out of what the client could have stored when closing
maximized)

REVIEW: 108705
This commit is contained in:
Thomas Lübking 2013-02-01 19:44:06 +01:00
parent 8129451ab3
commit 32efd0f1e0

View file

@ -386,20 +386,41 @@ bool Client::manage(Window w, bool isMapped)
if (isMaximizable() && (width() >= area.width() || height() >= area.height())) { if (isMaximizable() && (width() >= area.width() || height() >= area.height())) {
// Window is too large for the screen, maximize in the // Window is too large for the screen, maximize in the
// directions necessary // directions necessary
if (width() >= area.width() && height() >= area.height()) { const QSize ss = workspace()->clientArea(ScreenArea, area.center(), desktop()).size();
dontKeepInArea = true; const QSize fs = workspace()->clientArea(FullArea, geom.center(), desktop()).size();
maximize(Client::MaximizeFull); const QSize cs = clientSize();
geom_restore = QRect(); // Use placement when unmaximizing int pseudo_max = Client::MaximizeRestore;
} else if (width() >= area.width()) { if (width() >= area.width())
maximize(Client::MaximizeHorizontal); pseudo_max |= Client::MaximizeHorizontal;
geom_restore = QRect(); // Use placement when unmaximizing if (height() >= area.height())
geom_restore.setY(y()); // But only for horizontal direction pseudo_max |= Client::MaximizeVertical;
geom_restore.setHeight(height());
} else if (height() >= area.height()) { // heuristics:
maximize(Client::MaximizeVertical); // if decorated client is smaller than the entire screen, the user might want to move it around (multiscreen)
geom_restore = QRect(); // Use placement when unmaximizing // in this case, if the decorated client is bigger than the screen (+1), we don't take this as an
geom_restore.setX(x()); // But only for vertical direction // attempt for maximization, but just constrain the size (the window simply wants to be bigger)
geom_restore.setWidth(width()); // NOTICE
// i intended a second check on cs < area.size() ("the managed client ("minus border") is smaller
// than the workspace") but gtk / gimp seems to store it's size including the decoration,
// thus a former maximized window wil become non-maximized
if (width() < fs.width() && (cs.width() > ss.width()+1))
pseudo_max &= ~Client::MaximizeHorizontal;
if (height() < fs.height() && (cs.height() > ss.height()+1))
pseudo_max &= ~Client::MaximizeVertical;
if (pseudo_max != Client::MaximizeRestore) {
maximize((MaximizeMode)pseudo_max);
// from now on, care about maxmode, since the maximization call will override mode for fix aspects
dontKeepInArea = (max_mode == Client::MaximizeFull);
geom_restore = QRect(); // Use placement when unmaximizing ...
if (!(max_mode & Client::MaximizeVertical)) {
geom_restore.setY(y()); // ...but only for horizontal direction
geom_restore.setHeight(height());
}
if (!(max_mode & Client::MaximizeHorizontal)) {
geom_restore.setX(x()); // ...but only for vertical direction
geom_restore.setWidth(width());
}
} }
} }
} }