SDL: cocoa: Fix SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=0. (649c3)

From 649c36c5766c18c368d4f7c6e83c280358dfe30f Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 5 Feb 2026 18:53:41 -0500
Subject: [PATCH] cocoa: Fix SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=0.

This hint is documented to not just turn off fullscreen windows going into a
new Fullscreen Space, but also to make the green button on a resizeable
window's title bar do a maximize/zoom instead of make the window fullscreen.

Previously, this only did the former and not the latter (or perhaps it worked
and the defaults changed in a newer macOS, we aren't sure).

Fixes #7470.

(cherry picked from commit 50f3adec7736a5dd9223e217e46d3abc1f95d790)
---
 src/video/cocoa/SDL_cocoawindow.m | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 2f12a9525ce29..412a6a3202a2f 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1814,12 +1814,12 @@ int Cocoa_CreateWindow(_THIS, SDL_Window * window)
     }
 #endif
 
-    if (videodata.allow_spaces) {
+    /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
+    if ((window->flags & SDL_WINDOW_RESIZABLE) && videodata.allow_spaces) {
         /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
-        if (window->flags & SDL_WINDOW_RESIZABLE) {
-            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
-            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
-        }
+        [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+    } else {
+        [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenNone];
     }
 
     if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
@@ -2124,13 +2124,11 @@ void Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
     if (![listener isInFullscreenSpace]) {
         SetWindowStyle(window, GetWindowStyle(window));
     }
-    if (videodata.allow_spaces) {
-        if (resizable) {
-            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
-            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
-        } else {
-            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
-        }
+    if (resizable && videodata.allow_spaces) {
+        /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
+        [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+    } else {
+        [nswindow setCollectionBehavior:NSWindowCollectionBehaviorNone];
     }
 }}