From 460f97ff96838b34a329d40be4ba09fa950ad16d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 2 Mar 2014 16:36:40 -0500 Subject: [PATCH] A bunch of fixes for the new Spaces code. --- src/video/cocoa/SDL_cocoawindow.h | 1 + src/video/cocoa/SDL_cocoawindow.m | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 4f88ce1f79f3d..a4ec07d72fb3c 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -73,6 +73,7 @@ typedef enum -(void) windowDidEnterFullScreen:(NSNotification *) aNotification; -(void) windowWillExitFullScreen:(NSNotification *) aNotification; -(void) windowDidExitFullScreen:(NSNotification *) aNotification; +-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; /* Window event handling */ -(void) mouseDown:(NSEvent *) theEvent; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 5f28c19f115ea..c7d4f851ee907 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -265,7 +265,7 @@ -(BOOL) setFullscreenSpace:(BOOL) state if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) { return NO; /* we only allow this on FULLSCREEN_DESKTOP windows. */ - } else if (![nswindow respondsToSelector: @selector(setCollectionBehavior:)]) { + } else if (![nswindow respondsToSelector: @selector(toggleFullScreen:)]) { return NO; /* No Spaces support? Older Mac OS X? */ } else if (state == isFullscreenSpace) { return YES; /* already there. */ @@ -558,8 +558,6 @@ - (void)windowDidEnterFullScreen:(NSNotification *)aNotification [self setFullscreenSpace:NO]; } else { if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { - /* Remove the fullscreen toggle button and menu now that we're here. */ - [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; [NSMenu setMenuBarVisible:NO]; } @@ -597,11 +595,14 @@ - (void)windowDidExitFullScreen:(NSNotification *)aNotification pendingWindowOperation = PENDING_OPERATION_NONE; [nswindow miniaturize:nil]; } else { - if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { - /* Remove the fullscreen toggle button and readd menu now that we're here. */ + /* Adjust the fullscreen toggle button and readd menu now that we're here. */ + if (window->flags & SDL_WINDOW_RESIZABLE) { + /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } else { [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; - [NSMenu setMenuBarVisible:YES]; } + [NSMenu setMenuBarVisible:YES]; pendingWindowOperation = PENDING_OPERATION_NONE; /* Force the size change event in case it was delivered earlier @@ -613,6 +614,16 @@ - (void)windowDidExitFullScreen:(NSNotification *)aNotification } } +-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions +{ + if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { + return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; + } else { + return proposedOptions; + } +} + + /* We'll respond to key events by doing nothing so we don't beep. * We could handle key messages here, but we lose some in the NSApp dispatch, * where they get converted to action messages, etc. @@ -1021,7 +1032,7 @@ - (void)resetCursorRects } [nswindow setBackgroundColor:[NSColor blackColor]]; - if ([nswindow respondsToSelector: @selector(setCollectionBehavior:)]) { + if ([nswindow respondsToSelector: @selector(toggleFullScreen:)]) { /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */ if (window->flags & SDL_WINDOW_RESIZABLE) { /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */