]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix click position to menu bar entry with no-toolkit
authorManuel Giraud <manuel@ledu-giraud.fr>
Fri, 18 Nov 2022 08:24:55 +0000 (09:24 +0100)
committerPo Lu <luangruo@yahoo.com>
Sat, 19 Nov 2022 00:22:45 +0000 (08:22 +0800)
* 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
src/keyboard.c
src/xdisp.c

index 2f5f4335fe593789f8563b50f930ed6a2805ad36..2afbdeabaab9c20ba4f89707eab748c69a3fc6a3 100644 (file)
@@ -3495,7 +3495,8 @@ extern bool cursor_in_mouse_face_p (struct window *w);
 extern void tty_draw_row_with_mouse_face (struct window *, struct glyph_row *,
                                          int, int, enum draw_glyphs_face);
 extern void display_tty_menu_item (const char *, int, int, int, int, bool);
-
+extern struct glyph *x_y_to_hpos_vpos (struct window *, int, int, int *, int *,
+                                      int *, int *, int *);
 /* Flags passed to try_window.  */
 #define TRY_WINDOW_CHECK_MARGINS       (1 << 0)
 #define TRY_WINDOW_IGNORE_FONTS_CHANGE (1 << 1)
index 069cf0627b251d2d4e9a4f016d90fe7816e7e88c..6ce6ce17f27f0f538f340b56ff614a70e075153f 100644 (file)
@@ -5974,8 +5974,22 @@ 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);
+#if defined HAVE_WINDOW_SYSTEM
+               if (FRAME_WINDOW_P (f))
+                 {
+                   struct window *menu_w = XWINDOW (f->menu_bar_window);
+                   int x, y, dummy;
+
+                   x = FRAME_TO_WINDOW_PIXEL_X (menu_w, XFIXNUM (event->x));
+                   y = FRAME_TO_WINDOW_PIXEL_Y (menu_w, XFIXNUM (event->y));
+
+                   x_y_to_hpos_vpos (XWINDOW (f->menu_bar_window), x, y, &column, &row,
+                                     NULL, NULL, &dummy);
+                 }
+               else
+#endif
+                 pixel_to_glyph_coords (f, XFIXNUM (event->x), XFIXNUM (event->y),
+                                        &column, &row, NULL, 1);
 
                /* In the non-toolkit version, clicks on the menu bar
                   are ordinary button events in the event buffer.
index f8fc0f57873b01badb82ca9b8bf737cfdb48df27..b5f013ea6a18066598aed9baafddc357edeb2858 100644 (file)
@@ -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)
 {