From 2eb1657d91814972cdbc480fd0728fb563f9ea3e Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 11 Sep 2016 14:17:59 +0900 Subject: [PATCH] Wayland: Only input a character on GLFW_PRESS action Closes #804. --- src/wl_init.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 64276f3c..a4be0e8c 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -258,29 +258,11 @@ static int toGLFWKeyCode(uint32_t key) return GLFW_KEY_UNKNOWN; } -static void keyboardHandleKey(void* data, - struct wl_keyboard* keyboard, - uint32_t serial, - uint32_t time, - uint32_t key, - uint32_t state) +static void inputChar(_GLFWwindow* window, uint32_t key) { uint32_t code, num_syms; long cp; - int keyCode; - int action; const xkb_keysym_t *syms; - _GLFWwindow* window = _glfw.wl.keyboardFocus; - - if (!window) - return; - - keyCode = toGLFWKeyCode(key); - action = state == WL_KEYBOARD_KEY_STATE_PRESSED - ? GLFW_PRESS : GLFW_RELEASE; - - _glfwInputKey(window, keyCode, key, action, - _glfw.wl.xkb.modifiers); code = key + 8; num_syms = xkb_key_get_syms(_glfw.wl.xkb.state, code, &syms); @@ -297,6 +279,31 @@ static void keyboardHandleKey(void* data, } } +static void keyboardHandleKey(void* data, + struct wl_keyboard* keyboard, + uint32_t serial, + uint32_t time, + uint32_t key, + uint32_t state) +{ + int keyCode; + int action; + _GLFWwindow* window = _glfw.wl.keyboardFocus; + + if (!window) + return; + + keyCode = toGLFWKeyCode(key); + action = state == WL_KEYBOARD_KEY_STATE_PRESSED + ? GLFW_PRESS : GLFW_RELEASE; + + _glfwInputKey(window, keyCode, key, action, + _glfw.wl.xkb.modifiers); + + if (action == GLFW_PRESS) + inputChar(window, key); +} + static void keyboardHandleModifiers(void* data, struct wl_keyboard* keyboard, uint32_t serial,