I want to create an application where I draw on an window, either windowed or fullscreen, where I have the mouse grabbed but without intercepting any WM keyboard shortcuts, like Alt+Tab, and I also need to be notified whenever the user enter/leaves focus.
Common applications like Google Chrome, Firefox or gnome-terminal can handle this just fine (going fullscreen with F11, but still having Alt+Tab), but they do not grab the mouse.
SDL has a notorious poor handling of this use case: SDL_WM_GrabInput grabs the mouse but also intercepts WM shortcuts; and SDL_FULLSCREEN seems to have some sort of automatic grab by itself (don't ask me why).
A solution could be to write code for Alt+Tab myself, but this sucks (and doesn't help for other WM shortcuts, like changing to another workspace).
Another solution is to not call SDL_WM_GrabInput, but instead fake a grab: just hide the mouse pointer (with SDL_ShowCursor) and move it back to the center whenever the user moves. Which is ugly, but in practice works - except of course for SDL_FULLSCREEN, because it grabs automatically (unlike sane implementations). A fullscreen-capable SDL solution is this, but that's still not what I want. I don't want to have hacks to enable and disable grab, I want to grab the mouse but not grab the keyboard.
So I am mad with SDL and want to see alternatives. I would like to use SDL but this is not necessary.
This question seems to point out that what SDL actually does is to use XGrabKeyboard. By reading the man page it's not immediately clear to me whether you can grab the mouse without grabbing the keyboard (I never used Xlib myself).
I know how to make "fake fullscreen" with GTK (that is, of the Alt+Tab friendly, gnome-terminal variety). I imagine that doing this, coupled with mouse hiding and moving it back to the center ("fake grabbing") could do the trick, but this feels like too much duct tape. There must be a simpler way. (Also I don't want to add GTK as a dependency; but I'm also not sure if making raw Xlib calls is a good idea).
What's a good solution for this?
I need a Linux/X11 solution but it would be nice for it to be cross-platform - I know this can be solved smoothly on Windows, so perhaps there is a library that does exactly this. (also, I render with OpenGL but this is irrelevant)
PS: Perhaps I am having a bad understanding of this issue and I'm not asking the right question, so feel free to point out approaches I haven't considered.