A bunch of fixes for the new Spaces code.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 02 Mar 2014 16:36:40 -0500
changeset 829136f8cf82d308
parent 8290 b64c52d62264
child 8292 2b0736ab4d5f
A bunch of fixes for the new Spaces code.
src/video/cocoa/SDL_cocoawindow.h
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.h	Sun Mar 02 13:06:51 2014 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.h	Sun Mar 02 16:36:40 2014 -0500
     1.3 @@ -73,6 +73,7 @@
     1.4  -(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
     1.5  -(void) windowWillExitFullScreen:(NSNotification *) aNotification;
     1.6  -(void) windowDidExitFullScreen:(NSNotification *) aNotification;
     1.7 +-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
     1.8  
     1.9  /* Window event handling */
    1.10  -(void) mouseDown:(NSEvent *) theEvent;
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sun Mar 02 13:06:51 2014 -0800
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Mar 02 16:36:40 2014 -0500
     2.3 @@ -265,7 +265,7 @@
     2.4  
     2.5      if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
     2.6          return NO;  /* we only allow this on FULLSCREEN_DESKTOP windows. */
     2.7 -    } else if (![nswindow respondsToSelector: @selector(setCollectionBehavior:)]) {
     2.8 +    } else if (![nswindow respondsToSelector: @selector(toggleFullScreen:)]) {
     2.9          return NO;  /* No Spaces support? Older Mac OS X? */
    2.10      } else if (state == isFullscreenSpace) {
    2.11          return YES;  /* already there. */
    2.12 @@ -558,8 +558,6 @@
    2.13          [self setFullscreenSpace:NO];
    2.14      } else {
    2.15          if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    2.16 -            /* Remove the fullscreen toggle button and menu now that we're here. */
    2.17 -            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    2.18              [NSMenu setMenuBarVisible:NO];
    2.19          }
    2.20  
    2.21 @@ -597,11 +595,14 @@
    2.22          pendingWindowOperation = PENDING_OPERATION_NONE;
    2.23          [nswindow miniaturize:nil];
    2.24      } else {
    2.25 -        if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    2.26 -            /* Remove the fullscreen toggle button and readd menu now that we're here. */
    2.27 +        /* Adjust the fullscreen toggle button and readd menu now that we're here. */
    2.28 +        if (window->flags & SDL_WINDOW_RESIZABLE) {
    2.29 +            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    2.30 +            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    2.31 +        } else {
    2.32              [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    2.33 -            [NSMenu setMenuBarVisible:YES];
    2.34          }
    2.35 +        [NSMenu setMenuBarVisible:YES];
    2.36  
    2.37          pendingWindowOperation = PENDING_OPERATION_NONE;
    2.38          /* Force the size change event in case it was delivered earlier
    2.39 @@ -613,6 +614,16 @@
    2.40      }
    2.41  }
    2.42  
    2.43 +-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
    2.44 +{
    2.45 +    if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    2.46 +        return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar;
    2.47 +    } else {
    2.48 +        return proposedOptions;
    2.49 +    }
    2.50 +}
    2.51 +
    2.52 +
    2.53  /* We'll respond to key events by doing nothing so we don't beep.
    2.54   * We could handle key messages here, but we lose some in the NSApp dispatch,
    2.55   * where they get converted to action messages, etc.
    2.56 @@ -1021,7 +1032,7 @@
    2.57      }
    2.58      [nswindow setBackgroundColor:[NSColor blackColor]];
    2.59  
    2.60 -    if ([nswindow respondsToSelector: @selector(setCollectionBehavior:)]) {
    2.61 +    if ([nswindow respondsToSelector: @selector(toggleFullScreen:)]) {
    2.62          /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
    2.63          if (window->flags & SDL_WINDOW_RESIZABLE) {
    2.64              /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */