emacs-diffs
[Top][All Lists]
Advanced

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

feature/android 85e39e86b0b 2/2: Update Android port


From: Po Lu
Subject: feature/android 85e39e86b0b 2/2: Update Android port
Date: Mon, 17 Jul 2023 02:41:30 -0400 (EDT)

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

    Update Android port
    
    * doc/lispref/commands.texi (Touchscreen Events): Document
    meaning of `mouse-1-menu-command'.
    * lisp/mouse.el (minor-mode-menu-from-indicator): New arg EVENT.
    Give it to popup-menu.
    (mouse-minor-mode-menu): Use posn specified within EVENT.
    * lisp/touch-screen.el (touch-screen-handle-touch): Fix
    interactive translation.  Treat commands labeled
    `mouse-1-menu-command' like ordinary keymaps.
---
 doc/lispref/commands.texi | 34 +++++++++++++++++++++-------------
 lisp/mouse.el             | 12 +++++++++---
 lisp/touch-screen.el      | 25 ++++++++++++++-----------
 3 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index 74b57f58ee8..bcba3fe4026 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -2066,19 +2066,20 @@ However, some commands bound to
 conflict with defined touch screen gestures (such as ``long-press to
 drag''), or with user expectations for touch input, and shouldn't
 subject the touch sequence to simple translation.  If a command whose
-name contains the property @code{ignored-mouse-command} is encountered
-or there is no command bound to @code{down-mouse-1}, a more irregular
-form of translation takes place: here, Emacs processes touch screen
-gestures (@pxref{Touchscreens,,, emacs, The GNU Emacs Manual}) first,
-and finally attempts to translate touch screen events into mouse
-events if no gesture was detected prior to a closing
-@code{touchscreen-end} event and a command is bound to @code{mouse-1}
-at the location of that event.  Before generating the @code{mouse-1}
-event, point is also set to the location of the @code{touchscreen-end}
-event, and the window containing the position of that event is
-selected, as a compromise for packages which assume
-@code{mouse-drag-region} has already set point to the location of any
-mouse click and selected the window where it took place.
+name contains the property (@pxref{Symbol Properties})
+@code{ignored-mouse-command} is encountered or there is no command
+bound to @code{down-mouse-1}, a more irregular form of translation
+takes place: here, Emacs processes touch screen gestures
+(@pxref{Touchscreens,,, emacs, The GNU Emacs Manual}) first, and
+finally attempts to translate touch screen events into mouse events if
+no gesture was detected prior to a closing @code{touchscreen-end}
+event and a command is bound to @code{mouse-1} at the location of that
+event.  Before generating the @code{mouse-1} event, point is also set
+to the location of the @code{touchscreen-end} event, and the window
+containing the position of that event is selected, as a compromise for
+packages which assume @code{mouse-drag-region} has already set point
+to the location of any mouse click and selected the window where it
+took place.
 
 To prevent unwanted @code{mouse-1} events arriving after a mouse menu
 is dismissed (@pxref{Mouse Menus}), Emacs also avoids simple
@@ -2088,6 +2089,13 @@ prefix key.  In lieu of simple translation, it 
translates the closing
 starting position of the touch sequence, consequentially displaying
 the mouse menu.
 
+@cindex @code{mouse-1-menu-command}, a symbol property
+Since certain commands are also bound to @code{down-mouse-1} for the
+purpose of displaying pop-up menus, Emacs additionally behaves as
+illustrated in the last paragraph if @code{down-mouse-1} is bound to a
+command whose name has the property @code{mouse-1-menu-command}.
+
+@cindex touchscreen gesture events
 If touch gestures are detected during translation, one of the
 following input events may be generated:
 
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 3c30361ad7d..50c10880da7 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -206,8 +206,11 @@ always return a positive integer or zero."
 
 ;; Provide a mode-specific menu on a mouse button.
 
-(defun minor-mode-menu-from-indicator (indicator)
+(defun minor-mode-menu-from-indicator (indicator &optional event)
   "Show menu for minor mode specified by INDICATOR.
+EVENT may be the mouse event that is causing this menu to be
+displayed.
+
 Interactively, INDICATOR is read using completion.
 If there is no menu defined for the minor mode, then create one with
 items `Turn Off' and `Help'."
@@ -234,14 +237,17 @@ items `Turn Off' and `Help'."
                           ,(lambda () (interactive)
                              (describe-function mm-fun)))))))
       (if menu
-          (popup-menu menu)
+          (popup-menu menu event)
         (message "No menu available")))))
 
 (defun mouse-minor-mode-menu (event)
   "Show minor-mode menu for EVENT on minor modes area of the mode line."
   (interactive "@e")
   (let ((indicator (car (nth 4 (car (cdr event))))))
-    (minor-mode-menu-from-indicator indicator)))
+    (minor-mode-menu-from-indicator indicator event)))
+
+;; See (elisp)Touchscreen Events.
+(put 'mouse-minor-mode-menu 'mouse-1-menu-command t)
 
 (defun mouse-menu-major-mode-map ()
   (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
diff --git a/lisp/touch-screen.el b/lisp/touch-screen.el
index 7d733bdb77f..1ef66d0043f 100644
--- a/lisp/touch-screen.el
+++ b/lisp/touch-screen.el
@@ -767,12 +767,13 @@ the place of EVENT within the key sequence being 
translated, or
   (if interactive
       ;; Called interactively (probably from wid-edit.el.)
       ;; Add any event generated to `unread-command-events'.
-      (let ((event (catch 'input-event
-                     (touch-screen-translate-touch nil) nil)))
-        (when (vectorp event)
+      (let ((event1
+             (let ((current-key-remap-sequence (vector event)))
+               (touch-screen-translate-touch nil))))
+        (when (vectorp event1)
           (setq unread-command-events
                 (nconc unread-command-events
-                       (nreverse (append event nil))))))
+                       (nreverse (append event1 nil))))))
     (cond
      ((eq (car event) 'touchscreen-begin)
       ;; A tool was just pressed against the screen.  Figure out the
@@ -816,13 +817,15 @@ the place of EVENT within the key sequence being 
translated, or
                                            t nil position))
                         (not (and (symbolp binding)
                                   (get binding 'ignored-mouse-command))))))
-            (if (keymapp binding)
-                ;; binding is a keymap.  If a `mouse-1' event is
-                ;; generated after the keyboard command loop displays
-                ;; it as a menu, that event could cause unwanted
-                ;; commands to be run.  Set what to `mouse-1-menu'
-                ;; instead and wait for the up event to display the
-                ;; menu.
+            (if (or (keymapp binding)
+                    (and (symbolp binding)
+                         (get binding 'mouse-1-menu-command)))
+                ;; binding is a keymap, or a command that does almost
+                ;; the same thing.  If a `mouse-1' event is generated
+                ;; after the keyboard command loop displays it as a
+                ;; menu, that event could cause unwanted commands to
+                ;; be run.  Set what to `mouse-1-menu' instead and
+                ;; wait for the up event to display the menu.
                 (setcar (nthcdr 3 touch-screen-current-tool)
                         'mouse-1-menu)
               (progn (setcar (nthcdr 3 touch-screen-current-tool)



reply via email to

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