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 5267

Summary: SDL_WINDOW_FULLSCREEN_DESKTOP doesn't take xrandr desktop scaling into account on Linux
Product: SDL Reporter: Tyler Schicke <tschicke>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: 2.0.12Keywords: target-2.0.16
Hardware: x86_64   
OS: Linux   
Attachments: small app that shows a repro of this bug

Description Tyler Schicke 2020-08-24 13:23:56 UTC
Created attachment 4445 [details]
small app that shows a repro of this bug

In SDL_UpdateFullscreenMode, when a window is set to fullscreen with SDL_WINDOW_FULLSCREEN_DESKTOP, a resize event can be generated using the mode's size, and the window's size is set to the mode's size.

However, on Linux with X11 and Xrandr, the size of the desktop doesn't have to match the size of the currently set mode (e.g. when using xrandr --scale-from WxH). This means that when using a scaled desktop (in my testing the mode was 1920x1200 and the scaled desktop size was 1680x1050), after setting a window to fullscreen the app will get a resize event with the mode's size (1920x1200), and SDL_GetWindowSize will return the mode's size (1920x1200) for a short time, even though the window is actually the scaled size (1680x1050) when it becomes fullscreen. After a short time it looks like SDL gets the update from X11 with the actual size of the window and generates another resize event with the correct size (1680x1050) and sets the window size correctly so that SDL_GetWindowSize also returns the correct size.

If SDL is going to generate a resize event before getting an update from X, then it should take this scaling into account using something like XRRGetCrtcTransform so that apps don't get an incorrect window size.

Repro:
Run "xrandr --output <output> --mode 1920x1080 --scale-from 1680x1050" (or some other appropriate mode) and then run the attached repro.cpp app and press F to make the window fullscreen.
The current output is something like:
Setting fullscreen
Resized to 1920x1080
Window size: 1920x1080
Window size: 1920x1080
...
Window size: 1920x1080
Window size: 1920x1080
Resized to 1680x1050

The expected output is:
Setting fullscreen
Resized to 1680x1050