Angus Leeming <[EMAIL PROTECTED]> writes:
| On Tuesday 10 December 2002 3:26 pm, Lars Gullik Bj�nnes wrote:
>> What we do not want is cursors, auto-repeat chars that just continue
>> to go after the key has been released. so we use xsync for this.
>> The problem is to know when to run this xsync, we want to loose as few
>> xevents as possible.
>> | So adjacent Release and Press events have the same time stamp. Next
>> | step?
>> this means that you are autorepeating.
>
| Ok. I'm getting there. You want code like this:
Sorry for leading you on a leash like that...
As we progressed I began feeling a bit queasy...it might not be som
clever after all.
..but yes, something similar to this was what I thought of.
| handler() {
| static Time time_released;
| static unsigned int last_key_pressed;
| static unsigned int last_state_pressed;
>
| switch (event) {
| case FL_KEYPRESS:
| {
| if (!ev) break;
| XKeyEvent * xke = reinterpret_cast<XKeyEvent *>(ev);
>
| if (xke->time - time_released < 25 // should perhaps be tunable
| && xke->state == last_state_pressed
| && xke->keycode == last_key_pressed) {
| // purge events
| if (XEventsQueued(fl_get_display(), QueuedAlready) > 0)
| waitForX(true);
| break;
| }
>
| // Go on to handle the key press and dispatch it to workAreaKeyPress
| ...
| break;
| }
| case FL_KEYRELEASE:
| if (!ev) break;
| time_released = ev->xkey.time;
| last_key_pressed = ev->xkey.keycode;
| last_state_pressed = ev->xkey.state;
| break;
| }
| }
>
| Am I there?
| Angus
>
--
Lgb