Using AnyModifier seems a good idea.
]]>Why don't you just do XGrabKey for each key you need at the moment you know that you need it?
That's what I'm going to have to do... but it's just messy compared to other event handling (i.e. just add ButtonMask to get all mouse button events - there's no "KeyMask").
It makes more sense to KeyGrab each key, so as to not get superfulous events.... but still... keyboard events are the only ones which don't have a mask...
Also, I'm going to use AnyModifier on all the keys so I can allow the "Mod" key to be switched on the fly - i.e. bind Alt+X to something, then later change the modifier key to Mod4, and Mod4+X is the same keybinding it was before....
]]>XGrabKey(dpy, XK_F1, AnyModifier, DefaultRootWindow(dpy), 1, GrabModeSync, GrabModeSync);
this code allows all "F1" keypresses to be sent to this client. Now, that's fine and all, except when you want to start doing some on-the-fly key bindings. It's fairly simple to decided "should I handle this key or pass it on to another client?":
if(handleKey(ev->xkey.keycode))
//swallow the event, don't pass it on
XAllowEvents(dpy, AsyncKeyboard, ev->xkey.time);
else
{ //pass through to client
XAllowEvents(dpy, ReplayKeyboard, ev->xkey.time);
XFlush(dpy); /* don't forget! */
}
Now, the problem comes in with the following: in order to do this on the fly and grab keys and things, I need to keygrab ever key I want to handle with the first snippet. That's fine, I guess, but it's be messy.
My question: is there a way to tell X "hey, give me every keypress!"?
]]>