Skip to content

wxGUI: Suppress layer tree drag ghost on macOS to avoid phantom windows - #25

Open
petrasovaa wants to merge 1 commit into
mainfrom
layertree-mac-drag-phantom
Open

wxGUI: Suppress layer tree drag ghost on macOS to avoid phantom windows#25
petrasovaa wants to merge 1 commit into
mainfrom
layertree-mac-drag-phantom

Conversation

@petrasovaa

Copy link
Copy Markdown
Owner

Description

On macOS with wxPython 4.2.x, dragging a layer in the Layer Manager tree to reorder it leaves behind a small darker window (the drag ghost) that stays on screen — visible in Mission Control as a separate window — and these phantoms pile up with every drag until the GUI is closed.

Root cause is upstream: wx.DragImage draws the ghost through wxOverlay, whose native NSWindow is never removed from the screen on macOS in wxWidgets 3.2.x (wxWidgets/wxWidgets#26380). The fix (orderOut: call in Reset()) exists only in wxWidgets 3.3, not on the 3.2 branch, so no current wxPython release has it. The leaked window is a raw native window, unreachable from Python, so it cannot be cleaned up after the fact.

This workaround replaces the drag image class CustomTreeCtrl instantiates with a no-op version on macOS: no ghost is shown, so nothing leaks. The mouse capture that wx.DragImage.BeginDrag() would acquire is kept, so drag-and-drop reordering behaves exactly as before (drop-target row highlight and hand cursor still provide feedback). The workaround can be removed once wxPython bundles wxWidgets >= 3.3 or the fix is backported to 3.2.

Tested on macOS with wxPython 4.2.4: layers reorder correctly and no phantom windows accumulate.

The problem was investigated and the workaround written with Claude Code.

🤖 Generated with Claude Code

wx.DragImage in wxWidgets 3.2.x draws the drag ghost through wxOverlay,
whose native window is never removed from the screen on macOS (wxWidgets
issue 26380, fixed only in wxWidgets 3.3), so every layer drag in the
layer tree leaves behind a phantom window until the GUI closes. Replace
the drag image class CustomTreeCtrl instantiates with a no-op version on
macOS, keeping only the mouse capture wx.DragImage would acquire, so
dragging behaves the same but without the ghost.

The problem was investigated and the workaround written with Claude Code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant