Skip to content

Commit

Permalink
cocoa: Fix recreated windows that are both borderless and resizable.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
icculus committed Apr 27, 2021
1 parent 40210f8 commit 8527c58
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -1405,7 +1405,10 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
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) {

This comment has been minimized.

Copy link
@slouken

slouken Apr 28, 2021

Collaborator

Was there a reason you didn't use: if ((style & NSWindowStyleMaskBorderless) != 0)

This comment has been minimized.

Copy link
@icculus

icculus Apr 28, 2021

Author Collaborator

(style & 0) would always be zero.

This comment has been minimized.

Copy link
@icculus

icculus Apr 28, 2021

Author Collaborator

(Although my specific thinking at the time is that every other style bit involves the window border, so I was explicitly checking for the degenerate case.)

window->flags |= SDL_WINDOW_BORDERLESS;
} else {
window->flags &= ~SDL_WINDOW_BORDERLESS;
Expand Down

0 comments on commit 8527c58

Please sign in to comment.