emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2c487c4: Fix a bug where the wrong menu would be triggered by mou


From: Eli Zaretskii
Subject: master 2c487c4: Fix a bug where the wrong menu would be triggered by mouse
Date: Sat, 24 Oct 2020 06:30:45 -0400 (EDT)

branch: master
commit 2c487c47c8c3060818b2fcbfebbcd859f9d06ef5
Author: Jared Finder <jared@finder.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    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.
---
 lisp/menu-bar.el | 6 ++++++
 lisp/xt-mouse.el | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index e426023..f9afc8a 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -2672,6 +2672,12 @@ EVENT should be a mouse down or click event.
 Also see `menu-bar-open', which this calls.
 This command is to be used when you click the mouse in the menubar."
   (interactive "e")
+  ;; This only should be bound to clicks on the menu-bar, outside of
+  ;; any window.
+  (let ((window (posn-window (event-start event))))
+    (when window
+      (error "Event is inside window %s" window)))
+
   (let* ((x-position (car (posn-x-y (event-start event))))
          (menu-bar-item-cons (menu-bar-item-at-x x-position)))
     (menu-bar-open nil
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 3c0dfb6..f9c08f9 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -267,7 +267,7 @@ which is the \"1006\" extension implemented in Xterm >= 
277."
                                                     (eq y 1)))
                                            'tab-bar
                                          'menu-bar))
-                             (nthcdr 2 (posn-at-x-y x y)))))
+                             (nthcdr 2 (posn-at-x-y x y (selected-frame))))))
              (event (list type posn)))
         (setcar (nthcdr 3 posn) timestamp)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]