Anything in particular I should be doing in my code, or is it that KDE
is not really compatible with this way of switching modes?
A lot of this code has changed in SDL2 recently, so this is likely our
bug. If this currently works in SDL 1.2 and is busted in SDL2, we want
(and need!) to hear about it right away. We have some important
SDL2-based stuff shipping soon and would like to catch these things now
if we can.
Sam and I have been beating the crap out of the X11 fullscreen code over
the last two weeks or so. The current “best” approach we have is what
we’re referring to as the “legacy” approach–that is, what SDL 1.2 did,
which has now been ported to SDL2.
The legacy approach looks something like this:
- SDL changes the screen resolution with XVidMode.
- SDL makes a big black window the size of this resolution and moves the
mouse into it so it’s covering the visible portion of the virtual
desktop, and then reparents its actual window on top of this.
- SDL locks the vidmode so you can’t press ctrl-alt-minus to see the
rest of your desktop.
- SDL grabs the mouse and keyboard, so you can’t alt-tab out of this window.
- Basically, we try to prevent you looking behind the curtain to see
that we’re faking all this stuff in the top-left corner of your actual
- If the app crashes, SDL (maybe) cleans everything up, but you might be
left with a frozen mouse cursor or a crappy resolution.
This is the system we’ve used since the 90’s, when Loki needed a way to
do “fullscreen” games. It works well enough, assuming you have an
uncontroversial window manager, X server, and a measure of luck…but
we’ve all been burnt by it at some time or another, whether we’ve wanted
to switch to our email client for a second and couldn’t, wanted to use
the volume keys on our keyboards, had XRandR smoosh all our windows
down, landed on the wrong Xinerama monitor, or had a crash that just
left a big mess on our screens.
This method will be remaining in SDL2, because in terms of catching
every configuration, it generally works on all sorts of X servers and
Unices, but it’s really a technically offensive approach.
If we could change anything, there’s really only one way to do this for
X11 that makes sense: the window manager needs to be responsible for
fullscreen switches. Sam and I are drafting a proposal for a new window
manager protocol that allows a window to request a fullscreen mode from
the WM, which will be able to handle multiple apps competing for the
screen, allow access to your desktop and volume keys safely, and clean
up in case of app crashes.
As a side benefit, apps won’t have to screw around with X11 extensions
like XVidMode and XRandR…that will move into a central place in the
window manager. The app will just have to say to the WM “make me
fullscreen” in the same way that it currently says things like “maximize
me” or “iconify me.”
As a side note, there’s already something like this in the WM specs
("_NET_WM_STATE_FULLSCREEN"), and that’s great for telling OpenOffice
Impress to use the whole projector for your presentation or Firefox to
take up the whole desktop when you press F11, but it doesn’t fit SDL’s
needs, or the needs of video games in a general sense.
We’ll be publishing our proposed spec shortly, and seeing if the
community likes the idea, and we’ll go forward from there.
That being said, there are probably still bugs in SDL2’s legacy
approach…please try the latest from Mercurial and report bugs!