From d1e45ef768d0d342fff686c387b1e414d1b48c4c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 23 Jan 2025 07:24:11 -0800 Subject: [PATCH] apprt/gtk: when text is committed, end the preedit state Fixes #3567 ibus 1.5.29 doesn't trigger a preedit end state when text is committed. This is fixed in ibus 1.5.30, but we need to handle this case for older versions which are shipped on LTS distributions such as Ubuntu. Every other input method engine I've tried thus far also triggers a preedit end state when text is committed, and none would expect preedit to continue after text is committed. So I think it's safe to assume that this is the expected behavior. --- src/apprt/gtk/Surface.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index 4539e61cb..b429c7233 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -1961,6 +1961,12 @@ fn gtkInputCommit( // Committing ends composing state self.im_composing = false; + // End our preedit state. Well-behaved input methods do this for us + // by triggering a preedit-end event but some do not (ibus 1.5.29). + self.core_surface.preeditCallback(null) catch |err| { + log.err("error in preedit callback err={}", .{err}); + }; + // Send the text to the core surface, associated with no key (an // invalid key, which should produce no PTY encoding). _ = self.core_surface.keyCallback(.{