aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Finder2020-10-11 20:16:00 -0700
committerEli Zaretskii2020-10-24 13:26:56 +0300
commit2c487c47c8c3060818b2fcbfebbcd859f9d06ef5 (patch)
tree0d72868c70492411ee43d8fc786b9e52192ffc6e
parent92d37029a755e7f610c3bc10c816763c5d853d2f (diff)
downloademacs-2c487c47c8c3060818b2fcbfebbcd859f9d06ef5.tar.gz
emacs-2c487c47c8c3060818b2fcbfebbcd859f9d06ef5.zip
Fix a bug where the wrong menu would be triggered by mouse
For layouts such as the following, clicking the "l" in Tools with the right window focused would trigger the File menu, not the Tools menu. This is because the event would have window coordinate (1 . 0). Similarly, clicking the "p" in Help would trigger the Edit menu. Example Emacs frame: +--------------------------------------------------------+ |File Edit Options Buffers Tools Help | |;; This buffer is for text$|;; This buffer is for text $| |;; To create a file, visit$|;; To create a file, visit $| | | | | | | |-UUU:----F1 *scratch* |-UUU:----F1 *scratch* | | | +--------------------------------------------------------+ * lisp/menu-bar.el (menu-bar-open-mouse): Reject clicks not on the menu bar. *lisp/xt-mouse.el (xterm-mouse-event): Pass the current frame to 'posn-at-x-y', to make the effect consistent with other mouse-handling features.
-rw-r--r--lisp/menu-bar.el6
-rw-r--r--lisp/xt-mouse.el2
2 files changed, 7 insertions, 1 deletions
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index e42602364d2..f9afc8a5f31 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -2672,6 +2672,12 @@ EVENT should be a mouse down or click event.
2672Also see `menu-bar-open', which this calls. 2672Also see `menu-bar-open', which this calls.
2673This command is to be used when you click the mouse in the menubar." 2673This command is to be used when you click the mouse in the menubar."
2674 (interactive "e") 2674 (interactive "e")
2675 ;; This only should be bound to clicks on the menu-bar, outside of
2676 ;; any window.
2677 (let ((window (posn-window (event-start event))))
2678 (when window
2679 (error "Event is inside window %s" window)))
2680
2675 (let* ((x-position (car (posn-x-y (event-start event)))) 2681 (let* ((x-position (car (posn-x-y (event-start event))))
2676 (menu-bar-item-cons (menu-bar-item-at-x x-position))) 2682 (menu-bar-item-cons (menu-bar-item-at-x x-position)))
2677 (menu-bar-open nil 2683 (menu-bar-open nil
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 3c0dfb65ecf..f9c08f9a174 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -267,7 +267,7 @@ which is the \"1006\" extension implemented in Xterm >= 277."
267 (eq y 1))) 267 (eq y 1)))
268 'tab-bar 268 'tab-bar
269 'menu-bar)) 269 'menu-bar))
270 (nthcdr 2 (posn-at-x-y x y))))) 270 (nthcdr 2 (posn-at-x-y x y (selected-frame))))))
271 (event (list type posn))) 271 (event (list type posn)))
272 (setcar (nthcdr 3 posn) timestamp) 272 (setcar (nthcdr 3 posn) timestamp)
273 273