Skip to content

Mac: Incorrect window position after exiting fullscreen on certain display configurations #15920

Description

@ZeroEightSix

It looks like in certain conditions on exiting fullscreen, SDL can trigger what seems to be a peculiar macOS bug, resulting in the window being moved to an incorrect position. It's consistently happening on my ultra wide monitor when I toggle fullscreen using the green title bar button or the Enter/Exit Full Screen menu item.

Interestingly, it's rare (but still reproducible) when I use SDL_WaitEvent instead of SDL_PollEvent, or when I use SDL_SetWindowFullscreen to toggle fullscreen.

Here's a video illustrating the problem:

toggle-fullscreen-720p.mov

I've debugged this and discovered that the issue occurs because in some cases the [NSMenu setMenuBarVisible:YES]; call in windowDidExitFullScreen: makes Cocoa call windowDidMove: with an incorrectly set window frame. [nswindow frame] in windowDidExitFullScreen: right before that setMenuBarVisible: call is correct.

Here's a screenshot of the call stack:

Image

Calling [NSMenu setMenuBarVisible:YES] in windowDidExitFullScreen: only if [NSMenu menuBarVisible] is false works around this problem and hopefully is an acceptable solution. I will create a pull request with that change shortly.

Also, this is possibly related to, or even a duplicate of #8191, but since this is happening on my single monitor, I've decided to open a new issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions