qt5base-lts/tests/auto/widgets
Volker Hilsheimer 32edae5e26 Fix restoring main window state for maximized/fullscreen windows
On systems that asynchronously resize the window to maximized or full
screen state, the window will become visible in its normal geometry
before it gets the final size by the windowing system. This might cause
multiple resize events, to each of which the widget's layout responds
with a call to its setGeometry implementation.

The QMainWindowLayout is special in that it will shrink dock widgets if
there is not enough space for them, but it doesn't grow them back once
there is. With the initial resize event being for a smaller size than
what was restored, the state is not restored correctly, but remains in
the state that fit into the smallest size with which setGeometry got
called.

To fix this, we have to keep the restored state around until the window
either gets a size that is large enough for it to fit, or until we can
be reasonably certain that the windowing system is done resizing the
window while transitioning it to the maximized or full screen state.
Since across the various platforms and windowing systems there is no
reliable way to know when the window reaches its final size, we have
to use a timer that we (re)start for each call to setGeometry with a
size that's not large enough. Once the timer times out, we have to
give up; then the last layout state calculated is the final state.

To calculate the size of the layout, introduce a function to the
QDockAreaLayout that returns the size required for the current sizes
of the docks. Refactor sizeHint and minimumSize (which were identical)
into a helper template that takes member-function pointers to call the
respective method from the dock area layout's content items.

Add a test case for various permutations of the scenario. The timeout
of 150ms is based on running this test case repeatedly on various
desktop platforms and X11 window managers.

Fixes: QTBUG-46620
Change-Id: I489675c2c40d3308ac8194aeb4267172b2fb38be
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-16 09:46:22 +02:00
..
dialogs Activate tst_QDialog::showAsTool test on macOS 2021-10-11 15:48:33 +02:00
effects Fix tst_qgraphicseffect on Wayland 2021-03-11 08:04:21 +01:00
graphicsview Remove conditioning on Android embedded 2021-09-17 17:30:14 +02:00
itemviews Select a single range of cells in QTableView, away from merged cells 2021-10-12 09:07:54 +02:00
kernel macOS: Correctly record normalGeometry in Cocoa plugin 2021-10-14 17:19:38 +00:00
styles Implement missing support for 'em' and 'ex' lengths in style sheet 2021-08-10 19:43:02 +02:00
util Fix references to QGuiApplication::lastWindowClosed 2021-10-13 22:30:08 +02:00
widgets Fix restoring main window state for maximized/fullscreen windows 2021-10-16 09:46:22 +02:00
CMakeLists.txt Begin port of qtbase to CMake 2018-11-01 11:48:46 +00:00