wxGUI: Suppress layer tree drag ghost on macOS to avoid phantom windows - #25
Open
petrasovaa wants to merge 1 commit into
Open
wxGUI: Suppress layer tree drag ghost on macOS to avoid phantom windows#25petrasovaa wants to merge 1 commit into
petrasovaa wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.DragImagedraws the ghost throughwxOverlay, whose nativeNSWindowis never removed from the screen on macOS in wxWidgets 3.2.x (wxWidgets/wxWidgets#26380). The fix (orderOut:call inReset()) 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
CustomTreeCtrlinstantiates with a no-op version on macOS: no ghost is shown, so nothing leaks. The mouse capture thatwx.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