From c0be0f74d8d5b3082d8f0a6823faea6b26eca586 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 22 Jan 2022 21:11:26 +0530 Subject: [PATCH] Use commit text instead of a zero key event Thanks @page-down --- glfw/cocoa_window.m | 2 +- kitty/keys.c | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 8d2a5c2f3..c3aee006a 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1481,7 +1481,7 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) { _glfw.ns.text[sizeof(_glfw.ns.text) - 1] = 0; if (!in_key_handler && _glfw.ns.text[0]) { debug_key("sending text to kitty from insertText called from event loop: %s\n", _glfw.ns.text); - GLFWkeyevent glfw_keyevent = {.text=_glfw.ns.text}; + GLFWkeyevent glfw_keyevent = {.text=_glfw.ns.text, .ime_state=GLFW_IME_COMMIT_TEXT}; _glfwInputKeyboard(window, &glfw_keyevent); _glfw.ns.text[0] = 0; } diff --git a/kitty/keys.c b/kitty/keys.c index ec9fea5e8..5985182d9 100644 --- a/kitty/keys.c +++ b/kitty/keys.c @@ -152,12 +152,6 @@ on_key_input(GLFWkeyevent *ev) { debug("invalid state, ignoring\n"); return; } - if (!native_key && !key && text[0]) { - // key == 0 is sent by the glfw coca backend when text is inserted by the IME outside the key handlers - schedule_write_to_child(w->id, 1, text, strlen(text)); - debug("sent key as text to child\n"); - return; - } PyObject *ke = NULL; #define create_key_event() { ke = convert_glfw_key_event_to_python(ev); if (!ke) { PyErr_Print(); return; } } if (global_state.in_sequence_mode) {