From 4ff66a7818e3eaa5362c828a18220b12f1cd9bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 27 Mar 2017 01:19:41 +0200 Subject: [PATCH] X11: Fix IM-duplicated key events leaking through Fixes #747. Fixes #964. --- README.md | 1 + src/x11_platform.h | 3 +-- src/x11_window.c | 13 ++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f537aead..8ec76cde 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Window creation on 64-bit would read past top of stack (#951) - [X11] Bugfix: XDND support had multiple non-conformance issues (#968) - [X11] Bugfix: The RandR monitor path was disabled despite working RandR (#972) +- [X11] Bugfix: IM-duplicated key events would leak at low polling rates (#747) - [Linux] Bugfix: Event processing did not detect joystick disconnection (#932) - [Cocoa] Added support for Vulkan window surface creation via [MoltenVK](https://moltengl.com/moltenvk/) (#870) diff --git a/src/x11_platform.h b/src/x11_platform.h index 4ca5a1da..bafe88f4 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -141,8 +141,7 @@ typedef struct _GLFWwindowX11 // The last position the cursor was warped to by GLFW int warpCursorPosX, warpCursorPosY; - // The information from the last KeyPress event - unsigned int lastKeyCode; + // The time of the last KeyPress event Time lastKeyTime; } _GLFWwindowX11; diff --git a/src/x11_window.c b/src/x11_window.c index 907fa794..e1c2a3e3 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -992,17 +992,16 @@ static void processEvent(XEvent *event) if (window->x11.ic) { // HACK: Ignore duplicate key press events generated by ibus - // Corresponding release events are filtered out by the - // GLFW key repeat logic - if (window->x11.lastKeyCode != keycode || - window->x11.lastKeyTime != event->xkey.time) + // These have the same timestamp as the original event + // Corresponding release events are filtered out + // implicitly by the GLFW key repeat logic + if (window->x11.lastKeyTime < event->xkey.time) { if (keycode) _glfwInputKey(window, key, keycode, GLFW_PRESS, mods); - } - window->x11.lastKeyCode = keycode; - window->x11.lastKeyTime = event->xkey.time; + window->x11.lastKeyTime = event->xkey.time; + } if (!filtered) {