فهرست منبع

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.
Frank Praznik 5 ماه پیش
والد
کامیت
18b7a2315c
1فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 11 0
      src/video/cocoa/SDL_cocoawindow.m

+ 11 - 0
src/video/cocoa/SDL_cocoawindow.m

@@ -1203,6 +1203,14 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
         _data.videodata.modifierFlags = (_data.videodata.modifierFlags & ~NSEventModifierFlagCapsLock) | newflags;
         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
@@ -2733,6 +2741,8 @@ SDL_FullscreenResult Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Windo
         NSWindow *nswindow = data.nswindow;
         NSRect rect;
 
+        [data.listener clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
+
         // The view responder chain gets messed with during setStyleMask
         if ([data.sdlContentView nextResponder] == data.listener) {
             [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]) {
             Cocoa_WaitForMiniaturizable(window);
             [data.listener addPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
+            [data.listener clearPendingWindowOperation:PENDING_OPERATION_MINIMIZE];
             [nswindow miniaturize:nil];
         }