cocoa: Restore fullscreen state on the window regaining key status

Ensure that fullscreen state is restored if a non-minimized fullscreen window regains key status. This can happen if a fullscreen window was requested to minimize on loss of key status, but the minimization didn't actually occur.
This commit is contained in:
Frank Praznik
2024-11-19 11:15:31 -05:00
parent 014196d98d
commit 18b7a2315c

View File

@@ -1203,6 +1203,14 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
_data.videodata.modifierFlags = (_data.videodata.modifierFlags & ~NSEventModifierFlagCapsLock) | newflags; _data.videodata.modifierFlags = (_data.videodata.modifierFlags & ~NSEventModifierFlagCapsLock) | newflags;
SDL_ToggleModState(SDL_KMOD_CAPS, newflags ? true : false); SDL_ToggleModState(SDL_KMOD_CAPS, newflags ? true : false);
} }
/* Restore fullscreen mode unless the window is deminiaturizing.
* If it is, fullscreen will be restored when deminiaturization is complete.
*/
if (!(window->flags & SDL_WINDOW_MINIMIZED) &&
[self windowOperationIsPending:PENDING_OPERATION_ENTER_FULLSCREEN]) {
SDL_UpdateFullscreenMode(window, true, true);
}
} }
- (void)windowDidResignKey:(NSNotification *)aNotification - (void)windowDidResignKey:(NSNotification *)aNotification
@@ -2733,6 +2741,8 @@ SDL_FullscreenResult Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Windo
NSWindow *nswindow = data.nswindow; NSWindow *nswindow = data.nswindow;
NSRect rect; NSRect rect;
[data.listener clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
// The view responder chain gets messed with during setStyleMask // The view responder chain gets messed with during setStyleMask
if ([data.sdlContentView nextResponder] == data.listener) { if ([data.sdlContentView nextResponder] == data.listener) {
[data.sdlContentView setNextResponder:nil]; [data.sdlContentView setNextResponder:nil];
@@ -2841,6 +2851,7 @@ SDL_FullscreenResult Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Windo
if (!fullscreen && [data.listener windowOperationIsPending:PENDING_OPERATION_MINIMIZE]) { if (!fullscreen && [data.listener windowOperationIsPending:PENDING_OPERATION_MINIMIZE]) {
Cocoa_WaitForMiniaturizable(window); Cocoa_WaitForMiniaturizable(window);
[data.listener addPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN]; [data.listener addPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
[data.listener clearPendingWindowOperation:PENDING_OPERATION_MINIMIZE];
[nswindow miniaturize:nil]; [nswindow miniaturize:nil];
} }