From 00029d0a6f66009a076055d3b657d168e54a8953 Mon Sep 17 00:00:00 2001 From: lsdhophora Date: Thu, 9 Jul 2026 08:22:06 +0800 Subject: [PATCH] Fix IME popup position after text_input re-enters on Wayland When a kitty window regains text-input focus (e.g. switching back to a workspace in sway, unminimizing, or unlocking the screen), the zwp_text_input_v3::enter event is fired. However, text_input_enter() only called enable + set_content_type without restoring the cursor rectangle. If the compositor does not re-send wl_keyboard.enter at the same time, kitty never updates the IME position, causing the popup to appear at the top-left corner. Restore the last known cursor rectangle in text_input_enter() so the IME popup immediately appears at the correct position. --- glfw/wl_text_input.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/glfw/wl_text_input.c b/glfw/wl_text_input.c index 1f26bf3fa..38e3fce60 100644 --- a/glfw/wl_text_input.c +++ b/glfw/wl_text_input.c @@ -35,6 +35,15 @@ text_input_enter(void *data UNUSED, struct zwp_text_input_v3 *txt_input, struct ime_focused = true; zwp_text_input_v3_enable(txt_input); zwp_text_input_v3_set_content_type(txt_input, ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE, ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL); + if (last_cursor_width > 0) { + zwp_text_input_v3_set_cursor_rectangle( + txt_input, + last_cursor_left, + last_cursor_top, + last_cursor_width, + last_cursor_height + ); + } commit(); } }