Subject: bug#28658: closed (Re: bug#28658: 27.0.50; [PATCH] double/triple clicking in xterm-mouse-mode doesn't respect mouse position)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 08 Oct 2017 23:46:01 +0000

Your bug report

#28658: 27.0.50; [PATCH] double/triple clicking in xterm-mouse-mode doesn't respect mouse position

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
28658: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=28658
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#28658: 27.0.50; [PATCH] double/triple clicking in xterm-mouse-mode doesn't respect mouse position
From: Alex <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked]
Date: Sun, 08 Oct 2017 17:44:52 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Eli Zaretskii <[email-masked]> writes:

> LGTM, thanks.  Please mention the bug number in the log message when
> you push (to the emacs-26 branch).

Pushed.

Subject: 27.0.50; [PATCH] double/triple clicking in xterm-mouse-mode doesn't respect mouse position
From: Alex <[email-masked]>
To: [email-masked]
Date: Sat, 30 Sep 2017 16:06:34 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

1. emacs -Q -nw
2. M-x xterm-mouse-mode RET
3. Click once, then quickly move the cursor to a different word and click again.
4. Notice that the 2nd click was registered as a double click even
though the cursor moved.
5. Click once, and quickly perform step 3 again. Notice that the 3rd
click was registered as a triple click even though the cursor moved.

I've attached a patch that fixes this behaviour. It would be nice if it
worked with pixel positions rather than character positions, but I'm not
sure how to do that in a terminal Emacs.

>From 77590f427ba962f5efc3f07d2e4dcadb4ec1237d Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <[email-masked]>
Date: Sat, 30 Sep 2017 15:47:56 -0600
Subject: [PATCH] Increase xterm click count only with unchanged point

* lisp/xt-mouse.el (xterm-mouse-event): Save the last click's position
and check it against the current click's position.
---
 lisp/xt-mouse.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 772a72d5c5..dc202e78f6 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -278,6 +278,8 @@ xterm-mouse-event
                (last-name (symbol-name last-type))
                (last-time (nth 1 last-click))
                (click-count (nth 2 last-click))
+               (last-x (nth 3 last-click))
+               (last-y (nth 4 last-click))
                (this-time (float-time))
                (name (symbol-name type)))
           (cond
@@ -290,12 +292,14 @@ xterm-mouse-event
               (xterm-mouse--set-click-count event click-count)))
            ((not last-time) nil)
            ((and (> double-click-time (* 1000 (- this-time last-time)))
+                 (eq x last-x)
+                 (eq y last-y)
                  (equal last-name (replace-match "" t t name)))
             (setq click-count (1+ click-count))
             (xterm-mouse--set-click-count event click-count))
            (t (setq click-count 1)))
           (set-terminal-parameter nil 'xterm-mouse-last-click
-                                  (list type this-time click-count)))
+                                  (list type this-time click-count x y)))
 
         (set-terminal-parameter nil 'xterm-mouse-x x)
         (set-terminal-parameter nil 'xterm-mouse-y y)
-- 
2.14.1