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.

Change-Id: I84bc25668d702c3475dfbd75a94dd3ed43a1695c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit a645128c296756ea6c7e70259958a0d000d029e5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Jøger Hansegård 2024-08-14 16:44:16 +02:00 committed by Qt Cherry-pick Bot
parent 839695567f
commit ac81827ed8

View File

@ -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();