SDL: cocoa: Clear state on failure to enter fullscreen (d8b18)

From d8b18a7e183d37c75ffdfe0d7b3569b5815bd8b1 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Tue, 14 Jul 2026 22:10:12 -0400
Subject: [PATCH] cocoa: Clear state on failure to enter fullscreen

A fullscreen exit event doesn't always accompany an entry error, so ensure that all relevant state is cleared if the window fails to enter fullscreen.

(cherry picked from commit 1a9801a16f003ee2df56dc56f35e8d5d08ad6c70)
---
 src/video/cocoa/SDL_cocoawindow.m | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 3b8fa7a042d57..220ba022765ec 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1430,12 +1430,18 @@ - (void)windowWillEnterFullScreen:(NSNotification *)aNotification
 }
 
 /* This is usually sent after an unexpected windowDidExitFullscreen if the window
- * failed to become fullscreen.
+ * failed to become fullscreen, but not always, so ensure that the state variables
+ * are cleared.
  *
  * Since something went wrong and the current state is unknown, dump any pending events.
+ *
+ * For testing purposes, this error can usually be induced by starting something that
+ * immedately enters a fullscreen space from a terminal that is in a fullscreen space.
  */
 - (void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
 {
+    inFullscreenTransition = NO;
+    isFullscreenSpace = NO;
     [self clearAllPendingWindowOperations];
 }