summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel/qwindow
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-11-13 11:12:50 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-11-13 19:14:59 +0100
commitdb33628452c5ccbf07b901405fba74525f7192c9 (patch)
tree8a480081b4721e26835fb91105eb20c2ff8f0c91 /tests/auto/gui/kernel/qwindow
parent93077dd1f237730a26714d77bb7e91542f96affc (diff)
Ensure foreign window can be reparented out of contained window again
A foreign window embedded into a Qt hierarchy must also support being removed from that window hierarchy. Pick-to: 6.6 Change-Id: Id4d08079ff19d67a8989937bc72602e8bd14b31b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/gui/kernel/qwindow')
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
index c42bb9d974..a43939a21b 100644
--- a/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
@@ -81,10 +81,17 @@ void tst_ForeignWindow::embedForeignWindow()
NativeWindow nativeWindow;
QVERIFY(nativeWindow);
+ // Top level windows may not have 0 as their winId, e.g. on
+ // XCB the root window of the screen is used.
+ const auto originalParentWinId = nativeWindow.parentWinId();
+
// As a prerequisite to that, we must be able to reparent the foreign window
std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
- foreignWindow.release()->setParent(&parentWindow);
+ foreignWindow->setParent(&parentWindow);
QTRY_COMPARE(nativeWindow.parentWinId(), parentWindow.winId());
+
+ foreignWindow->setParent(nullptr);
+ QTRY_COMPARE(nativeWindow.parentWinId(), originalParentWinId);
}
#include <tst_foreignwindow.moc>