Output selection for games
Game toolkits like SDL are in a bit of a difficult situation when it comes to selecting the output to place a fullscreen game on. The current way this works is pretty much
- SDL exposes a list of outputs
- the game moves its window to the output it wants to be fullscreen on
- the game sets its window to be fullscreen on the screen it's on. On Wayland, SDL just picks the screen the window would've been on, if the application could place its window
There's roughly these three cases:
- the game just always picks the first output in the list. That's what effectively all games do
- the game has a selector for the screen to place the window on in its settings
- the game developer sets a specific screen to put the game on, so it gets placed on a specific screen during development
In order to make the most prevalent case work at least somewhat well, SDL sorts the list of outputs so that the "primary" screen is in the first place on Windows and X11. On Wayland, it doesn't get this information, so what ends up happening is one of
- a Gnome dbus interface is available with that info and gets used
- a kde internal protocol is available with that info and gets used
- the order in which
wl_output
globals appear gets used
Obviously, all of these are horrible. Window placement shouldn't happen based on any desktop environment protocol (which, in the case of Plasma, is about the placement of panels, never apps!), and definitely not based on the random-ish order of globals either.
The ideal solution would of course be that SDL just uses a null wl_output
in the xdg_toplevel.set_fullscreen
request, but because of the existing API combined with an actually real use case (selecting the screen the game is in through the game UI), that is currently not possible. For future SDL versions I suggested a set_fullscreen_on_preferred_screen
function, but this also depends on games making use of it.
The only feasible way I see to have these existing games be placed how our users expect it, would be to have some protocol for the compositor to tell SDL and similar game toolkits about an output it would prefer the game to launch on; effectively a racy version of xdg_toplevel.set_fullscreen(null)
. Does anyone have thoughts or immediate rejections for this, before I write an actual protocol proposal?