Skip to content

Commit 6556348

Browse files
committed
* lisp/help.el (help--read-key-sequence): Handle `switch-frame' events
If you do `C-h k ... mouse-1 in other frame` (at least if you have a focus that follows the mouse), then additionally to the down-mouse-1 and mouse-1 events, a `switch-frame` event (and `select-window` event as well sometimes) is generated. When `read-key-sequence` is called with nil for `can-return-switch-frame`, this event is not returned but kept for later, which causes a subsequent `sit-for` to return nil immediately. This interfered without our "wait for double-click" which in turn prevented us from stopping after the mouse-1 click, getting stuck waiting for something else instead. (help--read-key-sequence): Pass a non-nil `can-return-switch-frame`, so the subsequent `sit-for` returns more trustworthy information.
1 parent e8709e7 commit 6556348

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lisp/help.el

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ If NO-MOUSE-MOVEMENT is non-nil, ignore key sequences starting
745745
with `mouse-movement' events."
746746
(let ((enable-disabled-menus-and-buttons t)
747747
(cursor-in-echo-area t)
748+
(side-event nil)
748749
saved-yank-menu)
749750
(unwind-protect
750751
(let (last-modifiers key-list)
@@ -763,7 +764,8 @@ with `mouse-movement' events."
763764
(and (memq 'click last-modifiers)
764765
(not (sit-for (/ double-click-time 1000.0) t))))
765766
(let* ((seq (read-key-sequence "\
766-
Describe the following key, mouse click, or menu item: "))
767+
Describe the following key, mouse click, or menu item: "
768+
nil nil 'can-return-switch-frame))
767769
(raw-seq (this-single-command-raw-keys))
768770
(keyn (when (> (length seq) 0)
769771
(aref seq (1- (length seq)))))
@@ -772,11 +774,18 @@ Describe the following key, mouse click, or menu item: "))
772774
(cond
773775
((zerop (length seq))) ;FIXME: Can this happen?
774776
((and no-mouse-movement (eq base 'mouse-movement)) nil)
777+
((memq base '(mouse-movement switch-frame select-window))
778+
;; Mostly ignore these events since it's sometimes difficult to
779+
;; generate the event you care about without also generating
780+
;; these side-events along the way.
781+
(setq side-event (cons seq raw-seq)))
775782
((eq base 'help-echo) nil)
776783
(t
777784
(setq last-modifiers modifiers)
778785
(push (cons seq raw-seq) key-list)))))
779-
(nreverse key-list))
786+
(if side-event
787+
(cons side-event (nreverse key-list))
788+
(nreverse key-list)))
780789
;; Put yank-menu back as it was, if we changed it.
781790
(when saved-yank-menu
782791
(setq yank-menu (copy-sequence saved-yank-menu))

0 commit comments

Comments
 (0)