From 676dffff4b063cf4f7667bd0ca6ded3a03704d2c Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 13 Mar 2022 18:58:42 +0800 Subject: [PATCH] Fix setting IM spot after key press events * src/xterm.c (handle_one_xevent): Check f is not NULL before trying to set its status area and set preedit spot location after KeyPress events. --- src/xterm.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 18a8d5b431a..397b5bfc7a8 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -11038,6 +11038,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, } done_keysym: #ifdef HAVE_X_I18N + if (f) + { + struct window *w = XWINDOW (f->selected_window); + xic_set_preeditarea (w, w->cursor.x, w->cursor.y); + + if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) + xic_set_statusarea (f); + } + /* Don't dispatch this event since XtDispatchEvent calls XFilterEvent, and two calls in a row may freeze the client. */ @@ -11507,11 +11516,11 @@ handle_one_xevent (struct x_display_info *dpyinfo, #ifdef HAVE_X_I18N - if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) - xic_set_statusarea (f); - if (f) { + if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) + xic_set_statusarea (f); + struct window *w = XWINDOW (f->selected_window); xic_set_preeditarea (w, w->cursor.x, w->cursor.y); } @@ -13598,8 +13607,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, xi_done_keysym: #ifdef HAVE_X_I18N - if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) - xic_set_statusarea (f); + if (f) + { + struct window *w = XWINDOW (f->selected_window); + xic_set_preeditarea (w, w->cursor.x, w->cursor.y); + + if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) + xic_set_statusarea (f); + } #endif if (must_free_data) XFreeEventData (dpyinfo->display, &event->xcookie); -- 2.39.5