summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJøger Hansegård <[email protected]>2024-08-14 16:44:16 +0200
committerTor Arne Vestbø <[email protected]>2024-10-07 12:30:16 +0000
commita645128c296756ea6c7e70259958a0d000d029e5 (patch)
tree2c5409ae3abbebf4c9f0cb0824100b28b44d4d20
parentff8068deb45e45eb683745486956d3c6c795a708 (diff)
Add WS_CLIPCHILDREN style to native window in embeddedwindows test
When a native/foreign window is used as a parent, its WS_CLIPSCHILDREN style should be enabled. If it is not, the parent will paint on top of the children and cause flickering. It is not Qt's responsiblity to adjust the styles of foreign windows, so instead we document this in the manual test. Pick-to: 6.8 Change-Id: I84bc25668d702c3475dfbd75a94dd3ed43a1695c Reviewed-by: Tor Arne Vestbø <[email protected]>
-rw-r--r--tests/manual/embeddedwindows/main.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/manual/embeddedwindows/main.cpp b/tests/manual/embeddedwindows/main.cpp
index e34c7206eaa..c88d1ddb99d 100644
--- a/tests/manual/embeddedwindows/main.cpp
+++ b/tests/manual/embeddedwindows/main.cpp
@@ -93,6 +93,15 @@ int main(int argc, char *argv[])
NativeWindow nativeParentWindow;
if (QWindow *foreignWindow = QWindow::fromWinId(nativeParentWindow)) {
+
+#ifdef Q_OS_WIN
+ // Native parent windows should have WS_CLIPCHILDREN style set
+ // to prevent overdrawing child area and cause flickering.
+ const HWND hwnd = reinterpret_cast<HWND>(foreignWindow->winId());
+ const LONG_PTR oldStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
+ SetWindowLongPtr(hwnd, GWL_STYLE, oldStyle | WS_CLIPCHILDREN);
+#endif
+
foreignWindow->setParent(&window);
foreignWindow->setGeometry(50, 350, 100, 100);
foreignWindow->showNormal();