GNU bug report logs - #7802
24.0.50; Extraneous `mouse-3' event when do `double-mouse-3'

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Fri, 7 Jan 2011 19:05:01 UTC

Severity: wishlist

Found in version 24.0.50

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 7802 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>, Jason Rumney <jasonr <at> gnu.org>
Subject: bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3'
Date: Thu, 13 Jan 2011 12:32:40 -0500
> It's cleaner to let the calling Elisp code worry about this.  That is to
> say, the caller can bind the first click to a command that starts up a
> timer to execute the "single click" action after a short period, and
> bind the double click to a command that cancels that timer.

Admittedly, this is pretty delicate to do right:
- if nothing happens during those 500ms, run the timer.  O, that's the
  easy case.
- if a second clicks comes in before those 500ms cancel the timer.
  First difficulty: where do you put the code that cancels the timer?
- if another event like a click on another mouse button, or a keyboard
  key comes in before the 500ms, we should be careful to run the click
  command immediately (i.e. neither let the timer finish,
  not just cancel it outright).  And don't wait for this second event to
  complete to a key-sequence bound to a command (i.e. run the click
  command as soon as a C-x comes in, for example).
- but if that second event is a mouse-movement, we should not do anything.

I think the best place to put such code is somewhere around
function-key-map.  Just like down-mouse-N can be dropped and
double-mouse-N can be demoted to just mouse-N, we could turn mouse-N
events that aren't bound to new single-mouse-N events.  I guess we could
do it with code along the lines of:

  [Check that there's no mouse-N binding, but there is a single-mouse-N
   binding in the active key maps]
  (let ((event
         (catch 'timeout
           (let ((timer
                  (run-with-timer 0.5 nil
                                  (lambda () (throw 'timeout 'timeout)))))
             (unwind-protect
                 (let (event)
                   (while (progn
                            (setq event (read-event))
                            (not (memq event '(mouse-movement))))) ; Any other?
                   event)
               (cancel timer))))))
    (cond
     ((eq event 'timeout) [single-mouse-N])
     ((eq event 'down-mouse-N)
      (push event unread-command-events)
      [])
     (t
      (push event unread-command-events)
      [single-mouse-N])))


-- Stefan




This bug report was last modified 13 years and 312 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.