Re: Getting keyboard state.



"Timothy M. Shead" <tshead k-3d com> writes:
Havoc Pennington wrote:

"Timothy M. Shead" <tshead k-3d com> writes:
Rather than creating handlers and maintaining state for this, you can get the
information along with the pointer position from anywhere in your code:
int x, y;
GdkModifierType modifiers;
gdk_window_get_pointer(window, &x, &y, &modifiers);
... the modifier keys will be OR-ed together GdkModifierType values.

Maintaining the state is much more correct, the get_pointer()
solution
is a giant race condition.
Havoc

Come again?  Are you referring to the round-trip to the X server?
Tim

See Philip Kendall's post. The wall-clock time of the event you're
currently processing, and the wall-clock time when you request the
state with get_pointer(), could be very far apart. With a slow or
flaky network connection, could be several seconds. It could be
user-perceptible even with a local X connection if the machine is
heavily loaded. Imagine someone touch typing a bunch of stuff for
example; if you use get_pointer() instead of the state field for the
key events, your app would regularly capitalize the wrong letters.

That's why there's a state field in key/mouse events, so you can get
the state that was active when that event was generated.

Havoc






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