[linux] SDL fullscreen keyboard grab breaks alt-tabbing
Posted: Wed Oct 17, 2012 2:20 am
When you fullscreen FTL, it really really fullscreens, and as such grabs complete control of keyboard input. It bypasses all other shims such as global shortcut daemons or window managers, and is expected behavior of SDL and X.org both.
Would it be possible to implement a faux alt-tab for such fullscreen cases? As in, when alt-tab is pressed, minimize and give focus to the root window? Maybe also listen and react to common keys, like XF86AudioRaiseVolume and friends (refer to /usr/include/X11/XF86keysym.h) -- or simply let everything not relevant to FTL pass through?
The best workaround I've found so far is to patch SDL to always allow for alt-tab to seep through, but obviously it would be neater with a fix built into FTL proper. There's also a preload hack if you don't want to compile stuff yourself, but this way I also nail other SDL games I play.
...well, the neatest way would be if X.org was a bit more lenient. But there seems to be valid reasons for this stringency.
[source]- "Fake" fullscreen: Wine apps, Firefox, Totem. They don't grab the
keyboard. Basically, they hide the window decoration and fill the screen
with the window.
- "True" fullscreen: Games. They grab the keyboard control, so Gnome
can't do anything. If an app like this crashes, you can't even call
System Monitor to kill it (like ctrl + alt + del in Windows).
[source]The cause is that the game grabs all mouse and keyboard input with
SDL_WM_GrabInput() to lock the mouse to the window, which is desirable,
but which then prevents the window managers from registering Alt-Tab
requests.
Unfortunately, Alt-Tab wasn't set as a standard by SDL leaving the
games to support Alt-Tab themselves in their own input routines. And
they mostly don't...
Would it be possible to implement a faux alt-tab for such fullscreen cases? As in, when alt-tab is pressed, minimize and give focus to the root window? Maybe also listen and react to common keys, like XF86AudioRaiseVolume and friends (refer to /usr/include/X11/XF86keysym.h) -- or simply let everything not relevant to FTL pass through?
The best workaround I've found so far is to patch SDL to always allow for alt-tab to seep through, but obviously it would be neater with a fix built into FTL proper. There's also a preload hack if you don't want to compile stuff yourself, but this way I also nail other SDL games I play.
...well, the neatest way would be if X.org was a bit more lenient. But there seems to be valid reasons for this stringency.