From aa9de47da3e703632f31ef8ef1bef8e4b18a70db Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Sep 2018 14:50:09 +0200 Subject: [PATCH] Support compose sequences with no symbol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compose sequences can be defined without an associated symbol. To test for completeness, we now also rely on XKB’s reported compose state. Fixes #880. --- glfw/xkb_glfw.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/glfw/xkb_glfw.c b/glfw/xkb_glfw.c index c4baf5ff9..5908bf4a5 100644 --- a/glfw/xkb_glfw.c +++ b/glfw/xkb_glfw.c @@ -335,12 +335,14 @@ glfw_xkb_should_repeat(_GLFWXKBData *xkb, xkb_keycode_t scancode) { static KeyEvent key_event = {}; static inline xkb_keysym_t -compose_symbol(struct xkb_compose_state *composeState, xkb_keysym_t sym) { +compose_symbol(struct xkb_compose_state *composeState, xkb_keysym_t sym, int *compose_completed) { + *compose_completed = 0; if (sym == XKB_KEY_NoSymbol || !composeState) return sym; if (xkb_compose_state_feed(composeState, sym) != XKB_COMPOSE_FEED_ACCEPTED) return sym; switch (xkb_compose_state_get_status(composeState)) { case XKB_COMPOSE_COMPOSED: xkb_compose_state_get_utf8(composeState, key_event.text, sizeof(key_event.text)); + *compose_completed = 1; return xkb_compose_state_get_one_sym(composeState); case XKB_COMPOSE_COMPOSING: case XKB_COMPOSE_CANCELLED: @@ -471,8 +473,9 @@ glfw_xkb_handle_key_event(_GLFWwindow *window, _GLFWXKBData *xkb, xkb_keycode_t debug("clean_sym: %s ", glfw_xkb_keysym_name(clean_syms[0])); if (action == GLFW_PRESS || action == GLFW_REPEAT) { const char *text_type = "composed_text"; - glfw_sym = compose_symbol(sg->composeState, syms[0]); - if (glfw_sym == XKB_KEY_NoSymbol) { + int compose_completed; + glfw_sym = compose_symbol(sg->composeState, syms[0], &compose_completed); + if (glfw_sym == XKB_KEY_NoSymbol && !compose_completed) { debug("compose not complete, ignoring.\n"); return; }