emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/android e88730a4b43: Work around race condition bug in Android 1


From: Po Lu
Subject: feature/android e88730a4b43: Work around race condition bug in Android 13's input manager
Date: Fri, 17 Feb 2023 08:32:58 -0500 (EST)

branch: feature/android
commit e88730a4b439b3b534048c6f419d651a4c0cc76d
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 src/androidterm.c |  2 +-
 src/textconv.c    | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]