From 8eb762769e909abc5d63279f7746015ace7bf9d5 Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Tue, 1 Nov 2016 17:38:05 +0000 Subject: [PATCH] Skip duplicate key events sent by IMEs like uim. --- src/video/x11/SDL_x11events.c | 6 ++++++ src/video/x11/SDL_x11video.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 74e54d9d9..b345c933d 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -574,6 +574,9 @@ X11_DispatchEvent(_THIS) if (orig_keycode) { #if defined(HAVE_IBUS_IBUS_H) || defined(HAVE_FCITX_FRONTEND_H) SDL_Scancode scancode = videodata->key_layout[orig_keycode]; + videodata->filter_code = orig_keycode; + videodata->filter_time = xevent.xkey.time; + if (orig_event_type == KeyPress) { SDL_SendKeyboardKey(SDL_PRESSED, scancode); } else { @@ -582,6 +585,9 @@ X11_DispatchEvent(_THIS) #endif } return; + } else if (orig_keycode == videodata->filter_code && xevent.xkey.time == videodata->filter_time) { + /* This is a duplicate event, resent by an IME - skip it. */ + return; } /* Send a SDL_SYSWMEVENT if the application wants them */ diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index a3324ff53..798d14f56 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -133,6 +133,10 @@ typedef struct SDL_VideoData #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM XkbDescPtr xkb; #endif + + KeyCode filter_code; + Time filter_time; + } SDL_VideoData; extern SDL_bool X11_UseDirectColorVisuals(void);