mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-19 06:35:15 +00:00
Anchor IME cursor rectangle to pre-edit start
During IME composition kitty reported the cursor rectangle at the end of the pre-edit text (overlay_line.cursor_x), so every keystroke that grew the pre-edit moved the rectangle and the IME candidate window jumped horizontally. Report the start of the pre-edit text (overlay_line.xstart) instead, which is stable for the whole composition, and only send position updates when it changes. Also deduplicate IBus SetCursorLocation the same way the Wayland text-input path already does.
This commit is contained in:
parent
b00de8c4bb
commit
3bce8cdc36
3 changed files with 17 additions and 3 deletions
9
glfw/ibus_glfw.c
vendored
9
glfw/ibus_glfw.c
vendored
|
|
@ -494,6 +494,15 @@ glfw_ibus_set_focused(_GLFWIBUSData *ibus, bool focused) {
|
|||
|
||||
void
|
||||
glfw_ibus_set_cursor_geometry(_GLFWIBUSData *ibus, int x, int y, int w, int h) {
|
||||
// Skip duplicate updates (e.g. pre-edit text changes while the anchor
|
||||
// cell is unchanged) so the IME candidate window is not needlessly
|
||||
// repositioned. Mirrors the dedup in wl_text_input.c.
|
||||
static int last_x = INT_MIN, last_y = INT_MIN, last_w = INT_MIN, last_h = INT_MIN;
|
||||
if (x == last_x && y == last_y && w == last_w && h == last_h) return;
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
last_w = w;
|
||||
last_h = h;
|
||||
if (check_connection(ibus)) {
|
||||
glfw_dbus_call_method_no_reply(
|
||||
ibus->conn,
|
||||
|
|
|
|||
|
|
@ -150,7 +150,9 @@ prepare_ime_position_update_event(OSWindow *osw, Window *w, Screen *screen, GLFW
|
|||
unsigned int cell_width = osw->fonts_data->fcm.cell_width, cell_height = osw->fonts_data->fcm.cell_height;
|
||||
unsigned int left = w->render_data.geometry.left, top = w->render_data.geometry.top;
|
||||
if (screen_is_overlay_active(screen)) {
|
||||
left += screen->overlay_line.cursor_x * cell_width;
|
||||
// Anchor to the start of the pre-edit text rather than its end, so the
|
||||
// IME candidate window does not jump horizontally as the pre-edit grows.
|
||||
left += screen->overlay_line.xstart * cell_width;
|
||||
top += MIN(screen->overlay_line.ynum + screen->scrolled_by, screen->lines - 1) * cell_height;
|
||||
} else {
|
||||
left += screen->cursor->x * cell_width;
|
||||
|
|
|
|||
|
|
@ -5156,8 +5156,11 @@ render_overlay_line(Screen *self, Line *line, FONTS_DATA_HANDLE fonts_data) {
|
|||
line_reset_cells(line, 0, line->xnum, ol.original_line.gpu_cells, ol.original_line.cpu_cells);
|
||||
ol.is_dirty = false;
|
||||
const index_type y = MIN(ol.ynum + self->scrolled_by, self->lines - 1);
|
||||
if (ol.last_ime_pos.x != ol.cursor_x || ol.last_ime_pos.y != y) {
|
||||
ol.last_ime_pos.x = ol.cursor_x;
|
||||
// Track the start of the pre-edit text, not its end, so IME position
|
||||
// updates are not sent as the pre-edit grows, which would make the IME
|
||||
// candidate window jump horizontally while typing.
|
||||
if (ol.last_ime_pos.x != ol.xstart || ol.last_ime_pos.y != y) {
|
||||
ol.last_ime_pos.x = ol.xstart;
|
||||
ol.last_ime_pos.y = y;
|
||||
update_ime_position_for_window(self->window_id, false, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue