Xlib - Ignore Modifier Keys in XGrab*
Holla,
I'm currently hacking out some changes to TinyWM - one I'd like to implement is a click-to-focus policy.
I've figured out that I need to run an XGrabButton
on the child as it is created in an MapNotify
event, but I cannot figure out what modifier mask to use which ignores all modifier masks (meaning, I would like the focus click to happen no matter what modifier keys are activated).
I've hit a brick wall, as even AnyModifier
seems not to work when I have no modifier keys pressed (and even then, it is rather picky).
Here's the relevant chunk of code:
void eMapNotify(Display *dpy, XEvent *ev){
// Ignore windows we don't care about
if (!ev.xmap.override_redirect) XSetWindowBorderWidth(dpy, ev.xmap.window, 3);
// Allows us to hook into this window's clicks to let us focus it
XGrabButton(dpy, 1, WHAT_MASK_DO_I_PUT_HERE, ev.xmap.window,
True, ButtonPressMask, GrabModeAsync, GrabModeAsync,
None, None);
}
Any ideas?
EDIT:
I've found out that in fact the event handler does record the click, but the click is not forwarded to the child window, which is precisely the behavior I want.
UPDATE
I've currently implemented focusing functionality with the following code, which tracks the pointer and focuses it wherever it is. On my machine, it's not nearly as expensive as it may look:
Window dump, child;
int rx, ry, cx, cy;
unsigned int mask;
// Get the pointer's location
XQueryPointer(dpy, root, &dump, &child, &rx, &ry, &cx, &cy, &mask);
// Focuses the pointer's c开发者_运维知识库urrent window
XSetInputFocus(dpy, dump, RevertToNone, CurrentTime);
The mask would be 0
for no modifiers.
精彩评论