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.
authorSam Lantinga <slouken@libsdl.org>
Mon, 09 Nov 2015 08:54:42 -0800
changeset 99032bbb11de1e60
parent 9902 a0d15db7bd09
child 9904 e9b49510e51b
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.
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon Nov 09 02:32:37 2015 -0400
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Nov 09 08:54:42 2015 -0800
     1.3 @@ -282,6 +282,8 @@
     1.4          [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
     1.5          [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
     1.6          [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
     1.7 +        [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
     1.8 +        [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
     1.9      } else {
    1.10          [window setDelegate:self];
    1.11      }
    1.12 @@ -413,6 +415,8 @@
    1.13          [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
    1.14          [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
    1.15          [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
    1.16 +        [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    1.17 +        [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    1.18      } else {
    1.19          [window setDelegate:nil];
    1.20      }
    1.21 @@ -634,6 +638,19 @@
    1.22      inFullscreenTransition = YES;
    1.23  }
    1.24  
    1.25 +- (void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
    1.26 +{
    1.27 +    SDL_Window *window = _data->window;
    1.28 +    
    1.29 +    SetWindowStyle(window, GetWindowStyle(window));
    1.30 +
    1.31 +    isFullscreenSpace = NO;
    1.32 +    inFullscreenTransition = NO;
    1.33 +
    1.34 +    /* Try again? Not sure what else to do, the application wants to be fullscreen. */
    1.35 +    [self setFullscreenSpace:YES];
    1.36 +}
    1.37 +
    1.38  - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
    1.39  {
    1.40      SDL_Window *window = _data->window;
    1.41 @@ -668,6 +685,19 @@
    1.42      inFullscreenTransition = YES;
    1.43  }
    1.44  
    1.45 +- (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
    1.46 +{
    1.47 +    SDL_Window *window = _data->window;
    1.48 +    
    1.49 +    SetWindowStyle(window, (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask));
    1.50 +    
    1.51 +    isFullscreenSpace = YES;
    1.52 +    inFullscreenTransition = NO;
    1.53 +
    1.54 +    /* Try again? Not sure what else to do, the application wants to be non-fullscreen. */
    1.55 +    [self setFullscreenSpace:NO];
    1.56 +}
    1.57 +
    1.58  - (void)windowDidExitFullScreen:(NSNotification *)aNotification
    1.59  {
    1.60      SDL_Window *window = _data->window;