emacs-diffs
[Top][All Lists]
Advanced

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

master b7db7eb: Fix positioning of pop-up menus when there are window-ma


From: Eli Zaretskii
Subject: master b7db7eb: Fix positioning of pop-up menus when there are window-margins
Date: Sun, 21 Nov 2021 12:08:18 -0500 (EST)

branch: master
commit b7db7eb2c7b8ac1bddf4afa9ccf9b30ebeb0224e
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix positioning of pop-up menus when there are window-margins
    
    * src/menu.c (x_popup_menu_1): Calculate X and Y correctly for
    clicks in the text area.  (Bug#51782)
---
 src/menu.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/menu.c b/src/menu.c
index ab01e1b..96d1c52 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1113,7 +1113,7 @@ into menu items.  */)
 Lisp_Object
 x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
 {
-  Lisp_Object keymap, tem, tem2;
+  Lisp_Object keymap, tem, tem2 = Qnil;
   int xpos = 0, ypos = 0;
   Lisp_Object title;
   const char *error_name = NULL;
@@ -1252,8 +1252,21 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
        CHECK_LIVE_WINDOW (window);
        f = XFRAME (WINDOW_FRAME (win));
 
-       xpos = WINDOW_LEFT_EDGE_X (win);
-       ypos = WINDOW_TOP_EDGE_Y (win);
+       if (FIXNUMP (tem2))
+         {
+           /* Clicks in the text area, where TEM2 is a buffer
+              position, are relative to the top-left edge of the text
+              area, see keyboard.c:make_lispy_position.  */
+           xpos = window_box_left (win, TEXT_AREA);
+           ypos = (WINDOW_TOP_EDGE_Y (win)
+                   + WINDOW_TAB_LINE_HEIGHT (win)
+                   + WINDOW_HEADER_LINE_HEIGHT (win));
+         }
+       else
+         {
+           xpos = WINDOW_LEFT_EDGE_X (win);
+           ypos = WINDOW_TOP_EDGE_Y (win);
+         }
       }
     else
       /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,



reply via email to

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