diff options
Diffstat (limited to 'src/Fl_x.cxx')
| -rw-r--r-- | src/Fl_x.cxx | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index d57385aed..ce1fc036f 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -780,15 +780,6 @@ static inline void checkdouble() { static Fl_Window* resize_bug_fix; -extern "C" { - static Bool fake_keyup_test(Display*, XEvent* event, char* previous) { - return - event->type == KeyPress && - event->xkey.keycode == ((XKeyEvent*)previous)->keycode && - event->xkey.time == ((XKeyEvent*)previous)->time; - } -} - //////////////////////////////////////////////////////////////// static char unknown[] = "<unknown>"; @@ -1173,11 +1164,35 @@ int fl_handle(const XEvent& thisevent) // down, probably due to some back compatibility problem. Fortunately // we can detect this because the repeating KeyPress event is in // the queue, get it and execute it instead: - XEvent temp; - if (XCheckIfEvent(fl_display,&temp,fake_keyup_test,(char*)(&xevent))){ - xevent = temp; - goto KEYPRESS; + + // Bool XkbSetDetectableAutorepeat ( display, detectable, supported_rtrn ) + // Display * display ; + // Bool detectable ; + // Bool * supported_rtrn ; + // ...would be the easy way to corrct this isuue. Unfortunatly, this call is also + // broken on many Unix distros including Ubuntu and Solaris (as of Dec 2009) + + // Bogus KeyUp events are generated by repeated KeyDown events. One + // neccessary condition is an identical key event pending right after + // the bogus KeyUp. + // The new code introduced Dec 2009 differs in that it only check the very + // next event in the queue, not the entire queue of events. + // This function wrongly detects a repeat key if a software keyboard + // sends a burst of events containing two consecutive equal keys. However, + // in every non-gaming situation, this is no problem because both KeyPress + // events will cause the expected behavior. + XEvent peekevent; + if (XPending(fl_display)) { + XPeekEvent(fl_display, &peekevent); + if ( (peekevent.type == KeyPress) // must be a KeyPress event + && (peekevent.xkey.keycode == xevent.xkey.keycode) // must be the same key + && (peekevent.xkey.time == xevent.xkey.time) // must be sent at the exact same time + ) { + XNextEvent(fl_display, &xevent); + goto KEYPRESS; + } } + event = FL_KEYUP; fl_key_vector[keycode/8] &= ~(1 << (keycode%8)); // keyup events just get the unshifted keysym: |
