Skip to content

Commit

Permalink
Add WS_CLIPCHILDREN style to native window in embeddedwindows test
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jogerh authored and torarnv committed Oct 7, 2024
1 parent ff8068d commit a645128
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/manual/embeddedwindows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a645128

Please sign in to comment.