add hacky support for failed fullscreen transitions. SDL doesn't have the concept of a fullscreen transition that failed. if the user is actively changing spaces while the app goes fullscreen, it fails to go fullscreen; now it will just try again instead of hanging around with the wrong window styles.

This commit is contained in:
Sam Lantinga 2015-11-09 08:54:42 -08:00
parent 7ce64372c8
commit 2d884656c4

View File

@ -282,6 +282,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
[center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window]; [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
[center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window]; [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
[center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window]; [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
[center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
[center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
} else { } else {
[window setDelegate:self]; [window setDelegate:self];
} }
@ -413,6 +415,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
[center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window]; [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
[center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window]; [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
[center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window]; [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
[center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
[center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
} else { } else {
[window setDelegate:nil]; [window setDelegate:nil];
} }
@ -634,6 +638,19 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
inFullscreenTransition = YES; inFullscreenTransition = YES;
} }
- (void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;
SetWindowStyle(window, GetWindowStyle(window));
isFullscreenSpace = NO;
inFullscreenTransition = NO;
/* Try again? Not sure what else to do, the application wants to be fullscreen. */
[self setFullscreenSpace:YES];
}
- (void)windowDidEnterFullScreen:(NSNotification *)aNotification - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
{ {
SDL_Window *window = _data->window; SDL_Window *window = _data->window;
@ -668,6 +685,19 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
inFullscreenTransition = YES; inFullscreenTransition = YES;
} }
- (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;
SetWindowStyle(window, (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask));
isFullscreenSpace = YES;
inFullscreenTransition = NO;
/* Try again? Not sure what else to do, the application wants to be non-fullscreen. */
[self setFullscreenSpace:NO];
}
- (void)windowDidExitFullScreen:(NSNotification *)aNotification - (void)windowDidExitFullScreen:(NSNotification *)aNotification
{ {
SDL_Window *window = _data->window; SDL_Window *window = _data->window;