cocoa: Clear pending state on fullscreen switch failures
The window failing to enter/exit fullscreen notifications don't necessarily imply anything about the actual state of the window. On failure, dump pending events, and don't presume anything about the current window state, as it will be handled by subsequent enter/leave notifications.
This commit is contained in:
@@ -905,6 +905,11 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
|
|||||||
pendingWindowOperation &= ~operation;
|
pendingWindowOperation &= ~operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)clearAllPendingWindowOperations
|
||||||
|
{
|
||||||
|
pendingWindowOperation = PENDING_OPERATION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)addPendingWindowOperation:(PendingWindowOperation)operation
|
- (void)addPendingWindowOperation:(PendingWindowOperation)operation
|
||||||
{
|
{
|
||||||
pendingWindowOperation |= operation;
|
pendingWindowOperation |= operation;
|
||||||
@@ -1352,21 +1357,14 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
|
|||||||
inFullscreenTransition = YES;
|
inFullscreenTransition = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is usually sent after an unexpected windowDidExitFullscreen if the window
|
||||||
|
* failed to become fullscreen.
|
||||||
|
*
|
||||||
|
* Since something went wrong and the current state is unknown, dump any pending events.
|
||||||
|
*/
|
||||||
- (void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
|
- (void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
SDL_Window *window = _data.window;
|
[self clearAllPendingWindowOperations];
|
||||||
|
|
||||||
if (window->is_destroying) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetWindowStyle(window, GetWindowStyle(window));
|
|
||||||
|
|
||||||
[self clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
|
|
||||||
isFullscreenSpace = NO;
|
|
||||||
inFullscreenTransition = NO;
|
|
||||||
|
|
||||||
[self windowDidExitFullScreen:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidEnterFullScreen:(NSNotification *)aNotification
|
- (void)windowDidEnterFullScreen:(NSNotification *)aNotification
|
||||||
@@ -1374,6 +1372,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
|
|||||||
SDL_Window *window = _data.window;
|
SDL_Window *window = _data.window;
|
||||||
|
|
||||||
inFullscreenTransition = NO;
|
inFullscreenTransition = NO;
|
||||||
|
isFullscreenSpace = YES;
|
||||||
[self clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
|
[self clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
|
||||||
|
|
||||||
if ([self windowOperationIsPending:PENDING_OPERATION_LEAVE_FULLSCREEN]) {
|
if ([self windowOperationIsPending:PENDING_OPERATION_LEAVE_FULLSCREEN]) {
|
||||||
@@ -1424,26 +1423,14 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
|
|||||||
inFullscreenTransition = YES;
|
inFullscreenTransition = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This may be sent before windowDidExitFullscreen to signal that the window was
|
||||||
|
* dumped out of fullscreen with no animation.
|
||||||
|
*
|
||||||
|
* Since something went wrong and the state is unknown, dump any pending events.
|
||||||
|
*/
|
||||||
- (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
|
- (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
SDL_Window *window = _data.window;
|
[self clearAllPendingWindowOperations];
|
||||||
const NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
|
|
||||||
|
|
||||||
if (window->is_destroying) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_data.pending_position = NO;
|
|
||||||
_data.pending_size = NO;
|
|
||||||
window->last_position_pending = false;
|
|
||||||
window->last_size_pending = false;
|
|
||||||
|
|
||||||
SetWindowStyle(window, flags);
|
|
||||||
|
|
||||||
isFullscreenSpace = YES;
|
|
||||||
inFullscreenTransition = NO;
|
|
||||||
|
|
||||||
[self windowDidEnterFullScreen:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidExitFullScreen:(NSNotification *)aNotification
|
- (void)windowDidExitFullScreen:(NSNotification *)aNotification
|
||||||
@@ -1452,16 +1439,24 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
|
|||||||
NSWindow *nswindow = _data.nswindow;
|
NSWindow *nswindow = _data.nswindow;
|
||||||
|
|
||||||
inFullscreenTransition = NO;
|
inFullscreenTransition = NO;
|
||||||
|
isFullscreenSpace = NO;
|
||||||
_data.fullscreen_space_requested = NO;
|
_data.fullscreen_space_requested = NO;
|
||||||
|
|
||||||
/* As of macOS 10.15, the window decorations can go missing sometimes after
|
/* As of macOS 10.15, the window decorations can go missing sometimes after
|
||||||
certain fullscreen-desktop->exlusive-fullscreen->windowed mode flows
|
certain fullscreen-desktop->exclusive-fullscreen->windowed mode flows
|
||||||
sometimes. Making sure the style mask always uses the windowed mode style
|
sometimes. Making sure the style mask always uses the windowed mode style
|
||||||
when returning to windowed mode from a space (instead of using a pending
|
when returning to windowed mode from a space (instead of using a pending
|
||||||
fullscreen mode style mask) seems to work around that issue.
|
fullscreen mode style mask) seems to work around that issue.
|
||||||
*/
|
*/
|
||||||
SetWindowStyle(window, GetWindowWindowedStyle(window));
|
SetWindowStyle(window, GetWindowWindowedStyle(window));
|
||||||
|
|
||||||
|
/* This can happen if the window failed to enter fullscreen, as this
|
||||||
|
* may be called *before* windowDidFailToEnterFullScreen in that case.
|
||||||
|
*/
|
||||||
|
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||||
|
[self clearAllPendingWindowOperations];
|
||||||
|
}
|
||||||
|
|
||||||
/* Don't recurse back into UpdateFullscreenMode() if this was hit in
|
/* Don't recurse back into UpdateFullscreenMode() if this was hit in
|
||||||
* a blocking transition, as the caller is already waiting in
|
* a blocking transition, as the caller is already waiting in
|
||||||
* UpdateFullscreenMode().
|
* UpdateFullscreenMode().
|
||||||
|
|||||||
Reference in New Issue
Block a user