Commit a164c9d24541f7d3e8fb224f1b192827d37270b1

uyjulian 2022-01-04T10:43:34

SDL_cocoawindow.m: update fullscreen toggle when SDL_SetWindowResizable called

diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index bf86d7b..bca8eb4 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -2020,9 +2020,19 @@ Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
      */
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Cocoa_WindowListener *listener = data->listener;
+    NSWindow *nswindow = data->nswindow;
+    SDL_VideoData *videodata = ((SDL_WindowData *) window->driverdata)->videodata;
     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];
+        }
+    }
 }}
 
 void