From: Eli Zaretskii Date: Sun, 21 Nov 2021 17:07:10 +0000 (+0200) Subject: Fix positioning of pop-up menus when there are window-margins X-Git-Tag: emacs-29.0.90~2852^2~129 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b7db7eb2c7b8ac1bddf4afa9ccf9b30ebeb0224e;p=emacs.git 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) --- diff --git a/src/menu.c b/src/menu.c index ab01e1bfad2..96d1c5208a9 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,