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,6 +258,27 @@ static int toGLFWKeyCode(uint32_t key) return GLFW_KEY_UNKNOWN; } +static void inputChar(_GLFWwindow* window, uint32_t key) +{ + uint32_t code, num_syms; + long cp; + const xkb_keysym_t *syms; + + code = key + 8; + num_syms = xkb_key_get_syms(_glfw.wl.xkb.state, code, &syms); + + if (num_syms == 1) + { + cp = _glfwKeySym2Unicode(syms[0]); + if (cp != -1) + { + const int mods = _glfw.wl.xkb.modifiers; + const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); + _glfwInputChar(window, cp, mods, plain); + } + } +} + static void keyboardHandleKey(void* data, struct wl_keyboard* keyboard, uint32_t serial, @@ -265,11 +286,8 @@ static void keyboardHandleKey(void* data, uint32_t key, uint32_t state) { - uint32_t code, num_syms; - long cp; int keyCode; int action; - const xkb_keysym_t *syms; _GLFWwindow* window = _glfw.wl.keyboardFocus; if (!window) @@ -282,19 +300,8 @@ static void keyboardHandleKey(void* data, _glfwInputKey(window, keyCode, key, action, _glfw.wl.xkb.modifiers); - code = key + 8; - num_syms = xkb_key_get_syms(_glfw.wl.xkb.state, code, &syms); - - if (num_syms == 1) - { - cp = _glfwKeySym2Unicode(syms[0]); - if (cp != -1) - { - const int mods = _glfw.wl.xkb.modifiers; - const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); - _glfwInputChar(window, cp, mods, plain); - } - } + if (action == GLFW_PRESS) + inputChar(window, key); } static void keyboardHandleModifiers(void* data,