We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4990

Summary: SDL2 fullscreen windows on Linux are created on secondary monitor
Product: SDL Reporter: bugzilla
Component: videoAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 Keywords: target-2.0.16
Version: 2.0.9   
Hardware: x86_64   
OS: Linux   
Attachments: Three examples of the problem

Description bugzilla 2020-02-16 22:13:36 UTC
Created attachment 4220 [details]
Three examples of the problem

Overview:

On Linux, SDL2 incorrectly places fullscreen windows on the secondary display if the resolution is higher than the primary display. It seems like SDL2 is attempting to place the window on the primary display, but it exceeds the usable space (the space after the Gnome top bar and bottom window navigation bar are subtracted) and it therefore places the window on the secondary display.

Steps to Reproduce:

I have three test programs that demonstrate the problem. They are available in the attachment or in the following Gist: https://gist.github.com/blast007/3d6fa9bde9d13ac943fa9948cef8ba80
Example1 creates a windowed SDL window, and then switches to fullscreen. FULLSCREEN_WIDTH and FULLSCREEN_HEIGHT should be set to the native resolution of the primary/smaller display. WINDOW_WIDTH and WINDOW_HEIGHT should be set to the same native resolution to see the failure occur, and then can be set to a resolution that would fit in the usable space to see SDL correctly switch to fullscreen.
Example2 creates a fullscreen SDL window. FULLSCREEN_WIDTH and FULLSCREEN_HEIGHT should be set to the native resolution of the primary/smaller display.
Example3 creates a fullscreen window using SDL_WINDOW_FULLSCREEN_DESKTOP. It requires no configuration.

Actual Results:

The fullscreen window is created on the secondary, higher resolution monitor.

Expected Results:

The fullscreen window is created on the primary, lower resolution monitor.

Additional Information:

I have tested with mainly on Debian Buster, which includes SDL 2.0.9. I believe the issue had also occurred with SDL 2.0.10 and with the latest SDL2 in Mercurial (as of a few months ago). I am using Gnome 3 on Xorg, though the issue also occurred on Wayland.

Display arrangement for the test
.---------.------------------.
| 1       | 2                |
|         |                  |
`---------|                  |
          |                  |
          `------------------`

Display 1 is the primary display and running at 1366x768.
Display 2 is running at 2560x1440.
Top edge of displays is aligned in the Gnome display settings.

I also reproduced this with display 1 running at 1920x1200 and display 2 running at 2560x1440.
Comment 1 bugzilla 2020-05-07 13:29:52 UTC
To assist with replicating the issue, it seems to only happen when I have the Gnome "Window list" extension enabled, which adds a bottom bar to the screen. This may be constraining the usable space enough that the window pops over to the other screen.