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.
This commit is contained in:
lsdhophora 2026-07-09 08:22:06 +08:00
parent efc31d9de8
commit 00029d0a6f

View file

@ -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();
}
}