baisheng.wang.cn at gmail.com
Thu Feb 28 14:15:03 PST 2008
On Thursday 28 February 2008 04:00:56 am Peter Hutterer wrote:
> Wang Baisheng wrote:
> > I am using the XGrabKey, but I am confused...
> this is a mandatory requirement for grabs. if you wouldn't be, the MiB
> would be after you.
> > First, for params keyboard_mode, the man page says "If the keyboard_mode
> > argument is GrabModeAsync, keyboard event processing continues as usual",
> > but when I write some code like, " XGrabKey(display,
> > XKeysymToKeycode(display, XK_d), 0, rootWindow, True, GrabModeAsync,
> > GrabModeAsync);", the focus application can not receive any key d press
> > event.
> this is correct. you told the x server to deliver any d press that
> happens on the root window (== every press) to you. No matter who has
> the focus.
> grabs work top down (checking the root window first for grabs). event
> delivery works bottom up (checking focus window first for delivery).
> This is an important distinction.
You mean that if I use the parameter GrabModeAsync, the x server only deliver
the d press to the root window and then do not deliver it to the focus
And if I want to let the focus window receive the d press event I have to send
the d press event manually when the root window receive the d press event.
> > And the man page says "Actual keyboard changes are not lost while the
> > keyboard is frozen; they are simply queued in the server for later
> > processing", but after I receive the key press event, I call
> > XAllowEvents, but I can not receive any KeyRelease event, why ?
> you can't XAllowEvents if you don't freeze the device. so it's either
> GrabModeAsync or XAllowEvents.
Yes. I passed GrabModeSync to the XGrabKey. After I receive the key press
event, I call XAllowEvents but I can not receive any KeyRelease event.
More information about the xorg