From: Po Lu Date: Fri, 17 Feb 2023 13:31:43 +0000 (+0800) Subject: Work around race condition bug in Android 13's input manager X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e88730a4b439b3b534048c6f419d651a4c0cc76d;p=emacs.git Work around race condition bug in Android 13's input manager * src/androidterm.c (android_get_selection): Use ephemeral last point. * src/textconv.c (report_selected_window_change): Set w->ephemeral_last_point to the window's point now. --- diff --git a/src/androidterm.c b/src/androidterm.c index 8a07bfa7455..0fbee1e9867 100644 --- a/src/androidterm.c +++ b/src/androidterm.c @@ -4841,7 +4841,7 @@ android_get_selection (void *data) /* Return W's point at the time of the last redisplay. This is rather important to keep the input method consistent with the contents of the display. */ - context->point = w->last_point; + context->point = w->ephemeral_last_point; } } diff --git a/src/textconv.c b/src/textconv.c index 8f5a4987d5a..7704f1b62a6 100644 --- a/src/textconv.c +++ b/src/textconv.c @@ -1477,11 +1477,24 @@ conversion_disabled_p (void) void report_selected_window_change (struct frame *f) { + struct window *w; + reset_frame_state (f); if (!text_interface) return; + /* When called from window.c, F's selected window has already been + redisplayed, but w->last_point has not yet been updated. Update + it here to avoid race conditions when the IM asks for the initial + selection position immediately after. */ + + if (WINDOWP (f->selected_window)) + { + w = XWINDOW (f->selected_window); + w->ephemeral_last_point = window_point (w); + } + text_interface->reset (f); }