From e655d571e05a7d7b91084076841508dc22d5fea1 Mon Sep 17 00:00:00 2001 From: Kyle Neideck Date: Wed, 24 Apr 2024 17:55:46 +1000 Subject: [PATCH] Fix the About panel not always opening on macOS 14.4+. --- BGMApp/BGMApp/Base.lproj/MainMenu.xib | 4 ++-- BGMApp/BGMApp/Preferences/BGMAboutPanel.m | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/BGMApp/BGMApp/Base.lproj/MainMenu.xib b/BGMApp/BGMApp/Base.lproj/MainMenu.xib index 8431f35..27bf97d 100644 --- a/BGMApp/BGMApp/Base.lproj/MainMenu.xib +++ b/BGMApp/BGMApp/Base.lproj/MainMenu.xib @@ -148,8 +148,8 @@ - - + + diff --git a/BGMApp/BGMApp/Preferences/BGMAboutPanel.m b/BGMApp/BGMApp/Preferences/BGMAboutPanel.m index b266d40..c15e90e 100644 --- a/BGMApp/BGMApp/Preferences/BGMAboutPanel.m +++ b/BGMApp/BGMApp/Preferences/BGMAboutPanel.m @@ -140,9 +140,25 @@ - (void) initAboutPanel { - (void) show { DebugMsg("BGMAboutPanel::showAboutPanel: Opening \"About Background Music\" panel"); - [NSApp activateIgnoringOtherApps:YES]; + + // We have to make aboutPanel visible before calling [NSApp activateIgnoringOtherApps:YES] + // or the app won't be activated the first time (not sure why it only happens the first + // time) and aboutPanel won't open. WindowServer logs this explanation: + // 0[SetFrontProcessWithInfo]: CPS: Rejecting the request for pid 1234 due to the activation count being 0; launch ts=19302059379458, current time=19314267188375, window count = 0. [aboutPanel setIsVisible:YES]; [aboutPanel makeKeyAndOrderFront:self]; + + // On macOS 14.4, aboutPanel needs "Release When Closed" unchecked in MainMenu.xib. Otherwise, + // aboutPanel will never open again if you click the close button. + + // This is deprecated for NSApplication.activate, but that stops aboutPanel from ever being shown. + [NSApp activateIgnoringOtherApps:YES]; + + DebugMsg("BGMAboutPanel::showAboutPanel: Finished opening panel. " + "aboutPanel.isVisible %d, aboutPanel.isKeyWindow %d, NSApp.isActive %d", + aboutPanel.isVisible, + aboutPanel.isKeyWindow, + NSApp.isActive); } @end