From ac81827ed8cd652e07001397ebc46f5c440401bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= Date: Wed, 14 Aug 2024 16:44:16 +0200 Subject: [PATCH] Add WS_CLIPCHILDREN style to native window in embeddedwindows test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Change-Id: I84bc25668d702c3475dfbd75a94dd3ed43a1695c Reviewed-by: Tor Arne Vestbø (cherry picked from commit a645128c296756ea6c7e70259958a0d000d029e5) Reviewed-by: Qt Cherry-pick Bot --- tests/manual/embeddedwindows/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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(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();