From 697cbac26e81457840f187399530b0f91adb1768 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Fri, 18 Nov 2022 09:24:55 +0100 Subject: [PATCH] Fix click position to menu bar entry with no-toolkit * src/keyboard.c (make_lispy_event): Use x_y_to_hpos_vpos to compute correct menu bar position should the menu face change. * src/xdisp.c (x_y_to_hpos_vpos): Not static anymore. * src/dispextern.h: Export x_y_to_hpos_vpos. --- src/dispextern.h | 2 ++ src/keyboard.c | 13 +++++++++++-- src/xdisp.c | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/dispextern.h b/src/dispextern.h index 2f5f4335fe..c59f594f9e 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3376,6 +3376,8 @@ #define TTY_CAP_STRIKE_THROUGH 0x20 struct glyph_row *row_containing_pos (struct window *, ptrdiff_t, struct glyph_row *, struct glyph_row *, int); +struct glyph *x_y_to_hpos_vpos (struct window *, int, int, int *, int *, + int *, int *, int *); int line_bottom_y (struct it *); int default_line_pixel_height (struct window *); bool display_prop_intangible_p (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); diff --git a/src/keyboard.c b/src/keyboard.c index 069cf0627b..5cc7209846 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5974,8 +5974,17 @@ make_lispy_event (struct input_event *event) in a menu (non-toolkit version). */ if (!toolkit_menubar_in_use (f)) { - pixel_to_glyph_coords (f, XFIXNUM (event->x), XFIXNUM (event->y), - &column, &row, NULL, 1); + int dummy; + + /* I guess this works because the menu bar is always + at position (0, 0) in a frame. Should this changed + and we need a way to calculate the correct position + into the menu bar from the position of the event in + the frame. */ + x_y_to_hpos_vpos (XWINDOW (f->menu_bar_window), + XFIXNUM (event->x), XFIXNUM (event->y), + &column, &row, + NULL, NULL, &dummy); /* In the non-toolkit version, clicks on the menu bar are ordinary button events in the event buffer. diff --git a/src/xdisp.c b/src/xdisp.c index f6a279636a..0c073c0fb5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -2330,7 +2330,7 @@ pixel_to_glyph_coords (struct frame *f, int pix_x, int pix_y, int *x, int *y, text, or we can't tell because W's current matrix is not up to date. */ -static struct glyph * +struct glyph * x_y_to_hpos_vpos (struct window *w, int x, int y, int *hpos, int *vpos, int *dx, int *dy, int *area) { -- 2.38.1