Fullscreen space naming cleanup to avoid confusion with normal fullscreen mode
authorSam Lantinga <slouken@libsdl.org>
Tue, 12 Nov 2013 00:32:29 -0800
changeset 7967 75f04553360a
parent 7966 ef27c2dbeb8f
child 7968 8c0afe77a1b2
Fullscreen space naming cleanup to avoid confusion with normal fullscreen mode
src/video/cocoa/SDL_cocoawindow.h
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.h	Mon Nov 11 23:42:43 2013 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.h	Tue Nov 12 00:32:29 2013 -0800
@@ -40,7 +40,7 @@
     BOOL observingVisible;
     BOOL wasCtrlLeft;
     BOOL wasVisible;
-    BOOL isFullscreen;
+    BOOL isFullscreenSpace;
     BOOL inFullscreenTransition;
     PendingWindowOperation pendingWindowOperation;
 }
@@ -48,7 +48,7 @@
 -(void) listen:(SDL_WindowData *) data;
 -(void) pauseVisibleObservation;
 -(void) resumeVisibleObservation;
--(BOOL) setFullscreenState:(BOOL) state;
+-(BOOL) setFullscreenSpace:(BOOL) state;
 -(BOOL) isInFullscreenTransition;
 -(void) addPendingWindowOperation:(PendingWindowOperation) operation;
 -(void) close;
--- a/src/video/cocoa/SDL_cocoawindow.m	Mon Nov 11 23:42:43 2013 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Tue Nov 12 00:32:29 2013 -0800
@@ -101,7 +101,7 @@
     observingVisible = YES;
     wasCtrlLeft = NO;
     wasVisible = [window isVisible];
-    isFullscreen = NO;
+    isFullscreenSpace = NO;
     inFullscreenTransition = NO;
     pendingWindowOperation = PENDING_OPERATION_NONE;
 
@@ -184,34 +184,38 @@
     }
 }
 
--(BOOL) setFullscreenState:(BOOL) state;
+-(BOOL) setFullscreenSpace:(BOOL) state;
 {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
     SDL_Window *window = _data->window;
     NSWindow *nswindow = _data->nswindow;
-    BOOL canSetState = NO;
+    BOOL canSetSpace = NO;
 
-    /* Make sure we can support this fullscreen style */
-    if (![nswindow respondsToSelector: @selector(toggleFullScreen:)]) {
+    /* Make sure the window supports switching to fullscreen spaces */
+    if (![nswindow respondsToSelector: @selector(collectionBehavior)]) {
+        return NO;
+    }
+    if ([nswindow collectionBehavior] != NSWindowCollectionBehaviorFullScreenPrimary) {
         return NO;
     }
 
     pendingWindowOperation = PENDING_OPERATION_NONE;
 
-    /* We can enter new style fullscreen mode for "fullscreen desktop" */
+    /* We can enter fullscreen spaces for "fullscreen desktop" */
     if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
-        canSetState = YES;
+        canSetSpace = YES;
     }
 
-    /* We can always leave new style fullscreen mode */
-    if (!state && isFullscreen) {
-        canSetState = YES;
+    /* We can always leave fullscreen spaces */
+    if (!state && isFullscreenSpace) {
+        canSetSpace = YES;
     }
 
-    if (!canSetState) {
+    if (!canSetSpace) {
         return NO;
     }
 
-    if (state == isFullscreen) {
+    if (state == isFullscreenSpace) {
         return YES;
     }
 
@@ -226,6 +230,9 @@
 
     [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
     return YES;
+#else
+    return NO
+#endif /* SDK >= 10.7 */
 }
 
 -(BOOL) isInFullscreenTransition
@@ -430,19 +437,20 @@
         }
     }
 
-    isFullscreen = YES;
+    isFullscreenSpace = YES;
     inFullscreenTransition = YES;
 }
 
 - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
 {
     SDL_Window *window = _data->window;
+    NSWindow *nswindow = _data->nswindow;
 
     inFullscreenTransition = NO;
 
     if (pendingWindowOperation == PENDING_OPERATION_LEAVE_FULLSCREEN) {
         pendingWindowOperation = PENDING_OPERATION_NONE;
-        [self setFullscreenState:NO];
+        [self setFullscreenSpace:NO];
     } else {
         pendingWindowOperation = PENDING_OPERATION_NONE;
         /* Force the size change event in case it was delivered earlier
@@ -466,7 +474,7 @@
         window->flags = flags;
     }
 
-    isFullscreen = NO;
+    isFullscreenSpace = NO;
     inFullscreenTransition = YES;
 }
 
@@ -479,7 +487,7 @@
 
     if (pendingWindowOperation == PENDING_OPERATION_ENTER_FULLSCREEN) {
         pendingWindowOperation = PENDING_OPERATION_NONE;
-        [self setFullscreenState:YES];
+        [self setFullscreenSpace:YES];
     } else if (pendingWindowOperation == PENDING_OPERATION_MINIMIZE) {
         pendingWindowOperation = PENDING_OPERATION_NONE;
         [nswindow miniaturize:nil];
@@ -1272,7 +1280,7 @@
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
 
-    if (![data->listener setFullscreenState:(fullscreen ? YES : NO)]) {
+    if (![data->listener setFullscreenSpace:(fullscreen ? YES : NO)]) {
         Cocoa_SetWindowFullscreen_OldStyle(_this, window, display, fullscreen);
     }