Re: losing key release events

>or alternatively, whilst the user is pressing Ctrl, another window is
>created by a separate application, and the WM shifts focus over there. I
>think this is a more fundamental problem as we don't have any control
>over whether that window receives KeyRelease events or not.

in Adrian Nye's book on Xlib, he explicitly advises using keyboard
grabs for such situations. that's what i've done for now, and it works
for me, but i really don't like keyboard grabs.

>What I do in my ZX Spectrum emulator[1] (which does something very
>similar in order to maintain a state table of which of the Spectrum's
>keys are pressed) is simply to clear all keys from the state table when
>the main window loses focus.
>This works in most cases, but doesn't handle:
>* Press Ctrl
>* Leave window
>* Re-enter window
>* Press p
>when it thinks p has been pressed rather than Ctrl-p.

unfortunately, thats precisely 1 of the 2 problems i had to fix :)

in addition, there's the additional problem for me that because i
handle stuff at the keyboard snooper level, "which window we left"
doesn't really have much of a definition. i have a single key event
handler for every key event received by my application, regardless of
which window it occurs in, and it doesn't get told about the window
either. its possible i could change this and use a handler for "event"
in every GtkWindow and stop the emission if its a keyboard event.

XQueryKeymap() will always work, but its a roundtrip to the server and
you have to be able to map the server keycodes (which are used in the
return info from XQueryKeymap) to the keyvals of the event structure


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]