The SDL forums have moved to
This is just a read-only archive of the previous forums, to keep old links working.

SDL Forum Index
Simple Directmedia Layer Forums
[PATCH] Grabbing the keyboard in X11
David Gow


At the moment, SDL grabs both the keyboard and mouse on X11 when
SDL_SetWindowGrab() is called, but only grabs the mouse on win32 and
other platforms. This means that Alt+Tab (and similar WM keys) don't
work, which is a bit of a pain. While the old-style X11 fullscreen code
(for WMs which aren't ICCCM-2.0 compliant) needs the keyboard grabbed,
otherwise simply grabbing the mouse suffices.

There are a couple of different ways of resolving this: allowing the
user to grab the mouse and keyboard separately, perhaps with something
like SDL_SetWindowGrab(w, SDL_GRAB_KEYBOARD | SDL_GRAB_MOUSE), or by
simply making the X11 backend only grab the keyboard when in old-style
fullscreen mode. I have implemented the latter --- the patch is attached
--- and it seems to work quite well.

What do you think the right way forward is?

-- David

SDL mailing list