SDL: cocoa: Fix new windows setting SDL_WINDOW_BORDERLESS flag incorrectly. (128c3)

From 128c34b8393ae6af59be118222e97c6dd109a9de Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 27 Sep 2022 14:23:42 -0400
Subject: [PATCH] cocoa: Fix new windows setting SDL_WINDOW_BORDERLESS flag
 incorrectly.

Fixes #6172.
(cherry picked from commit 57b20e7b9e35225ffd0aa6439d28a9fb51b2c75f)
---
 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 ad7d9e2af0d7..e9e3c09faddd 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -299,6 +299,9 @@ static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r)
 static NSUInteger
 GetWindowWindowedStyle(SDL_Window * window)
 {
+    /* IF YOU CHANGE ANY FLAGS IN HERE, PLEASE READ
+       the NSWindowStyleMaskBorderless comments in SetupWindowData()! */
+
     /* always allow miniaturization, otherwise you can't programatically
        minimize the window, whether there's a title bar or not */
     NSUInteger style = NSWindowStyleMaskMiniaturizable;
@@ -1641,7 +1644,7 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
         /* NSWindowStyleMaskBorderless is zero, and it's possible to be
             Resizeable _and_ borderless, so we can't do a simple bitwise AND
             of NSWindowStyleMaskBorderless here. */
-        if ((style & ~NSWindowStyleMaskResizable) == NSWindowStyleMaskBorderless) {
+        if ((style & ~(NSWindowStyleMaskResizable|NSWindowStyleMaskMiniaturizable)) == NSWindowStyleMaskBorderless) {
             window->flags |= SDL_WINDOW_BORDERLESS;
         } else {
             window->flags &= ~SDL_WINDOW_BORDERLESS;