A bunch of fixes for the new Spaces code.

This commit is contained in:
Ryan C. Gordon 2014-03-02 16:36:40 -05:00
parent da324233e2
commit 460f97ff96
2 changed files with 19 additions and 7 deletions

View File

@ -73,6 +73,7 @@ typedef enum
-(void) windowDidEnterFullScreen:(NSNotification *) aNotification; -(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
-(void) windowWillExitFullScreen:(NSNotification *) aNotification; -(void) windowWillExitFullScreen:(NSNotification *) aNotification;
-(void) windowDidExitFullScreen:(NSNotification *) aNotification; -(void) windowDidExitFullScreen:(NSNotification *) aNotification;
-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
/* Window event handling */ /* Window event handling */
-(void) mouseDown:(NSEvent *) theEvent; -(void) mouseDown:(NSEvent *) theEvent;

View File

@ -265,7 +265,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) { if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
return NO; /* we only allow this on FULLSCREEN_DESKTOP windows. */ 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? */ return NO; /* No Spaces support? Older Mac OS X? */
} else if (state == isFullscreenSpace) { } else if (state == isFullscreenSpace) {
return YES; /* already there. */ return YES; /* already there. */
@ -558,8 +558,6 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
[self setFullscreenSpace:NO]; [self setFullscreenSpace:NO];
} else { } else {
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { 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]; [NSMenu setMenuBarVisible:NO];
} }
@ -597,11 +595,14 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
pendingWindowOperation = PENDING_OPERATION_NONE; pendingWindowOperation = PENDING_OPERATION_NONE;
[nswindow miniaturize:nil]; [nswindow miniaturize:nil];
} else { } else {
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { /* Adjust the fullscreen toggle button and readd menu now that we're here. */
/* Remove 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]; [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
[NSMenu setMenuBarVisible:YES];
} }
[NSMenu setMenuBarVisible:YES];
pendingWindowOperation = PENDING_OPERATION_NONE; pendingWindowOperation = PENDING_OPERATION_NONE;
/* Force the size change event in case it was delivered earlier /* Force the size change event in case it was delivered earlier
@ -613,6 +614,16 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
} }
} }
-(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'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, * We could handle key messages here, but we lose some in the NSApp dispatch,
* where they get converted to action messages, etc. * where they get converted to action messages, etc.
@ -1021,7 +1032,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
} }
[nswindow setBackgroundColor:[NSColor blackColor]]; [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 */ /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
if (window->flags & SDL_WINDOW_RESIZABLE) { if (window->flags & SDL_WINDOW_RESIZABLE) {
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */