Skip to content

fix(macos): raise Preferences after Browse so it stays in front - #283

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/macos-prefs-raise-after-browse
Jul 3, 2026
Merged

fix(macos): raise Preferences after Browse so it stays in front#283
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/macos-prefs-raise-after-browse

Conversation

@got3nks

@got3nks got3nks commented Jul 3, 2026

Copy link
Copy Markdown

Bug

Clicking any Browse button inside Preferences on macOS visually closes the whole Preferences dialog, on both file-picked and Cancel. Reproduces on the pre-existing video-player picker (IDC_BROWSEV), the browser picker (IDC_SELBROWSER), and — once #280 lands — the ffprobe path picker (IDC_MEDIAMETA_FFPROBEBROWSE). Windows (wxMSW) and Linux (wxGTK 3.2) don't reproduce.

Root cause

Not a close event we were mishandling. Debug-tracing showed:

  • Before wxFileSelector: IsShown() == true, IsBeingDeleted() == false
  • After wxFileSelector (Cancel): str == "", IsShown() == true, IsBeingDeleted() == false
  • OnClose never fires

So the dialog was still logically alive after the file selector returned — it just wasn't visible. Cmd+Tab back to aMule confirmed it: the Preferences window was ordered behind the main aMule window. The modal NSOpenPanel that wxCocoa opens steals key-window status while shown; when it dismisses, Cocoa returns focus + Z-order to whichever aMule window was active before Preferences opened, not to Preferences itself.

Fix

Raise() on the Preferences dialog after wxFileSelector returns, macOS-only. Restores Z-order so the dialog sits in front of the main window where the user left it.

wxString str = wxFileSelector(title, "", "", "", wildcard, 0, this);

#ifdef __WXMAC__
    // wxCocoa quirk: the modal NSOpenPanel steals key-window status;
    // when it dismisses [...] Raise() restores its Z-order.
    Raise();
#endif

Wrapped in #ifdef __WXMAC__ so wxGTK / wxMSW pay nothing — they don't reproduce the bug (Windows CommonDialog is a real top-level, wxGTK's file dialog doesn't reshuffle Z-order the same way).

Verified

Local build + retest on macOS 15 ARM64: Preferences → Files → any Browse button → Cancel now leaves Preferences in front. Same for Open. Windows / Linux behaviour unchanged (Raise() is a no-op there, but the #ifdef guards against paying the call at all).

Clicking any Browse button inside Preferences on macOS (video player
picker on IDC_BROWSEV, browser picker on IDC_SELBROWSER, and — once
amule-project#280 lands — the ffprobe path picker on IDC_MEDIAMETA_FFPROBEBROWSE)
visually closes the whole Preferences dialog on both Open and Cancel.

Debug-tracing the dialog state showed it was still logically alive
after wxFileSelector returned (IsShown() == true, IsBeingDeleted()
== false, no wxEVT_CLOSE_WINDOW fired), so the disappearance wasn't
a close event we were mishandling. The modal NSOpenPanel that wxCocoa
opens steals key-window status while shown; when it dismisses, Cocoa
returns focus + Z-order to whichever aMule window was active before
Preferences opened, not to Preferences itself. The dialog sits alive
but ordered behind the main aMule window — Cmd+Tab back to aMule
brings it right up.

Fix: call Raise() on Preferences after wxFileSelector returns on
macOS. Wrapped in #ifdef __WXMAC__ so wxGTK / wxMSW pay nothing
(they don't reproduce the bug — the Windows CommonDialog is a real
top-level and wxGTK's file dialog doesn't reshuffle Z-order the same
way).
@got3nks
got3nks merged commit d81edb5 into amule-org:master Jul 3, 2026
11 checks passed
@got3nks
got3nks deleted the fix/macos-prefs-raise-after-browse branch July 3, 2026 12:39
Cflsft pushed a commit to Cflsft/amule that referenced this pull request Jul 6, 2026
…e-org#283)

Clicking any Browse button inside Preferences on macOS (video player
picker on IDC_BROWSEV, browser picker on IDC_SELBROWSER, and — once
amule-org#280 lands — the ffprobe path picker on IDC_MEDIAMETA_FFPROBEBROWSE)
visually closes the whole Preferences dialog on both Open and Cancel.

Debug-tracing the dialog state showed it was still logically alive
after wxFileSelector returned (IsShown() == true, IsBeingDeleted()
== false, no wxEVT_CLOSE_WINDOW fired), so the disappearance wasn't
a close event we were mishandling. The modal NSOpenPanel that wxCocoa
opens steals key-window status while shown; when it dismisses, Cocoa
returns focus + Z-order to whichever aMule window was active before
Preferences opened, not to Preferences itself. The dialog sits alive
but ordered behind the main aMule window — Cmd+Tab back to aMule
brings it right up.

Fix: call Raise() on Preferences after wxFileSelector returns on
macOS. Wrapped in #ifdef __WXMAC__ so wxGTK / wxMSW pay nothing
(they don't reproduce the bug — the Windows CommonDialog is a real
top-level and wxGTK's file dialog doesn't reshuffle Z-order the same
way).
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.

1 participant