[X11] SDL_GetDesktopDisplayMode does not return correct system screen resolution once system resolution is changed during runtime

Hi Devs,

Hope everyone is having a wonderful day and wanted to report a bug (I think) I found on X11 side of the SDL. I’m using SDL2 (2.0.22) to detect system resolution changes on my game engine while the game engine is running.

I’m using SDL_GetDesktopDisplayMode call to query current system resolution and found out it returns previous desktop resolution even after I change my display resolution through Ubuntu settings window.

I tested the same API call on Wayland and it seems to return the proper resolution.

For example (X11 behavior):

  • Say my display resolution is 2560x1440 when I start my game engine.
  • While game is running I decided to change display resolution to 1920x1080 via Ubuntu settings window.
  • When I query new resolution via SDL_GetDesktopDisplayMode it still returns 2560x1440 (but on Wayland it properly returns 1920x1080)

I tested on Ubuntu 18.04, 20.04, 22.04 as well as 24.04 using SDL 2.0.22 as well as SDL master branch. In all the cases I’m not getting updated resolution.

I prefer not to in-cooperating X11 or Xrandr calls directly to my engine in order to keep the engine code cross platform as possible. Wondering if someone can help me ?

Thank you again.