Fixed assertion when quickly toggling from fullscreen back to fullscreen: "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'backgroundWindows not nil in enterFullScreenTransitionWithOptions:animated:activatingIt:'" To reproduce this, run testsprite2, press Alt-Enter once, again while it's animating to fullscreen, and then again while it's animating out of fullscreen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index be6f6cf..1cd9b63 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -184,10 +184,6 @@ GetWindowStyle(SDL_Window * window)
}
}
--(BOOL) canSetFullscreenState:(BOOL) state;
-{
-}
-
-(BOOL) setFullscreenState:(BOOL) state;
{
SDL_Window *window = _data->window;
@@ -228,7 +224,7 @@ GetWindowStyle(SDL_Window * window)
return YES;
}
- [nswindow performSelector: @selector(toggleFullScreen:) withObject:nswindow];
+ [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
return YES;
}
@@ -433,12 +429,15 @@ GetWindowStyle(SDL_Window * window)
[nswindow setStyleMask:NSBorderlessWindowMask];
}
}
+
isFullscreen = YES;
inFullscreenTransition = YES;
}
- (void)windowDidEnterFullScreen:(NSNotification *)aNotification
{
+ SDL_Window *window = _data->window;
+
inFullscreenTransition = NO;
if (pendingWindowOperation == PENDING_OPERATION_LEAVE_FULLSCREEN) {
@@ -446,6 +445,11 @@ GetWindowStyle(SDL_Window * window)
[self setFullscreenState:NO];
} else {
pendingWindowOperation = PENDING_OPERATION_NONE;
+ /* Force the size change event in case it was delivered earlier
+ while the window was still animating into place.
+ */
+ window->w = 0;
+ window->h = 0;
[self windowDidResize:aNotification];
}
}
@@ -465,6 +469,7 @@ GetWindowStyle(SDL_Window * window)
- (void)windowDidExitFullScreen:(NSNotification *)aNotification
{
+ SDL_Window *window = _data->window;
NSWindow *nswindow = _data->nswindow;
inFullscreenTransition = NO;
@@ -477,6 +482,11 @@ GetWindowStyle(SDL_Window * window)
[nswindow miniaturize:nil];
} else {
pendingWindowOperation = PENDING_OPERATION_NONE;
+ /* Force the size change event in case it was delivered earlier
+ while the window was still animating into place.
+ */
+ window->w = 0;
+ window->h = 0;
[self windowDidResize:aNotification];
}
}