From 8527c583f4b74c282e86fc1cbf85457a41456cd8 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 27 Apr 2021 01:36:23 -0400 Subject: [PATCH] cocoa: Fix recreated windows that are both borderless and resizable. These would accidentally get a titlebar because the "borderless" style mask is zero but the resizable attribute adds a bit. I assume this happens because you used to need window decoration to resize a window in macOS, but this changed in later releases. This only caused problems when recreating a window (you had an SDL_WINDOW_OPENGL window and tried to create a Metal SDL_Renderer on it, etc). Fixes #4324. --- 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 fa19aa67b..2b5d2de62 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1405,7 +1405,10 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, NSView *nsview, { unsigned long style = [nswindow styleMask]; - if (style == NSWindowStyleMaskBorderless) { + /* 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) { window->flags |= SDL_WINDOW_BORDERLESS; } else { window->flags &= ~SDL_WINDOW_BORDERLESS;