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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
Jøger Hansegård 2024-08-14 16:44:16 +02:00 committed by Tor Arne Vestbø
parent ff8068deb4
commit a645128c29

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