diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2009-12-13 12:03:26 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2009-12-13 12:03:26 +0000 |
| commit | c8278a23449da36df4e7177c49dcc6fc74683306 (patch) | |
| tree | b5d787a107b3a37d7c8d1034928fb58c5557fa44 /src/Fl_x.cxx | |
| parent | 64716f01e27a9c8ec28cfa9fd9e9822930a14ada (diff) | |
New patches appliet for Cocoa port. Fixed(?) STR 2232 workaround for X11 keyrepeat bbbbuuuuuuggggg.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6966 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
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: |
