]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix earlier changes to keyboard.c
authorPo Lu <luangruo@yahoo.com>
Sat, 19 Nov 2022 03:13:15 +0000 (11:13 +0800)
committerPo Lu <luangruo@yahoo.com>
Sat, 19 Nov 2022 03:13:15 +0000 (11:13 +0800)
* src/keyboard.c (coords_in_menu_bar_window): New function.
(make_lispy_event): Do not process menu bar events on window
system frames if there is no menu bar window or the click lies
outside.

src/keyboard.c

index c0642ab53a470accf010167a29f628d361505f2e..811998823ccc30555b35a2903dd01f09f057cbe1 100644 (file)
@@ -5720,6 +5720,29 @@ make_scroll_bar_position (struct input_event *ev, Lisp_Object type)
                builtin_lisp_symbol (scroll_bar_parts[ev->part]));
 }
 
+#if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
+
+/* Return whether or not the coordinates X and Y are inside the
+   box of the menu-bar window of frame F.  */
+
+static bool
+coords_in_menu_bar_window (struct frame *f, int x, int y)
+{
+  struct window *window;
+
+  if (!WINDOWP (f->menu_bar_window))
+    return false;
+
+  window = XWINDOW (f->menu_bar_window);
+
+  return (y >= WINDOW_TOP_EDGE_Y (window)
+         && x >= WINDOW_LEFT_EDGE_X (window)
+         && y <= WINDOW_BOTTOM_EDGE_Y (window)
+         && x <= WINDOW_RIGHT_EDGE_X (window));
+}
+
+#endif
+
 /* Given a struct input_event, build the lisp event which represents
    it.  If EVENT is 0, build a mouse movement event from the mouse
    movement buffer, which should have a movement event in it.
@@ -5972,7 +5995,15 @@ make_lispy_event (struct input_event *event)
               and ROW are set to frame relative glyph coordinates
               which are then used to determine whether this click is
               in a menu (non-toolkit version).  */
-           if (!toolkit_menubar_in_use (f))
+           if (!toolkit_menubar_in_use (f)
+#if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
+               /* Don't process events for menu bars if they are not
+                  in the menu bar window.  */
+               && (!FRAME_WINDOW_P (f)
+                   || coords_in_menu_bar_window (f, XFIXNUM (event->x),
+                                                 XFIXNUM (event->y)))
+#endif
+               )
              {
 #if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
                if (FRAME_WINDOW_P (f))
@@ -5999,7 +6030,7 @@ make_lispy_event (struct input_event *event)
                   menu bar and Emacs doesn't know about it until
                   after the user makes a selection.)  */
                if (row >= 0 && row < FRAME_MENU_BAR_LINES (f)
-                 && (event->modifiers & down_modifier))
+                   && (event->modifiers & down_modifier))
                  {
                    Lisp_Object items, item;