src/video/cocoa/SDL_cocoawindow.m
changeset 8291 36f8cf82d308
parent 8288 4e3afa79b8d8
child 8292 2b0736ab4d5f
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sun Mar 02 13:06:51 2014 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Mar 02 16:36:40 2014 -0500
     1.3 @@ -265,7 +265,7 @@
     1.4  
     1.5      if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
     1.6          return NO;  /* we only allow this on FULLSCREEN_DESKTOP windows. */
     1.7 -    } else if (![nswindow respondsToSelector: @selector(setCollectionBehavior:)]) {
     1.8 +    } else if (![nswindow respondsToSelector: @selector(toggleFullScreen:)]) {
     1.9          return NO;  /* No Spaces support? Older Mac OS X? */
    1.10      } else if (state == isFullscreenSpace) {
    1.11          return YES;  /* already there. */
    1.12 @@ -558,8 +558,6 @@
    1.13          [self setFullscreenSpace:NO];
    1.14      } else {
    1.15          if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    1.16 -            /* Remove the fullscreen toggle button and menu now that we're here. */
    1.17 -            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    1.18              [NSMenu setMenuBarVisible:NO];
    1.19          }
    1.20  
    1.21 @@ -597,11 +595,14 @@
    1.22          pendingWindowOperation = PENDING_OPERATION_NONE;
    1.23          [nswindow miniaturize:nil];
    1.24      } else {
    1.25 -        if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    1.26 -            /* Remove the fullscreen toggle button and readd menu now that we're here. */
    1.27 +        /* Adjust the fullscreen toggle button and readd menu now that we're here. */
    1.28 +        if (window->flags & SDL_WINDOW_RESIZABLE) {
    1.29 +            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    1.30 +            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    1.31 +        } else {
    1.32              [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    1.33 -            [NSMenu setMenuBarVisible:YES];
    1.34          }
    1.35 +        [NSMenu setMenuBarVisible:YES];
    1.36  
    1.37          pendingWindowOperation = PENDING_OPERATION_NONE;
    1.38          /* Force the size change event in case it was delivered earlier
    1.39 @@ -613,6 +614,16 @@
    1.40      }
    1.41  }
    1.42  
    1.43 +-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
    1.44 +{
    1.45 +    if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    1.46 +        return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar;
    1.47 +    } else {
    1.48 +        return proposedOptions;
    1.49 +    }
    1.50 +}
    1.51 +
    1.52 +
    1.53  /* We'll respond to key events by doing nothing so we don't beep.
    1.54   * We could handle key messages here, but we lose some in the NSApp dispatch,
    1.55   * where they get converted to action messages, etc.
    1.56 @@ -1021,7 +1032,7 @@
    1.57      }
    1.58      [nswindow setBackgroundColor:[NSColor blackColor]];
    1.59  
    1.60 -    if ([nswindow respondsToSelector: @selector(setCollectionBehavior:)]) {
    1.61 +    if ([nswindow respondsToSelector: @selector(toggleFullScreen:)]) {
    1.62          /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
    1.63          if (window->flags & SDL_WINDOW_RESIZABLE) {
    1.64              /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */