From 2c4b6d6d8e5602a09ef1b81d4b08217ad7e76c74 Mon Sep 17 00:00:00 2001 From: Kodai Nakamura Date: Thu, 19 Mar 2026 23:06:09 +0900 Subject: [PATCH 1/2] cocoa: Unmark IME pre-edit text on Ctrl+H This ensures that Ctrl+H behaves like Backspace and correctly clears the pre-edit state, preventing uncommitted characters from remaining on the screen when using IMEs like the Japanese one on macOS. --- glfw/cocoa_window.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 1e8890d58..13ac9c75e 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1279,7 +1279,7 @@ - (void)keyDown:(NSEvent *)event const uint32_t key = translateKey(keycode, true); const bool process_text = !_glfw.ignoreOSKeyboardProcessing && (!window->ns.textInputFilterCallback || window->ns.textInputFilterCallback(key, mods, keycode, flags) != 1); _glfw.ns.text[0] = 0; - if (keycode == 0x33 /* backspace */ || keycode == 0x35 /* escape */) [self unmarkText]; + if (keycode == 0x33 /* backspace */ || keycode == 0x35 /* escape */ || (keycode == 0x04 /* h */ && (mods & GLFW_MOD_CONTROL))) [self unmarkText]; GLFWkeyevent glfw_keyevent = {.key = key, .native_key = keycode, .native_key_id = keycode, .action = GLFW_PRESS, .mods = mods}; if (!_glfw.ns.unicodeData) { // Using the cocoa API for key handling is disabled, as there is no From 7e62808fb70be8151b350704d19898afa7c97a1d Mon Sep 17 00:00:00 2001 From: Kodai Nakamura Date: Thu, 19 Mar 2026 23:21:15 +0900 Subject: [PATCH 2/2] fix: Use strict modifier check for Ctrl+H IME unmarking Refine the check to mods == GLFW_MOD_CONTROL to ensure that combinations like Ctrl+Shift+H do not trigger unmarkText, following code review feedback. --- glfw/cocoa_window.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 13ac9c75e..c645ef61b 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1279,7 +1279,7 @@ - (void)keyDown:(NSEvent *)event const uint32_t key = translateKey(keycode, true); const bool process_text = !_glfw.ignoreOSKeyboardProcessing && (!window->ns.textInputFilterCallback || window->ns.textInputFilterCallback(key, mods, keycode, flags) != 1); _glfw.ns.text[0] = 0; - if (keycode == 0x33 /* backspace */ || keycode == 0x35 /* escape */ || (keycode == 0x04 /* h */ && (mods & GLFW_MOD_CONTROL))) [self unmarkText]; + if (keycode == 0x33 /* backspace */ || keycode == 0x35 /* escape */ || (keycode == 0x04 /* h */ && mods == GLFW_MOD_CONTROL)) [self unmarkText]; GLFWkeyevent glfw_keyevent = {.key = key, .native_key = keycode, .native_key_id = keycode, .action = GLFW_PRESS, .mods = mods}; if (!_glfw.ns.unicodeData) { // Using the cocoa API for key handling is disabled, as there is no