From 20b50849045986f08bf4916690ab2d54d612042c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 6 Apr 2018 20:18:03 +0530 Subject: [PATCH] Update glfw Fixes #439 --- glfw/glfw3.h | 2 +- glfw/xkb_glfw.c | 14 ++++++-------- kitty/glfw-wrapper.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 760fa5849..6aea7ddca 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -1383,7 +1383,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double); * So, for example, if on a US-ASCII keyboard the user presses Shift+= GLFW * will report the text "+" and the key as GLFW_KEY_EQUAL. The reported key takes into * account any current keyboard maps defined in the OS. So with a dvorak mapping, pressing - * the "q" key will generate text "d" and GLFW_KEY_D. + * the "s" key will generate text "o" and GLFW_KEY_O. * * @param[in] window The window that received the event. * @param[in] key The [keyboard key](@ref keys) that was pressed or released. diff --git a/glfw/xkb_glfw.c b/glfw/xkb_glfw.c index 52746f362..597881db5 100644 --- a/glfw/xkb_glfw.c +++ b/glfw/xkb_glfw.c @@ -216,16 +216,18 @@ glfw_xkb_compile_keymap(_GLFWXKBData *xkb, const char *map_str) { struct xkb_compose_table* compose_table = NULL; struct xkb_compose_state* compose_state = NULL; (void)(map_str); // not needed on X11 + GLFWbool ok = GLFW_FALSE; xkb_glfw_load_keymap(keymap, map_str); if (!keymap) _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to compile XKB keymap"); else { xkb_glfw_load_state(keymap, state); clean_state = xkb_state_new(keymap); - if (!state || ! clean_state) { + if (!state || !clean_state) { _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to create XKB state"); xkb_keymap_unref(keymap); keymap = NULL; } else { + ok = GLFW_TRUE; /* Look up the preferred locale, falling back to "C" as default. */ locale = getenv("LC_ALL"); if (!locale) locale = getenv("LC_CTYPE"); @@ -234,20 +236,16 @@ glfw_xkb_compile_keymap(_GLFWXKBData *xkb, const char *map_str) { compose_table = xkb_compose_table_new_from_locale(xkb->context, locale, XKB_COMPOSE_COMPILE_NO_FLAGS); if (!compose_table) { _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to create XKB compose table"); - xkb_keymap_unref(keymap); keymap = NULL; - xkb_state_unref(state); state = NULL; } else { compose_state = xkb_compose_state_new(compose_table, XKB_COMPOSE_STATE_NO_FLAGS); xkb_compose_table_unref(compose_table); compose_table = NULL; if (!compose_state) { _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to create XKB compose state"); - xkb_keymap_unref(keymap); keymap = NULL; - xkb_state_unref(state); state = NULL; } } } } - if (keymap && state && clean_state && compose_state) { + if (keymap && state && clean_state) { if (xkb->composeState) xkb_compose_state_unref(xkb->composeState); xkb->composeState = compose_state; if (xkb->keymap) xkb_keymap_unref(xkb->keymap); @@ -272,7 +270,7 @@ glfw_xkb_compile_keymap(_GLFWXKBData *xkb, const char *map_str) { } #undef S } - return GLFW_TRUE; + return ok; } static inline xkb_mod_mask_t @@ -311,7 +309,7 @@ static char text[256]; static inline xkb_keysym_t compose_symbol(_GLFWXKBData *xkb, xkb_keysym_t sym) { - if (sym == XKB_KEY_NoSymbol) return sym; + if (sym == XKB_KEY_NoSymbol || !xkb->composeState) return sym; if (xkb_compose_state_feed(xkb->composeState, sym) != XKB_COMPOSE_FEED_ACCEPTED) return sym; switch (xkb_compose_state_get_status(xkb->composeState)) { case XKB_COMPOSE_COMPOSED: diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index c22ba5500..72ce55ed3 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -1141,7 +1141,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double); * So, for example, if on a US-ASCII keyboard the user presses Shift+= GLFW * will report the text "+" and the key as GLFW_KEY_EQUAL. The reported key takes into * account any current keyboard maps defined in the OS. So with a dvorak mapping, pressing - * the "q" key will generate text "d" and GLFW_KEY_D. + * the "s" key will generate text "o" and GLFW_KEY_O. * * @param[in] window The window that received the event. * @param[in] key The [keyboard key](@ref keys) that was pressed or released.