diff options
Diffstat (limited to 'platform/x11/os_x11.cpp')
-rw-r--r-- | platform/x11/os_x11.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 2cb8247799..14d31b864c 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -480,7 +480,7 @@ unsigned int OS_X11::get_mouse_button_state(unsigned int p_x11_state) { return state; } -void OS_X11::handle_key_event(XKeyEvent *p_event) { +void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { // X11 functions don't know what const is @@ -591,17 +591,9 @@ void OS_X11::handle_key_event(XKeyEvent *p_event) { // To detect them, i use XPeekEvent and check that their // difference in time is below a treshold. - bool echo=false; - - if (xkeyevent->type == KeyPress) { - - // saved the time of the last keyrelease to see - // if it's the same as this keypress. - if (xkeyevent->time==last_keyrelease_time) - echo=true; - } else { - + if (xkeyevent->type != KeyPress) { + // make sure there are events pending, // so this call won't block. if (XPending(x11_display)>0) { @@ -615,17 +607,21 @@ void OS_X11::handle_key_event(XKeyEvent *p_event) { // not very helpful today. ::Time tresh=ABS(peek_event.xkey.time-xkeyevent->time); - if (peek_event.type == KeyPress && tresh<5 ) - echo=true; + if (peek_event.type == KeyPress && tresh<5 ) { + KeySym rk; + nbytes=XLookupString((XKeyEvent*)&peek_event, str, 256, &rk, NULL); + if (rk==keysym_keycode) { + XEvent event; + XNextEvent(x11_display, &event); //erase next event + handle_key_event( (XKeyEvent*)&event,true ); + return; //ignore current, echo next + } + } // use the time from peek_event so it always works - last_keyrelease_time=peek_event.xkey.time; - } else { - last_keyrelease_time=xkeyevent->time; } - // save the time to check for echo when keypress happens - + // save the time to check for echo when keypress happens } @@ -643,7 +639,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event) { event.key.scancode=keycode; event.key.unicode=unicode; - event.key.echo=echo; + event.key.echo=p_echo; if (event.key.scancode==KEY_BACKTAB) { //make it consistent accross platforms. @@ -1017,7 +1013,7 @@ String OS_X11::get_name() { Error OS_X11::shell_open(String p_uri) { - + return ERR_UNAVAILABLE; } |