Preedit not displayed in ghostty with fcitx5 #3279
-
DescriptionWhen using fcitx5 as the input method and enabling the option "Show preedit in applications," the preedit text does not appear in the ghostty application during text input. This seems specific to ghostty, as preedit works fine in other terminal applications. System Info and VersionOS: Arch Linux Videosghostty not showing preedit textghostty_no_preedit.mp4Expected behavior on alacrittyalacritty_preedit.mp4 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
We have other fcitx5 users in the beta (and presumably now out of the beta). I'd love to get their input on this. I'll convert back into an issue once a reproduction is confirmed. 😄 I think I know enough about fcitx5 that I can try this... |
Beta Was this translation helpful? Give feedback.
-
From 9ec0dc0560bc239f9a14b6674a06cce846a86b33 Mon Sep 17 00:00:00 2001
From: iFlygo <[email protected]>
Date: Sat, 28 Dec 2024 03:31:27 +0800
Subject: [PATCH] fix: just work for me
---
src/apprt/gtk/Surface.zig | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig
index 3d80d925..609d445d 100644
--- a/src/apprt/gtk/Surface.zig
+++ b/src/apprt/gtk/Surface.zig
@@ -1474,6 +1474,7 @@ fn gtkKeyPressed(
gtk_mods: c.GdkModifierType,
ud: ?*anyopaque,
) callconv(.C) c.gboolean {
+ log.debug("keypress", .{});
const self = userdataSelf(ud.?);
return if (self.keyEvent(
.press,
@@ -1491,6 +1492,7 @@ fn gtkKeyReleased(
state: c.GdkModifierType,
ud: ?*anyopaque,
) callconv(.C) c.gboolean {
+ log.debug("keyrelease", .{});
const self = userdataSelf(ud.?);
return if (self.keyEvent(
.release,
@@ -1732,7 +1734,7 @@ fn gtkInputPreeditStart(
_: *c.GtkIMContext,
ud: ?*anyopaque,
) callconv(.C) void {
- //log.debug("preedit start", .{});
+ log.debug("preedit start", .{});
const self = userdataSelf(ud.?);
if (!self.in_keypress) return;
@@ -1746,10 +1748,12 @@ fn gtkInputPreeditChanged(
ctx: *c.GtkIMContext,
ud: ?*anyopaque,
) callconv(.C) void {
+ log.debug("preedit changed", .{});
const self = userdataSelf(ud.?);
// If there's buffered character, send the characters directly to the surface.
if (self.im_composing and self.im_commit_buffered) {
+ log.debug("im commit: {s}", .{self.im_buf[0..self.im_len]});
defer self.im_commit_buffered = false;
defer self.im_len = 0;
_ = self.core_surface.keyCallback(.{
@@ -1766,11 +1770,12 @@ fn gtkInputPreeditChanged(
};
}
- if (!self.in_keypress) return;
+ // if (!self.in_keypress) return;
// Get our pre-edit string that we'll use to show the user.
var buf: [*c]u8 = undefined;
_ = c.gtk_im_context_get_preedit_string(ctx, &buf, null, null);
+ // log.debug("get preedit text: {s}", .{buf});
defer c.g_free(buf);
const str = std.mem.sliceTo(buf, 0);
@@ -1778,12 +1783,18 @@ fn gtkInputPreeditChanged(
// a commit event when the preedit is being cleared and we don't want
// to set im_len to zero. This is safe because preeditstart always sets
// im_len to zero.
- if (str.len == 0) return;
+ // if (str.len == 0) return;
// Copy the preedit string into the im_buf. This is safe because
// commit will always overwrite this.
self.im_len = @intCast(@min(self.im_buf.len, str.len));
@memcpy(self.im_buf[0..self.im_len], str);
+ // log.debug("im_buf: {s}", .{self.im_buf[0..self.im_len]});
+
+ _ = self.core_surface.preeditCallback(self.im_buf[0..self.im_len]) catch |err| {
+ log.err("error in key callback err={}", .{err});
+ return;
+ };
}
fn gtkInputPreeditEnd(
@@ -1804,6 +1815,8 @@ fn gtkInputCommit(
const self = userdataSelf(ud.?);
const str = std.mem.sliceTo(bytes, 0);
+ self.im_len = 0;
+
// If we're in a key event, then we want to buffer the commit so
// that we can send the proper keycallback followed by the char
// callback.
--
2.47.1 在修复之前,可以用这个patch凑合用一下 |
Beta Was this translation helpful? Give feedback.
-
Fixed on tip. |
Beta Was this translation helpful? Give feedback.
Fixed on tip.