Home > Archive > Unix Programming > July 2006 > XAutoRepeatOff (Display *)...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
XAutoRepeatOff (Display *)...
|
|
|
|
Greetings,
The two following Xlib functions...
int XAutoRepeatOn (Display *display);
int XAutoRepeatOff(Display *display);
....set on/off the auto-repeat mode of the keyboard on a given display,
i.e., they control whether series of "fake" KeyPress/KeyRelease XEvents
are generated while a key remains physically pressed past some delay.
Is there a way to specify such a thing for one Window only,
and not globally for the whole display ?
If not, when receiving an XKeyEvent,
is there a way to detect if the event is a "fake" one ?
(I hoped testing event.xkey.send_event would do it but no...)
Thanks,
--
regis
| |
|
| regis wrote:
> The two following Xlib functions...
>
> int XAutoRepeatOn (Display *display);
> int XAutoRepeatOff(Display *display);
>
> ...set on/off the auto-repeat mode of the keyboard on a given display,
> i.e., they control whether series of "fake" KeyPress/KeyRelease XEvents
> are generated while a key remains physically pressed past some delay.
>
> Is there a way to specify such a thing for one Window only,
> and not globally for the whole display ?
>
> If not, when receiving an XKeyEvent,
> is there a way to detect if the event is a "fake" one ?
> (I hoped testing event.xkey.send_event would do it but no...)
This ng does not seem to address X programming questions.
Sorry.
However, I found a workaround to detect fake KeyRelease/KeyPress
sequence: the two events always occurs contiguously in the queue
and KeyPress has always its time field set equal to the previous
keyRelease, which seems to never occur otherwise, so:
void
BoundedEventLoop (Display * display, int ignoreAutoRepeat)
{
int k, queued= XEventsQueued (display, QueuedAfterFlush);
XEvent event1, event2;
for (k= 0; k < queued; k++) {
XNextEvent (display, & event1);
if (ignoreAutoRepeat &&
event.xany.type == KeyRelease &&
k+1 < queued &&
XP Event (display, & event2) &&
event2.xany.type == KeyPress &&
event2.xkey.time == event1.xkey.time) {
/* discard the fake KeyRelease/KeyRelease sequence */
XNextEvent (display, & event2);
k++;
continue;
}
MyEventHandler (display, event1);
}
}
--
regis
|
|
|
|
|