emacs-diffs
[Top][All Lists]
Advanced

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

feature/android c74bab6067c: Update Android port


From: Po Lu
Subject: feature/android c74bab6067c: Update Android port
Date: Tue, 14 Mar 2023 22:07:33 -0400 (EDT)

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

    Update Android port
    
    * doc/lispref/commands.texi (Misc Events): Document variable
    `disable-inhibit-text-conversion'.
    * java/org/gnu/emacs/EmacsDialog.java (display1): Try an
    activity that is certain to be focused first.
    * lisp/touch-screen.el (touch-screen-track-tap)
    (touch-screen-track-drag): Bind
    `disable-inhibit-text-conversion'.
    * src/keyboard.c (read_key_sequence): Only disable text
    conversion if an actual function or numeric key is found in the
    key sequence.
    (syms_of_keyboard): New variable
    `disable-inhibit-text-conversion'.
    * src/lread.c (read_filtered_event): Check new variable.
    * src/textconv.c (textconv_query): Remove unused label.
---
 doc/lispref/commands.texi           |  6 ++++++
 java/org/gnu/emacs/EmacsDialog.java | 19 ++++++++++-------
 lisp/touch-screen.el                | 32 +++++++++++++++-------------
 src/keyboard.c                      | 42 ++++++++++++++++++++++++-------------
 src/lread.c                         |  5 +++--
 src/textconv.c                      |  2 --
 6 files changed, 64 insertions(+), 42 deletions(-)

diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index 271a6d15aa1..4a3ff1b5d25 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -2263,6 +2263,12 @@ that takes immediate effect, call the function
 lock up the input method for a significant amount of time, so do
 not do this lightly!
 
+@vindex disable-inhibit-text-conversion
+In addition, text conversion is automatically disabled after a prefix
+key is read by the command loop, or through @code{read-key-sequence}.
+This can be disabled by setting or binding the variable
+@code{disable-inhibit-text-conversion} to a non-@code{nil} value.
+
 @cindex @code{delete-frame} event
 @item (delete-frame (@var{frame}))
 This kind of event indicates that the user gave the window manager
diff --git a/java/org/gnu/emacs/EmacsDialog.java 
b/java/org/gnu/emacs/EmacsDialog.java
index de5a37bd5c5..3a5f22021fc 100644
--- a/java/org/gnu/emacs/EmacsDialog.java
+++ b/java/org/gnu/emacs/EmacsDialog.java
@@ -244,23 +244,26 @@ public final class EmacsDialog implements 
DialogInterface.OnDismissListener
     AlertDialog dialog;
     Window window;
 
-    /* First, try to display a dialog using the service context.  */
-
-    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
-       || Settings.canDrawOverlays (EmacsService.SERVICE))
-      context = EmacsService.SERVICE;
-    else if (EmacsActivity.focusedActivities.isEmpty ())
+    if (EmacsActivity.focusedActivities.isEmpty ())
       {
        /* If focusedActivities is empty then this dialog may have
           been displayed immediately after a popup dialog is
-          dismissed.  */
+          dismissed.  Or Emacs might legitimately be in the
+          background.  Try the service context first if possible.  */
 
-       context = EmacsActivity.lastFocusedActivity;
+       if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
+           || Settings.canDrawOverlays (EmacsService.SERVICE))
+         context = EmacsService.SERVICE;
+       else
+         context = EmacsActivity.lastFocusedActivity;
 
        if (context == null)
          return false;
       }
     else
+      /* Display using the activity context when Emacs is in the
+        foreground, as this allows the dialog to be dismissed more
+        consistently.  */
       context = EmacsActivity.focusedActivities.get (0);
 
     Log.d (TAG, "display1: using context " + context);
diff --git a/lisp/touch-screen.el b/lisp/touch-screen.el
index 3d542d78b1d..31d46b062ed 100644
--- a/lisp/touch-screen.el
+++ b/lisp/touch-screen.el
@@ -511,20 +511,21 @@ with that event and DATA.
 
 Return nil immediately if any other kind of event is received;
 otherwise, return t once the `touchscreen-end' event arrives."
-  (catch 'finish
-    (while t
-      (let ((new-event (read-event nil)))
-        (cond
-         ((eq (car-safe new-event) 'touchscreen-update)
-          (when (and update (assq (caadr event) (cadr new-event)))
-            (funcall update new-event data)))
-         ((eq (car-safe new-event) 'touchscreen-end)
-          (throw 'finish
-                 ;; Now determine whether or not the `touchscreen-end'
-                 ;; event has the same ID as EVENT.  If it doesn't,
-                 ;; then this is another touch, so return nil.
-                 (eq (caadr event) (caadr new-event))))
-         (t (throw 'finish nil)))))))
+  (let ((disable-inhibit-text-conversion t))
+    (catch 'finish
+      (while t
+        (let ((new-event (read-event nil)))
+          (cond
+           ((eq (car-safe new-event) 'touchscreen-update)
+            (when (and update (assq (caadr event) (cadr new-event)))
+              (funcall update new-event data)))
+           ((eq (car-safe new-event) 'touchscreen-end)
+            (throw 'finish
+                   ;; Now determine whether or not the `touchscreen-end'
+                   ;; event has the same ID as EVENT.  If it doesn't,
+                   ;; then this is another touch, so return nil.
+                   (eq (caadr event) (caadr new-event))))
+           (t (throw 'finish nil))))))))
 
 (defun touch-screen-track-drag (event update &optional data)
   "Track a single drag starting from EVENT.
@@ -543,7 +544,8 @@ otherwise, return either t or `no-drag' once the
 touch point in EVENT did not move significantly, and t otherwise."
   (let ((return-value 'no-drag)
         (start-xy (touch-screen-relative-xy (cdadr event)
-                                            'frame)))
+                                            'frame))
+        (disable-inhibit-text-conversion t))
     (catch 'finish
       (while t
         (let ((new-event (read-event nil)))
diff --git a/src/keyboard.c b/src/keyboard.c
index 11c37372db7..aa7c81f48f1 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10227,33 +10227,38 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object 
prompt,
 
 #ifdef HAVE_TEXT_CONVERSION
       /* When reading a key sequence while text conversion is in
-        effect, turn it off after the first character read.  This
-        makes input methods send actual key events instead.
+        effect, turn it off after the first actual character read.
+        This makes input methods send actual key events instead.
 
          Make sure only to do this once.  Also, disabling text
          conversion seems to interact badly with menus, so don't
          disable text conversion if a menu was displayed.  */
 
-      if (!disabled_conversion && t && !used_mouse_menu)
+      if (!disabled_conversion && t && !used_mouse_menu
+         && !disable_inhibit_text_conversion)
        {
          int i;
 
          /* used_mouse_menu isn't set if a menu bar prefix key has
-            just been stored.  It appears necessary to look for the
-            prefix key itself.  */
+            just been stored.  It appears necessary to look for a
+            prefix key itself.  Don't look through too many keys for
+            efficiency reasons.  */
 
-         for (i = 0; i < t; ++i)
+         for (i = 0; i < min (t, 10); ++i)
            {
-             if (EQ (keybuf[i], Qmenu_bar))
-               break;
+             if (NUMBERP (keybuf[i])
+                 || (SYMBOLP (keybuf[i])
+                     && EQ (Fget (keybuf[i], Qevent_kind),
+                            Qfunction_key)))
+               goto disable_text_conversion;
            }
 
-         if (i == t)
-           {
-             disable_text_conversion ();
-             record_unwind_protect_void (resume_text_conversion);
-             disabled_conversion = true;
-           }
+         goto replay_key;
+
+       disable_text_conversion:
+         disable_text_conversion ();
+         record_unwind_protect_void (resume_text_conversion);
+         disabled_conversion = true;
        }
 #endif
 
@@ -13377,9 +13382,16 @@ which see.  */);
   DEFVAR_LISP ("post-select-region-hook", Vpost_select_region_hook,
     doc: /* Abnormal hook run after the region is selected.
 This usually happens as a result of `select-active-regions'.  The hook
-is called with one argument, the string that was selected.  */);;
+is called with one argument, the string that was selected.  */);
   Vpost_select_region_hook = Qnil;
 
+  DEFVAR_LISP ("disable-inhibit-text-conversion",
+              disable_inhibit_text_conversion,
+    doc: /* Don't disable text conversion inside `read-key-sequence'.
+If non-nil, text conversion will continue to happen after a prefix
+key has been read inside `read-key-sequence'.  */);
+    disable_inhibit_text_conversion = false;
+
   pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper);
 }
 
diff --git a/src/lread.c b/src/lread.c
index 1e6e306a851..c29c7ede6ac 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -798,7 +798,7 @@ static void substitute_in_interval (INTERVAL, void *);
 
    If text conversion is enabled and ASCII_REQUIRED && ERROR_NONASCII,
    temporarily disable any input method which wants to perform
-   edits.  */
+   edits, unless `disable-inhibit-text-conversion'.  */
 
 static Lisp_Object
 read_filtered_event (bool no_switch_frame, bool ascii_required,
@@ -821,7 +821,8 @@ read_filtered_event (bool no_switch_frame, bool 
ascii_required,
   /* Don't use text conversion when trying to just read a
      character.  */
 
-  if (ascii_required && error_nonascii)
+  if (ascii_required && error_nonascii
+      && !disable_inhibit_text_conversion)
     {
       disable_text_conversion ();
       record_unwind_protect_void (resume_text_conversion);
diff --git a/src/textconv.c b/src/textconv.c
index 91f6e861c60..a4e3116fb68 100644
--- a/src/textconv.c
+++ b/src/textconv.c
@@ -231,8 +231,6 @@ textconv_query (struct frame *f, struct 
textconv_callback_struct *query,
        }
     }
 
- escape:
-
   /* If pos is outside the accessible part of the buffer or if it
      overflows, move back to point or to the extremes of the
      accessible region.  */



reply via email to

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