From 6776d6899ba029f45ad76b8bb2a9f3dcd1fcac52 Mon Sep 17 00:00:00 2001 From: Jared Finder Date: Sun, 11 Oct 2020 20:16:00 -0700 Subject: [PATCH] Fixing 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 22fae028d3..79689f8cc2 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -2662,14 +2662,14 @@ menu-bar-open (global-set-key [f10] 'menu-bar-open) -(defun menu-bar-open-mouse (event) +(defun menu-bar-open-mouse (position) "Open the menu bar for the menu item clicked on by the mouse. -EVENT should be a mouse down or click event. +POSITION should be a list of the form returned by `mouse-position'. Also see `menu-bar-open', which this calls. This command is to be used when you click the mouse in the menubar." - (interactive "e") - (let* ((x-position (car (posn-x-y (event-start event)))) + (interactive (list (mouse-position))) + (let* ((x-position (cadr position)) (menu-bar-item-cons (menu-bar-item-at-x x-position))) (menu-bar-open nil (if menu-bar-item-cons -- 2.20.1