diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-04-23 16:21:43 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-04-30 19:27:55 +0200 |
commit | 5da51e012094c6aad75238a04e0897d43a4975c6 (patch) | |
tree | ed495b7073ba48682f778832a599dbfdcf4f8b87 /tests | |
parent | 531e6d0b40dfb68fea7d0b867c587e68faaaf2b5 (diff) |
Only apply QWindow::setVisibility() on first show or explicit request
As a result of 16023fc77c423a267fcc48894ff942e94cf35b86 we were no longer
calling QWindow::setVisible or setVisibility from the QQuickWindowQmlImpl
overrides, but instead deferred them until applyWindowVisibility().
As a consequence, if the QWindow::Visibility of the QQuickWindowQmlImpl
was left at AutomaticVisibility, we would always apply the window state
when making the window visible or hidden, which is a major regression.
We should only apply the window state on first show, if the window's
visibility is AutomaticVisibility, or on explicit requests to set the
window's visibility.
This means a window with visibility: Window.Maximized will initially
show as maximized, but if the user then resizes the window and then
hides and shows it again, the window will show in the normal window
state, instead of re-applying the Window.Maximized visibility, which
matches the pre-6.7.0 behavior.
Fixes: QTBUG-124363
Pick-to: 6.7 6.7.1
Change-Id: Idc2078c17bd56026425acbabdc40174fd12558ca
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickwindow/data/visibilityDoesntClobberWindowState.qml | 5 | ||||
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 36 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/data/visibilityDoesntClobberWindowState.qml b/tests/auto/quick/qquickwindow/data/visibilityDoesntClobberWindowState.qml new file mode 100644 index 0000000000..af899ec5dd --- /dev/null +++ b/tests/auto/quick/qquickwindow/data/visibilityDoesntClobberWindowState.qml @@ -0,0 +1,5 @@ +import QtQuick + +Window { + +} diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 1e2553c107..ff3edb3b64 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -549,6 +549,8 @@ private slots: void visibleVsVisibility_data(); void visibleVsVisibility(); + void visibilityDoesntClobberWindowState(); + void eventTypes(); private: @@ -4139,6 +4141,40 @@ void tst_qquickwindow::visibleVsVisibility() QCOMPARE(window->isVisible(), expectVisible); } +void tst_qquickwindow::visibilityDoesntClobberWindowState() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("visibilityDoesntClobberWindowState.qml")); + QObject *created = component.create(); + QScopedPointer<QObject> cleanup(created); + QVERIFY(created); + + QQuickWindow *window = qobject_cast<QQuickWindow*>(created); + QVERIFY(window); + + window->showMaximized(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + QCOMPARE(window->windowState(), Qt::WindowMaximized); + + window->setProperty("visible", false); + window->setProperty("visible", true); + + QVERIFY(QTest::qWaitForWindowExposed(window)); + QCOMPARE(window->windowState(), Qt::WindowMaximized); + + EventFilter eventFilter; + window->installEventFilter(&eventFilter); + window->setProperty("visibility", QWindow::FullScreen); + QTRY_VERIFY(eventFilter.events.contains(QEvent::WindowStateChange)); + QCOMPARE(window->windowState(), Qt::WindowFullScreen); + + eventFilter.events.clear(); + window->setWindowState(Qt::WindowMaximized); + QTRY_VERIFY(eventFilter.events.contains(QEvent::WindowStateChange)); + QTRY_COMPARE(window->windowState(), Qt::WindowMaximized); +} + void tst_qquickwindow::eventTypes() { QQmlEngine engine; |