From cf4206d987d8b74964b11d1ccac38efddc0b7684 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 24 Jun 2015 20:24:52 +0200 Subject: [PATCH] Fixed duplicate key presses caused by XIM. Probably. --- src/x11_window.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 1211fbbd..641a945c 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -867,35 +867,42 @@ static void processEvent(XEvent *event) const int mods = translateState(event->xkey.state); const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); - if (event->xkey.keycode) - _glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods); - if (window->x11.ic) { - // Translate keys to characters with XIM input context - int i; Status status; wchar_t buffer[16]; if (filtered) - return; + { + // HACK: Ignore key press events intended solely for XIM + if (event->xkey.keycode) + { + _glfwInputKey(window, + key, event->xkey.keycode, + GLFW_PRESS, mods); + } + } + else + { + const int count = XwcLookupString(window->x11.ic, + &event->xkey, + buffer, sizeof(buffer), + NULL, &status); - const int count = XwcLookupString(window->x11.ic, - &event->xkey, - buffer, sizeof(buffer), - NULL, &status); - - for (i = 0; i < count; i++) - _glfwInputChar(window, buffer[i], mods, plain); + for (i = 0; i < count; i++) + _glfwInputChar(window, buffer[i], mods, plain); + } } else { - // Translate keys to characters with fallback lookup table - KeySym keysym; XLookupString(&event->xkey, NULL, 0, &keysym, NULL); + _glfwInputKey(window, + key, event->xkey.keycode, + GLFW_PRESS, mods); + const long character = _glfwKeySym2Unicode(keysym); if (character != -1) _glfwInputChar(window, character, mods, plain);