From 0c80f85d78f61288bc570bdd1a39e965bae75da9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 19 Dec 2023 21:56:40 -0800 Subject: [PATCH] apprt/gtk: only reset IME state if key consuming while IME composing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1047 This resets the IME state only if we were previously in a composing state. I did not realize that IME state also included non-composing state that we want to preserve, such as the next quotation direction in the case of chinese. i.e. `“` vs `”`. I'm not fully sure that this is the right logic, but previous pre-edit states such as in Japanese appear to still work and this fixes Chinese quotation marks. --- src/apprt/gtk/Surface.zig | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index 4a9ee5da3..a19144021 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -1482,10 +1482,15 @@ fn keyEvent( .closed => return true, .ignored => {}, .consumed => if (action == .press or action == .repeat) { - // If we consume the key then we want to reset the dead key - // state. - c.gtk_im_context_reset(self.im_context); - self.core_surface.preeditCallback(null) catch {}; + // If we were in the composing state then we reset our context. + // We do NOT want to reset if we're not in the composing state + // because there is other IME state that we want to preserve, + // such as quotation mark ordering for Chinese input. + if (self.im_composing) { + c.gtk_im_context_reset(self.im_context); + self.core_surface.preeditCallback(null) catch {}; + } + return true; }, }