more SDL fullscreen state tracking fixes, don't update fullscreen flags on failure to change fullscreen state
authorSam Lantinga <slouken@libsdl.org>
Mon, 09 Nov 2015 08:54:56 -0800
changeset 9905 fcf85090f816
parent 9904 e9b49510e51b
child 9906 49c432b1897b
more SDL fullscreen state tracking fixes, don't update fullscreen flags on failure to change fullscreen state
src/video/SDL_video.c
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/SDL_video.c	Mon Nov 09 08:54:49 2015 -0800
+++ b/src/video/SDL_video.c	Mon Nov 09 08:54:56 2015 -0800
@@ -1980,6 +1980,7 @@
 int
 SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
 {
+    Uint32 oldflags;
     CHECK_WINDOW_MAGIC(window, -1);
 
     flags &= FULLSCREEN_MASK;
@@ -1989,10 +1990,17 @@
     }
 
     /* clear the previous flags and OR in the new ones */
+    oldflags = window->flags & FULLSCREEN_MASK;
     window->flags &= ~FULLSCREEN_MASK;
     window->flags |= flags;
 
-    return SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window));
+    if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
+        return 0;
+    }
+    
+    window->flags &= ~FULLSCREEN_MASK;
+    window->flags |= oldflags;
+    return -1;
 }
 
 static SDL_Surface *
--- a/src/video/cocoa/SDL_cocoawindow.m	Mon Nov 09 08:54:49 2015 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Nov 09 08:54:56 2015 -0800
@@ -646,6 +646,8 @@
 
     isFullscreenSpace = NO;
     inFullscreenTransition = NO;
+    
+    [self windowDidExitFullScreen:nil];
 }
 
 - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
@@ -690,6 +692,8 @@
     
     isFullscreenSpace = YES;
     inFullscreenTransition = NO;
+    
+    [self windowDidEnterFullScreen:nil];
 }
 
 - (void)windowDidExitFullScreen:(NSNotification *)aNotification