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)
This commit is contained in:
Eli Zaretskii 2021-11-21 19:07:10 +02:00
parent 85f193b613
commit b7db7eb2c7

View file

@ -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,