SDL: cocoa: Workaround for an issue with incorrect window position after exiting fullscreen on some displays

From f514394d1c6ef13da12ba1a81fe6b6604138bd0f Mon Sep 17 00:00:00 2001
From: Michal Trepka <[EMAIL REDACTED]>
Date: Thu, 2 Jul 2026 12:37:36 -0400
Subject: [PATCH] cocoa: Workaround for an issue with incorrect window position
 after exiting fullscreen on some displays

Fix for https://github.com/libsdl-org/SDL/issues/15920
---
 src/video/cocoa/SDL_cocoawindow.m | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index ac0d904d4729d..0f59b6f436c0c 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1572,7 +1572,10 @@ when returning to windowed mode from a space (instead of using a pending
         } else {
             [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
         }
-        [NSMenu setMenuBarVisible:YES];
+
+        if (![NSMenu menuBarVisible]) {
+            [NSMenu setMenuBarVisible:YES];
+        }
 
         // Toggle zoom, if changed while fullscreen.
         if ([self windowOperationIsPending:PENDING_OPERATION_ZOOM]) {