SDL: cocoa: Properly set the pending fullscreen spaces state when in a transition (01391)

From 013918cd8365274416db01709df56d579ebcbf61 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Mon, 24 Mar 2025 23:23:32 -0400
Subject: [PATCH] cocoa: Properly set the pending fullscreen spaces state when
 in a transition

(cherry picked from commit b520cde18f5e64bb1be27a611564d47234105e98)
---
 src/video/cocoa/SDL_cocoawindow.m | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 69c3674b22692..2a0527b744f39 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -868,14 +868,16 @@ - (BOOL)setFullscreenSpace:(BOOL)state
         return NO; // we only allow you to make a Space on fullscreen desktop windows.
     } else if (!state && window->last_fullscreen_exclusive_display) {
         return NO; // we only handle leaving the Space on windows that were previously fullscreen desktop.
-    } else if (state == isFullscreenSpace) {
+    } else if (state == isFullscreenSpace && !inFullscreenTransition) {
         return YES; // already there.
     }
 
     if (inFullscreenTransition) {
         if (state) {
+            [self clearPendingWindowOperation:PENDING_OPERATION_LEAVE_FULLSCREEN];
             [self addPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
         } else {
+            [self clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN];
             [self addPendingWindowOperation:PENDING_OPERATION_LEAVE_FULLSCREEN];
         }
         return YES;