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 796775f04553360a
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
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.h	Mon Nov 11 23:42:43 2013 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.h	Tue Nov 12 00:32:29 2013 -0800
     1.3 @@ -40,7 +40,7 @@
     1.4      BOOL observingVisible;
     1.5      BOOL wasCtrlLeft;
     1.6      BOOL wasVisible;
     1.7 -    BOOL isFullscreen;
     1.8 +    BOOL isFullscreenSpace;
     1.9      BOOL inFullscreenTransition;
    1.10      PendingWindowOperation pendingWindowOperation;
    1.11  }
    1.12 @@ -48,7 +48,7 @@
    1.13  -(void) listen:(SDL_WindowData *) data;
    1.14  -(void) pauseVisibleObservation;
    1.15  -(void) resumeVisibleObservation;
    1.16 --(BOOL) setFullscreenState:(BOOL) state;
    1.17 +-(BOOL) setFullscreenSpace:(BOOL) state;
    1.18  -(BOOL) isInFullscreenTransition;
    1.19  -(void) addPendingWindowOperation:(PendingWindowOperation) operation;
    1.20  -(void) close;
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon Nov 11 23:42:43 2013 -0800
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Tue Nov 12 00:32:29 2013 -0800
     2.3 @@ -101,7 +101,7 @@
     2.4      observingVisible = YES;
     2.5      wasCtrlLeft = NO;
     2.6      wasVisible = [window isVisible];
     2.7 -    isFullscreen = NO;
     2.8 +    isFullscreenSpace = NO;
     2.9      inFullscreenTransition = NO;
    2.10      pendingWindowOperation = PENDING_OPERATION_NONE;
    2.11  
    2.12 @@ -184,34 +184,38 @@
    2.13      }
    2.14  }
    2.15  
    2.16 --(BOOL) setFullscreenState:(BOOL) state;
    2.17 +-(BOOL) setFullscreenSpace:(BOOL) state;
    2.18  {
    2.19 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
    2.20      SDL_Window *window = _data->window;
    2.21      NSWindow *nswindow = _data->nswindow;
    2.22 -    BOOL canSetState = NO;
    2.23 +    BOOL canSetSpace = NO;
    2.24  
    2.25 -    /* Make sure we can support this fullscreen style */
    2.26 -    if (![nswindow respondsToSelector: @selector(toggleFullScreen:)]) {
    2.27 +    /* Make sure the window supports switching to fullscreen spaces */
    2.28 +    if (![nswindow respondsToSelector: @selector(collectionBehavior)]) {
    2.29 +        return NO;
    2.30 +    }
    2.31 +    if ([nswindow collectionBehavior] != NSWindowCollectionBehaviorFullScreenPrimary) {
    2.32          return NO;
    2.33      }
    2.34  
    2.35      pendingWindowOperation = PENDING_OPERATION_NONE;
    2.36  
    2.37 -    /* We can enter new style fullscreen mode for "fullscreen desktop" */
    2.38 +    /* We can enter fullscreen spaces for "fullscreen desktop" */
    2.39      if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    2.40 -        canSetState = YES;
    2.41 +        canSetSpace = YES;
    2.42      }
    2.43  
    2.44 -    /* We can always leave new style fullscreen mode */
    2.45 -    if (!state && isFullscreen) {
    2.46 -        canSetState = YES;
    2.47 +    /* We can always leave fullscreen spaces */
    2.48 +    if (!state && isFullscreenSpace) {
    2.49 +        canSetSpace = YES;
    2.50      }
    2.51  
    2.52 -    if (!canSetState) {
    2.53 +    if (!canSetSpace) {
    2.54          return NO;
    2.55      }
    2.56  
    2.57 -    if (state == isFullscreen) {
    2.58 +    if (state == isFullscreenSpace) {
    2.59          return YES;
    2.60      }
    2.61  
    2.62 @@ -226,6 +230,9 @@
    2.63  
    2.64      [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
    2.65      return YES;
    2.66 +#else
    2.67 +    return NO
    2.68 +#endif /* SDK >= 10.7 */
    2.69  }
    2.70  
    2.71  -(BOOL) isInFullscreenTransition
    2.72 @@ -430,19 +437,20 @@
    2.73          }
    2.74      }
    2.75  
    2.76 -    isFullscreen = YES;
    2.77 +    isFullscreenSpace = YES;
    2.78      inFullscreenTransition = YES;
    2.79  }
    2.80  
    2.81  - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
    2.82  {
    2.83      SDL_Window *window = _data->window;
    2.84 +    NSWindow *nswindow = _data->nswindow;
    2.85  
    2.86      inFullscreenTransition = NO;
    2.87  
    2.88      if (pendingWindowOperation == PENDING_OPERATION_LEAVE_FULLSCREEN) {
    2.89          pendingWindowOperation = PENDING_OPERATION_NONE;
    2.90 -        [self setFullscreenState:NO];
    2.91 +        [self setFullscreenSpace:NO];
    2.92      } else {
    2.93          pendingWindowOperation = PENDING_OPERATION_NONE;
    2.94          /* Force the size change event in case it was delivered earlier
    2.95 @@ -466,7 +474,7 @@
    2.96          window->flags = flags;
    2.97      }
    2.98  
    2.99 -    isFullscreen = NO;
   2.100 +    isFullscreenSpace = NO;
   2.101      inFullscreenTransition = YES;
   2.102  }
   2.103  
   2.104 @@ -479,7 +487,7 @@
   2.105  
   2.106      if (pendingWindowOperation == PENDING_OPERATION_ENTER_FULLSCREEN) {
   2.107          pendingWindowOperation = PENDING_OPERATION_NONE;
   2.108 -        [self setFullscreenState:YES];
   2.109 +        [self setFullscreenSpace:YES];
   2.110      } else if (pendingWindowOperation == PENDING_OPERATION_MINIMIZE) {
   2.111          pendingWindowOperation = PENDING_OPERATION_NONE;
   2.112          [nswindow miniaturize:nil];
   2.113 @@ -1272,7 +1280,7 @@
   2.114      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   2.115      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   2.116  
   2.117 -    if (![data->listener setFullscreenState:(fullscreen ? YES : NO)]) {
   2.118 +    if (![data->listener setFullscreenSpace:(fullscreen ? YES : NO)]) {
   2.119          Cocoa_SetWindowFullscreen_OldStyle(_this, window, display, fullscreen);
   2.120      }
   2.121