Skip to content

Commit

Permalink
add hacky support for failed fullscreen transitions. SDL doesn't have…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
slouken committed Nov 9, 2015
1 parent 7ce6437 commit 2d88465
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -282,6 +282,8 @@ - (void)listen:(SDL_WindowData *)data
[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(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 {
[window setDelegate:self];
}
Expand Down Expand Up @@ -413,6 +415,8 @@ - (void)close
[center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
[center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
[center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
[center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
[center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
} else {
[window setDelegate:nil];
}
Expand Down Expand Up @@ -634,6 +638,19 @@ - (void)windowWillEnterFullScreen:(NSNotification *)aNotification
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
{
SDL_Window *window = _data->window;
Expand Down Expand Up @@ -668,6 +685,19 @@ - (void)windowWillExitFullScreen:(NSNotification *)aNotification
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
{
SDL_Window *window = _data->window;
Expand Down

0 comments on commit 2d88465

Please sign in to comment.