Skip to content

Commit 279dabf

Browse files
committed
cocoa: Don't use trick of briefly focusing the Dock on newer macOS releases.
On newer systems, the trick isn't necessary, and if you do it, if the user is moving the mouse when launching the app, it'll show a hidden Dock. Fixes #10340.
1 parent afa2724 commit 279dabf

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/video/cocoa/SDL_cocoaevents.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,26 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam
311311

312312
- (void)applicationDidFinishLaunching:(NSNotification *)notification
313313
{
314-
if (!SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", true))
314+
if (!SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", true)) {
315315
return;
316+
}
316317

317318
/* The menu bar of SDL apps which don't have the typical .app bundle
318319
* structure fails to work the first time a window is created (until it's
319320
* de-focused and re-focused), if this call is in Cocoa_RegisterApp instead
320-
* of here. https://bugzilla.libsdl.org/show_bug.cgi?id=3051
321+
* of here. https://github.com/libsdl-org/SDL/issues/1913
321322
*/
322-
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, false)) {
323+
324+
/* this apparently became unnecessary on macOS 14.0, and will addition pop up a
325+
hidden dock if you're moving the mouse during launch, so change the default
326+
behaviour there. https://github.com/libsdl-org/SDL/issues/10340
327+
(13.6 still needs it, presumably 13.7 does, too.) */
328+
bool background_app_default = false;
329+
if (@available(macOS 14.0, *)) {
330+
background_app_default = true; /* by default, don't explicitly activate the dock and then us again to force to foreground */
331+
}
332+
333+
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, background_app_default)) {
323334
// Get more aggressive for Catalina: activate the Dock first so we definitely reset all activation state.
324335
for (NSRunningApplication *i in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) {
325336
[i activateWithOptions:NSApplicationActivateIgnoringOtherApps];

0 commit comments

Comments
 (0)