]> git.eshelyaron.com Git - emacs.git/commitdiff
Better reproduce mouse event coalescence during touch event translation
authorPo Lu <luangruo@yahoo.com>
Tue, 23 Jul 2024 12:44:06 +0000 (20:44 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 23 Jul 2024 16:01:30 +0000 (18:01 +0200)
* lisp/touch-screen.el (touch-screen-handle-touch): Save the
confines of the current mouse glyph before initiating simple
translation.

(cherry picked from commit f521235656040dbae8406682976233f771c0c81c)

lisp/touch-screen.el

index ce9a5146bba99bf70a59401d4e2cbbdaace9dc63..756c82d5abe04fc2443085345e230bc9ffe1854d 100644 (file)
@@ -1728,8 +1728,26 @@ functions undertaking event management themselves to call
                     ;; `mouse-1-menu' instead and wait for the up
                     ;; event to display the menu.
                     (setcar (nthcdr 3 tool-list) 'mouse-1-menu)
-                  (progn (setcar (nthcdr 3 tool-list) 'mouse-drag)
-                         (throw 'input-event (list 'down-mouse-1 position))))
+                  (progn
+                    (setcar (nthcdr 3 tool-list) 'mouse-drag)
+                    ;; Record the extents of the glyph beneath this
+                    ;; touch point to avoid generating extraneous events
+                    ;; when it next moves.
+                    (setcar
+                     (nthcdr 5 touch-screen-current-tool)
+                     (let* ((edges (window-inside-pixel-edges window))
+                            (point (posn-x-y position))
+                            (frame-offsets (if (framep window)
+                                               '(0 . 0)
+                                             (cons (car edges)
+                                                   (cadr edges)))))
+                       (remember-mouse-glyph (or (and (framep window) window)
+                                                 (window-frame window))
+                                             (+ (car point)
+                                                (car frame-offsets))
+                                             (+ (cdr point)
+                                                (cdr frame-offsets)))))
+                    (throw 'input-event (list 'down-mouse-1 position))))
               (and point
                    ;; Start the long-press timer.
                    (touch-screen-handle-timeout nil)))))))