[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b23a4a1505 1/3: Fix earlier changes to keyboard.c
From: |
Po Lu |
Subject: |
master b23a4a1505 1/3: Fix earlier changes to keyboard.c |
Date: |
Sat, 19 Nov 2022 01:03:49 -0500 (EST) |
branch: master
commit b23a4a15055af504324c3a60e5c6cbd93becf9b0
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Fix earlier changes to keyboard.c
* 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 | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/keyboard.c b/src/keyboard.c
index c0642ab53a..811998823c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -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;