diff options
author | Po Lu <luangruo@yahoo.com> | 2022-11-19 11:13:15 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-11-19 11:13:15 +0800 |
commit | b23a4a15055af504324c3a60e5c6cbd93becf9b0 (patch) | |
tree | d36fdf741043ca308b5a858e448d30aa2faad3ce /src/keyboard.c | |
parent | 4921bd7bac4a9609c00e6b3337a4962b46135ff3 (diff) | |
download | emacs-b23a4a15055af504324c3a60e5c6cbd93becf9b0.tar.gz |
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.
Diffstat (limited to 'src/keyboard.c')
-rw-r--r-- | src/keyboard.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index c0642ab53a4..811998823cc 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; |