SDL: cocoa: Don't use trick of briefly focusing the Dock on newer macOS releases.

From 279dabfc96631965f8dad2e39d57daa4b9130d24 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 26 Jun 2025 14:23:26 -0400
Subject: [PATCH] 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.
---
 src/video/cocoa/SDL_cocoaevents.m | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m
index 58cae9955460c..fd178b8dacddf 100644
--- a/src/video/cocoa/SDL_cocoaevents.m
+++ b/src/video/cocoa/SDL_cocoaevents.m
@@ -311,15 +311,26 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam
 
 - (void)applicationDidFinishLaunching:(NSNotification *)notification
 {
-    if (!SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", true))
+    if (!SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", true)) {
         return;
+    }
 
     /* The menu bar of SDL apps which don't have the typical .app bundle
      * structure fails to work the first time a window is created (until it's
      * de-focused and re-focused), if this call is in Cocoa_RegisterApp instead
-     * of here. https://bugzilla.libsdl.org/show_bug.cgi?id=3051
+     * of here. https://github.com/libsdl-org/SDL/issues/1913
      */
-    if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, false)) {
+
+    /* this apparently became unnecessary on macOS 14.0, and will addition pop up a
+       hidden dock if you're moving the mouse during launch, so change the default
+       behaviour there.  https://github.com/libsdl-org/SDL/issues/10340
+       (13.6 still needs it, presumably 13.7 does, too.) */
+    bool background_app_default = false;
+    if (@available(macOS 14.0, *)) {
+        background_app_default = true;  /* by default, don't explicitly activate the dock and then us again to force to foreground */
+    }
+
+    if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, background_app_default)) {
         // Get more aggressive for Catalina: activate the Dock first so we definitely reset all activation state.
         for (NSRunningApplication *i in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) {
             [i activateWithOptions:NSApplicationActivateIgnoringOtherApps];