Details
-
Bug
-
Resolution: Won't Do
-
P2: Important
-
None
-
5.15.6
-
None
Description
I'm getting a couple bugs since my port from Qt4 to Qt5.
- I'm positioning dialog popup relative to MainWindow::pos() and noticed the dialog position is wrong when displayed after MainWindow::show() but before exec()
- When restoring MainWindow to a maximized state (with saveGeometry, saveState/restoreGeometry, restoreState) I get occasional windows that are in windowed mode, at a wrong position, but in a maximized state.
Origin
I narrowed these bugs to the same root cause in Widget::restoreGeometry()
https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=blob;f=src/widgets/kernel/qwidget.cpp;h=fa6915e545555ac0e5e1ebf001171e36814e8ee7;hb=HEAD#l7484
Although restoring window to a maximized state, the setGeometry() call is passed the QRect from the normal state
setGeometry(restoredNormalGeometry);
The setWindowState call a few lines later is in charge of applying the maximized state, however this will not update the internal crect to the maximized value.
setWindowState(ws); d_func()->topData()->normalGeometry = restoredNormalGeometry;
Proposed fix
https://codereview.qt-project.org/c/qt/qtbase/+/433373
Patch is attached, it consists in adding 2 lines to set the crect, similar to how it is done in setGeometry()
if (testAttribute(Qt::WA_WState_Created)) { data->crect.setTopLeft(restoredGeometry.topLeft()); data->crect.setSize(restoredGeometry.size().boundedTo(maximumSize()).expandedTo(minimumSize())); }
Looking forward hearing your feedback