Commit f1f51279 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

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.
parent f51db012
Pipeline #171725 passed with stage
in 21 minutes and 39 seconds
......@@ -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());
const QRect screenArea = workspace()->clientArea(MaximizeArea, this, output);
// 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(restore);
}
newFullScreenGeometryRestore.setSize(newFullScreenGeometryRestore.size().boundedTo(screenArea.size()));
QSize move = (screenArea.size() - newFullScreenGeometryRestore.size()) / 2;
newFullScreenGeometryRestore.translate(move.width(), move.height());
QRect newGeometryRestore = QRect(screenArea.topLeft(), geometryRestore().size().boundedTo(screenArea.size()));
move = (screenArea.size() - newGeometryRestore.size()) / 2;
newGeometryRestore.translate(move.width(), move.height());
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());
setFullscreenGeometryRestore(newFullScreenGeometryRestore);
setGeometryRestore(newGeometryRestore);
setGeometryRestore(restore);
}
}
void Window::checkWorkspacePosition(QRect oldGeometry, const VirtualDesktop *oldDesktop)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment