From 7cd11a71fa8d02b9f7115d76b440905b778c398b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 18 Jul 2023 13:24:55 +0800 Subject: [PATCH] Avoid splurious menu-bar nil events * src/keyboard.c (make_lispy_event): Return nil if no menu item is found. --- src/keyboard.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/keyboard.c b/src/keyboard.c index a65d706ee2d..97172be8152 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6222,6 +6222,11 @@ make_lispy_event (struct input_event *event) } } + /* Don't generate a menu bar event if ITEM is + nil. */ + if (NILP (item)) + return Qnil; + /* ELisp manual 2.4b says (x y) are window relative but code says they are frame-relative. */ @@ -6566,6 +6571,10 @@ make_lispy_event (struct input_event *event) #endif /* HAVE_WINDOW_SYSTEM */ f = XFRAME (event->frame_or_window); + + if (!FRAME_LIVE_P (f)) + return Qnil; + id = event->arg; x = event->x; y = event->y; @@ -6641,6 +6650,9 @@ make_lispy_event (struct input_event *event) bool close; #endif /* HAVE_WINDOW_SYSTEM */ + if (!FRAME_LIVE_P (f)) + return Qnil; + id = event->arg; x = event->x; y = event->y; @@ -6680,6 +6692,11 @@ make_lispy_event (struct input_event *event) } } + /* Don't generate a menu bar event if ITEM is + nil. */ + if (NILP (item)) + return Qnil; + /* ELisp manual 2.4b says (x y) are window relative but code says they are frame-relative. */ @@ -6769,6 +6786,9 @@ make_lispy_event (struct input_event *event) struct frame *f = XFRAME (event->frame_or_window); evt = Qnil; + if (!FRAME_LIVE_P (f)) + return Qnil; + for (tem = event->arg; CONSP (tem); tem = XCDR (tem)) { it = XCAR (tem); @@ -6777,10 +6797,19 @@ make_lispy_event (struct input_event *event) y = XCAR (XCDR (it)); id = XCAR (XCDR (XCDR (it))); + /* Don't report touches to the menu bar. */ + if (EQ (id, menu_bar_touch_id)) + continue; + position = make_lispy_position (f, x, y, event->timestamp); evt = Fcons (Fcons (id, position), evt); } + if (NILP (evt)) + /* Don't return an event if the touchpoint list is + empty. */ + return Qnil; + return list2 (Qtouchscreen_update, evt); } -- 2.39.2