We still want to generally minimize on focus loss, but not when we're in a fullscreen space on Mac OS X.
authorSam Lantinga <slouken@libsdl.org>
Tue, 12 Nov 2013 02:02:12 -0800
changeset 7969 72405c8b7dba
parent 7968 8c0afe77a1b2
child 7970 6dc794be47aa
We still want to generally minimize on focus loss, but not when we're in a fullscreen space on Mac OS X.
src/video/SDL_video.c
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/SDL_video.c	Tue Nov 12 01:52:54 2013 -0800
+++ b/src/video/SDL_video.c	Tue Nov 12 02:02:12 2013 -0800
@@ -115,6 +115,7 @@
 
 #ifdef __MACOSX__
 /* Support for Mac OS X fullscreen spaces */
+extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
 extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
 #endif
 
@@ -2152,19 +2153,17 @@
 static SDL_bool
 ShouldMinimizeOnFocusLoss(SDL_Window * window)
 {
-    SDL_bool default_minimize;
     const char *hint;
 
     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
         return SDL_FALSE;
     }
 
-    if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
-        /* We're not doing a mode switch, so it's okay to stay around */
-        default_minimize = SDL_FALSE;
-    } else {
-        default_minimize = SDL_TRUE;
+#ifdef __MACOSX__
+    if (Cocoa_IsWindowInFullscreenSpace(window)) {
+        return SDL_FALSE;
     }
+#endif
 
     hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
     if (hint) {
@@ -2175,7 +2174,7 @@
         }
     }
 
-    return default_minimize;
+    return SDL_TRUE;
 }
 
 void
--- a/src/video/cocoa/SDL_cocoawindow.m	Tue Nov 12 01:52:54 2013 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Tue Nov 12 02:02:12 2013 -0800
@@ -1383,6 +1383,18 @@
 }
 
 SDL_bool
+Cocoa_IsWindowInFullscreenSpace(SDL_Window * window)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+
+    if ([data->listener isInFullscreenSpace]) {
+        return SDL_TRUE;
+    } else {
+        return SDL_FALSE;
+    }
+}
+
+SDL_bool
 Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
 {
     SDL_bool succeeded = SDL_FALSE;