Fix the About panel not always opening on macOS 14.4+.

This commit is contained in:
Kyle Neideck 2024-04-24 17:55:46 +10:00
parent 9257d50b15
commit e655d571e0
No known key found for this signature in database
GPG key ID: CAA8D9B8E39EC18C
2 changed files with 19 additions and 3 deletions

View file

@ -148,8 +148,8 @@
</subviews>
<point key="canvasLocation" x="117" y="-45"/>
</customView>
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" visibleAtLaunch="NO" animationBehavior="default" id="Cf4-3V-gl1" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" utility="YES"/>
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="Cf4-3V-gl1" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" utility="YES" nonactivatingPanel="YES"/>
<windowPositionMask key="initialPositionMask" topStrut="YES"/>
<rect key="contentRect" x="248" y="350" width="1002" height="335"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="920"/>

View file

@ -140,9 +140,25 @@ static NSInteger const kContributorsLabelTag = 4;
- (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