all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: 7802@debbugs.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	[thread overview]
Message-ID: <jwvsjwwenuh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <yyxtyhdv00z.fsf@fencepost.gnu.org> (Chong Yidong's message of "Thu, 13 Jan 2011 00:35:24 -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





  parent reply	other threads:[~2011-01-13 17:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-07 19:11 bug#7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3' Drew Adams
2011-01-07 19:20 ` bug#7802: bug #7802: " Drew Adams
2011-01-07 19:38   ` Drew Adams
2011-01-08  5:03     ` Stefan Monnier
2011-01-08  6:36       ` Drew Adams
2011-01-08 16:01         ` Jason Rumney
2011-01-08 17:22           ` Drew Adams
2011-01-09  3:34             ` Jason Rumney
2011-01-09 14:18               ` Drew Adams
2011-01-13  5:35               ` Chong Yidong
2011-01-13  7:15                 ` Drew Adams
2011-01-15  3:29                   ` Chong Yidong
2011-08-08 18:45                     ` Drew Adams
2011-08-08 20:52                       ` Chong Yidong
2011-01-13 17:32                 ` Stefan Monnier [this message]
2011-01-08 19:50 ` grischka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvsjwwenuh.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=7802@debbugs.gnu.org \
    --cc=cyd@stupidchicken.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.