emacs-diffs
[Top][All Lists]
Advanced

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

feature/android c843f3e23b4: Update Android port


From: Po Lu
Subject: feature/android c843f3e23b4: Update Android port
Date: Fri, 7 Jul 2023 22:15:55 -0400 (EDT)

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

    Update Android port
    
    * java/org/gnu/emacs/EmacsService.java (DEBUG_IC)
    (DEBUG_THREADS): Improve commentary.
    * src/androidterm.c (handle_one_android_event): Signal
    completion of IME events that have lost their frames.
    (requestCursorUpdates): Don't set an edit counter as this event
    won't be passed to the text conversion machinery.
---
 java/org/gnu/emacs/EmacsService.java |  6 +++---
 src/androidterm.c                    | 35 +++++++++++++++++++++++++++++------
 2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/java/org/gnu/emacs/EmacsService.java 
b/java/org/gnu/emacs/EmacsService.java
index 37048960f25..62fd2740286 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -96,11 +96,11 @@ public final class EmacsService extends Service
   public DisplayMetrics metrics;
 
   /* Flag that says whether or not to print verbose debugging
-     information.  */
+     information when responding to an input method.  */
   public static final boolean DEBUG_IC = false;
 
-  /* Flag that says whether or not to perform extra checks on threads
-     performing drawing calls.  */
+  /* Flag that says whether or not to stringently check that only the
+     Emacs thread is performing drawing calls.  */
   private static final boolean DEBUG_THREADS = false;
 
   /* Atomic integer used for synchronization between
diff --git a/src/androidterm.c b/src/androidterm.c
index 20a8860a913..466a99a1e28 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -774,6 +774,11 @@ android_handle_ime_event (union android_event *event, 
struct frame *f)
     }
 }
 
+
+
+/* Forward declaration.  */
+static void android_notify_conversion (unsigned long);
+
 static int
 handle_one_android_event (struct android_display_info *dpyinfo,
                          union android_event *event, int *finish,
@@ -1659,8 +1664,21 @@ handle_one_android_event (struct android_display_info 
*dpyinfo,
     case ANDROID_INPUT_METHOD:
 
       if (!any)
-       /* Free any text allocated for this event.  */
-       xfree (event->ime.text);
+       {
+         /* Free any text allocated for this event.  */
+         xfree (event->ime.text);
+
+         /* If edits associated with this event haven't been
+            processed yet, signal their completion to avoid delays
+            the next time a call to `android_sync_edit' is made.
+
+            If events for a deleted frame are interleaved with events
+            for another frame, the edit counter may be prematurely
+            incremented before edits associated with the other frames
+            are processed.  This is not a problem in practice.  */
+
+         android_notify_conversion (event->ime.counter);
+       }
       else
        android_handle_ime_event (event, any);
 
@@ -4585,10 +4603,12 @@ static void
 android_sync_edit (void)
 {
   struct timespec start, end, rem;
+  unsigned long counter;
+
+  counter = __atomic_load_n (&last_edit_counter,
+                            __ATOMIC_SEQ_CST);
 
-  if (__atomic_load_n (&last_edit_counter,
-                      __ATOMIC_SEQ_CST)
-      == edit_counter)
+  if (counter == edit_counter)
     return;
 
   start = current_timespec ();
@@ -5618,7 +5638,10 @@ NATIVE_NAME (requestCursorUpdates) (JNIEnv *env, jobject 
object,
   event.ime.length = mode;
   event.ime.position = 0;
   event.ime.text = NULL;
-  event.ime.counter = ++edit_counter;
+
+  /* Since this does not affect the state of the buffer text, there is
+     no need to apply synchronization to this event.  */
+  event.ime.counter = 0;
 
   android_write_event (&event);
 }



reply via email to

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