From 08b3af43872a9535f0b778d6e8dcb6a2c05cad81 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 9 Jun 2015 14:41:15 +0200 Subject: [PATCH] Fixed non-pre-edit character input via XIM. Fixes #501. Fixes #473. --- README.md | 1 + src/x11_window.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 174bbe83..114d28bb 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ GLFW bundles a number of dependencies in the `deps/` directory. - [Cocoa] Bugfix: Creating or showing a window would make its context current - [X11] Bugfix: `glfwInit` would segfault on systems without RandR - [X11] Bugfix: The response to `_NET_WM_PING` was sent to the wrong window + - [X11] Bugfix: Character input via XIM did not work in many cases - [WGL] Removed `GLFW_USE_DWM_SWAP_INTERVAL` compile-time option - [WGL] Bugfix: Swap interval was ignored when DWM was enabled - [GLX] Added dependency on `libdl` on systems where it provides `dlopen` diff --git a/src/x11_window.c b/src/x11_window.c index 33e51708..4f5cb8ef 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -863,6 +863,10 @@ static void leaveFullscreenMode(_GLFWwindow* window) static void processEvent(XEvent *event) { _GLFWwindow* window = NULL; + Bool filtered = False; + + if (_glfw.x11.im) + filtered = XFilterEvent(event, None); if (event->type != GenericEvent) { @@ -893,11 +897,8 @@ static void processEvent(XEvent *event) Status status; wchar_t buffer[16]; - if (XFilterEvent(event, None)) - { - // Discard intermediary (dead key) events for character input + if (filtered) break; - } const int count = XwcLookupString(window->x11.ic, &event->xkey, @@ -1112,6 +1113,9 @@ static void processEvent(XEvent *event) { // Custom client message, probably from the window manager + if (filtered) + break; + if (event->xclient.message_type == None) break; @@ -1239,6 +1243,9 @@ static void processEvent(XEvent *event) { if (event->xfocus.mode == NotifyNormal) { + if (window->x11.ic) + XSetICFocus(window->x11.ic); + _glfwInputWindowFocus(window, GL_TRUE); if (window->cursorMode == GLFW_CURSOR_DISABLED) @@ -1252,6 +1259,9 @@ static void processEvent(XEvent *event) { if (event->xfocus.mode == NotifyNormal) { + if (window->x11.ic) + XUnsetICFocus(window->x11.ic); + _glfwInputWindowFocus(window, GL_FALSE); if (window->cursorMode == GLFW_CURSOR_DISABLED)