losing key release events

lets imagine that an application is tracking keyboard state in order
to allow arbitrary key combinations to be used for "shortcuts". when
the user presses Ctrl-x, the following things happen:

    key press (Ctrl): mark state as having ctrl pressed
    key press (x):    mark state as having x pressed
	              lookup action for current key state
		      execute action
    key release (x):  remove x from current state			     
    key release (Ctrl):  remove Ctrl from current state			     

consider a situation where a executed action creates a new
window. imagine that the user has her WM setup to give focus to newly
created windows. additionally imagine that the new window is a default
GtkWindow, where key release events are not received.

what happens now is that at least one of the 2 two key release events
(the Ctrl release) is lost, because it is processed by the X server
with focus given to the new window which doesn't receive such events.

this can be avoided by using a keyboard grab, but these are ugly and
dangerous and can result in users having to kill X or do other
unseemly things if the program goes awry during the grab.

it can also be avoided by using XQueryKeymap but thats non-portable to
non-X implementations of GDK, and its expensive.

another way to handle it would be to make sure that all new
GtkWindow's receive key release events. possible, but tedious and
error prone.

any other comments or ideas?


ps. i am of course using a keyboard snooper for this, since my
    application cannot accomodate the usual GTK+ focus rules. but
    i'm not doing anything unusual there, just making sure 
    that the rest of the GTK+ event system never gets to the
    key press events unless i allow it too.

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