Skip to content

Fixes handling of native / alien widgets when (un)docking#820

Merged
githubuser0xFFFF merged 4 commits into
githubuser0xFFFF:masterfrom
RubendeBruin:master
Mar 10, 2026
Merged

Fixes handling of native / alien widgets when (un)docking#820
githubuser0xFFFF merged 4 commits into
githubuser0xFFFF:masterfrom
RubendeBruin:master

Conversation

@RubendeBruin

Copy link
Copy Markdown

These two changes fix the artifacts for this situation.

Copilot AI and others added 4 commits March 7, 2026 08:51
When a content widget (e.g. VTK/OpenGL) calls winId() to get a native
window handle, Qt propagates native-window creation up the ancestor chain.
This makes CDockWidget, CDockAreaWidget, and CDockContainerWidget all
become native OS windows unexpectedly. Reparenting these native dock
widgets during floating or resizing then causes drawing artifacts.

Fix: set Qt::WA_DontCreateNativeAncestors on the content widget in
CDockWidget::setWidget() to stop native-window creation from propagating
up into the dock hierarchy.

Co-authored-by: RubendeBruin <34062862+RubendeBruin@users.noreply.github.com>
Three targeted fixes for the native/alien widget mixing problem:

1. Revert WA_DontCreateNativeAncestors from CDockWidget::setWidget().
   Setting it on the content widget created a broken native-inside-alien
   hierarchy: the QScrollArea (alien) could not clip its native child, so
   content escaped the scrollbox bounds; and alien CAutoHideDockContainer
   could not appear above the native content widget.
   Allowing natural propagation means QScrollArea also goes native, and OS
   parent/child window clipping works correctly.

2. Fix CDockContainerWidget::removeDockArea to use internalWinId() instead
   of testAttribute(WA_NativeWindow). WA_NativeWindow is only set when a
   widget is explicitly made native; widgets that became native through
   upward propagation from a descendant calling winId() have a real native
   window handle (internalWinId() != 0) but WA_NativeWindow may be unset.
   Setting their parent to nullptr would create a free-floating invisible
   OS window and cause drawing artifacts.

3. Fix CAutoHideDockContainer::collapseView: when the parent dock container
   is native but the auto-hide panel is still alien, promote the panel to a
   native window (winId()) before raise(). The OS always renders native
   child windows above a parent window's painted alien content, so an alien
   auto-hide panel can never appear above native sibling dock areas. Once
   the panel has its own OS-level window, raise() operates on OS Z-order
   and correctly places it above native content siblings.

Co-authored-by: RubendeBruin <34062862+RubendeBruin@users.noreply.github.com>
…rors

Fix docking system to handle mix of native and alien Qt widgets
@RubendeBruin RubendeBruin marked this pull request as draft March 8, 2026 12:24
@RubendeBruin

RubendeBruin commented Mar 8, 2026

Copy link
Copy Markdown
Author

these changes fix issue #819

@RubendeBruin RubendeBruin marked this pull request as ready for review March 8, 2026 20:20
@RubendeBruin RubendeBruin changed the title WIP: Native and alien mix Fixes handling of native / alien widgets when (un)docking Mar 8, 2026
@RubendeBruin

Copy link
Copy Markdown
Author

@githubuser0xFFFF, Ready for review. Let me know if you want me to squash the commits, although I believe github can do that automatically when merging.

These two changes fix all the drawing issues that I'm having with my application.

@githubuser0xFFFF githubuser0xFFFF merged commit ee3a526 into githubuser0xFFFF:master Mar 10, 2026
@githubuser0xFFFF

Copy link
Copy Markdown
Owner

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants