If you set the window to "maximized", save the layout and later, while the window again is in a "maximized" state, restore the saved layout, it'll be set to "normal".
This issue is similar to #477, but a slightly different case.
I can reproduce this with the qtwidgets_dockwidgets example as well as with TestNativeQPA::tst_restoreMaximizedFromNormal, when removing the following two lines:
Note, that this test then covers only the case where, before restoring, the window is maximized on the same screen as it shall be restored. But this doesn't need to be the case.
I had a look at LayoutSaver::restoreLayout and at // 1. Restore main windows the else-path is taken and within deserializeWindowGeometry the saved.normalGeometry is applied.
There is a comment Later it's maximized ..., which makes sense, but this maximization later on simply seems to be missing.
If I add the following snippet at the end of deserializeWindowGeometry, the problem seems to be fixed, but this works only for Qt6!
if (!isNormalWindowState(saved.windowState))
{
window->setWindowState(saved.windowState);
}
I quite don't understand what should be handled within deserializeWindowGeometry and what within the if in restoreLayout.
Adding another else if path in the latter fixes the problem for Qt6 and Qt5:
} else if (window->windowState() == WindowState::Maximized && mw.windowState == WindowState::Maximized) {
// Never call deserializeWindowGeometry() on a maximized window.
// If window is maximized and we're restoring it to "maximized", then 1st change state to "normal",
// then set geometry and finally set it to "maximized" again.
window->setWindowState(WindowState::None);
d->deserializeWindowGeometry(mw, window);
window->setWindowState(mw.windowState);
If you set the window to "maximized", save the layout and later, while the window again is in a "maximized" state, restore the saved layout, it'll be set to "normal". This issue is similar to #477, but a slightly different case.
I can reproduce this with the
qtwidgets_dockwidgets
example as well as withTestNativeQPA::tst_restoreMaximizedFromNormal
, when removing the following two lines:Note, that this test then covers only the case where, before restoring, the window is maximized on the same screen as it shall be restored. But this doesn't need to be the case.
I had a look at
LayoutSaver::restoreLayout
and at// 1. Restore main windows
theelse
-path is taken and withindeserializeWindowGeometry
thesaved.normalGeometry
is applied. There is a commentLater it's maximized ...
, which makes sense, but this maximization later on simply seems to be missing. If I add the following snippet at the end ofdeserializeWindowGeometry
, the problem seems to be fixed, but this works only for Qt6!I quite don't understand what should be handled within
deserializeWindowGeometry
and what within theif
inrestoreLayout
. Adding anotherelse if
path in the latter fixes the problem for Qt6 and Qt5: