Fix updating fullscreen geometry restore

Currently, fullscreen geometry restore is computed from maximized
geometry restore. However, the latter is set only when the window is
maximized.

Also, updateGeometryRestoresForFullscreen() can be called when the
window has not been moved. Avoid updating geometry restore if the output
has not been changed.
This commit is contained in:
Vlad Zahorodnii 2022-05-01 21:52:58 +03:00
parent f51db012f2
commit f1f512791e

View file

@ -4017,24 +4017,31 @@ void Window::sendToOutput(Output *newOutput)
void Window::updateGeometryRestoresForFullscreen(Output *output)
{
QRect screenArea = workspace()->clientArea(MaximizeArea, this, output);
QRect newFullScreenGeometryRestore = screenArea;
if (!(maximizeMode() & MaximizeVertical)) {
newFullScreenGeometryRestore.setHeight(geometryRestore().height());
}
if (!(maximizeMode() & MaximizeHorizontal)) {
newFullScreenGeometryRestore.setWidth(geometryRestore().width());
}
newFullScreenGeometryRestore.setSize(newFullScreenGeometryRestore.size().boundedTo(screenArea.size()));
QSize move = (screenArea.size() - newFullScreenGeometryRestore.size()) / 2;
newFullScreenGeometryRestore.translate(move.width(), move.height());
const QRect screenArea = workspace()->clientArea(MaximizeArea, this, output);
QRect newGeometryRestore = QRect(screenArea.topLeft(), geometryRestore().size().boundedTo(screenArea.size()));
move = (screenArea.size() - newGeometryRestore.size()) / 2;
newGeometryRestore.translate(move.width(), move.height());
// TODO: Reuse geometry calculation code in checkWorkspacePosition().
if (fullscreenGeometryRestore().isValid() && !screenArea.contains(fullscreenGeometryRestore().center())) {
QRect restore = screenArea;
if (!(requestedMaximizeMode() & MaximizeVertical)) {
restore.setHeight(fullscreenGeometryRestore().height());
}
if (!(requestedMaximizeMode() & MaximizeHorizontal)) {
restore.setWidth(fullscreenGeometryRestore().width());
}
restore.setSize(restore.size().boundedTo(screenArea.size()));
const QSize move = (screenArea.size() - restore.size()) / 2;
restore.translate(move.width(), move.height());
setFullscreenGeometryRestore(newFullScreenGeometryRestore);
setGeometryRestore(newGeometryRestore);
setFullscreenGeometryRestore(restore);
}
if (geometryRestore().isValid() && !screenArea.contains(geometryRestore().center())) {
QRect restore = QRect(screenArea.topLeft(), geometryRestore().size().boundedTo(screenArea.size()));
const QSize move = (screenArea.size() - restore.size()) / 2;
restore.translate(move.width(), move.height());
setGeometryRestore(restore);
}
}
void Window::checkWorkspacePosition(QRect oldGeometry, const VirtualDesktop *oldDesktop)