]> git.eshelyaron.com Git - emacs.git/commitdiff
Work around race condition bug in Android 13's input manager
authorPo Lu <luangruo@yahoo.com>
Fri, 17 Feb 2023 13:31:43 +0000 (21:31 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 17 Feb 2023 13:31:43 +0000 (21:31 +0800)
* 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.

src/androidterm.c
src/textconv.c

index 8a07bfa7455e9ffeb29ed54c7b249588b5c71a28..0fbee1e9867bd8fc656bc8c7a1cba2959ac5c40a 100644 (file)
@@ -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;
     }
 }
 
index 8f5a4987d5a5171fefc80a562ac1deeab1eefc50..7704f1b62a6155b67a57e93b7468039d9b7b4b0f 100644 (file)
@@ -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);
 }