From 70d63ead212b7ca1e561b869d44fddb14d0445af Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 10 Mar 2022 09:12:59 +0800 Subject: [PATCH] Fix menu bar event detection on XI2 builds using Core Input * src/gtkutil.c (xg_get_gdk_scale): Always return 1 on GTK+ 2. (xg_event_is_for_menubar): Fix some ifdefs. * src/xterm.c (handle_one_xevent): Update a comment. --- src/gtkutil.c | 6 ++++-- src/xterm.c | 9 ++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gtkutil.c b/src/gtkutil.c index bf95c966421..2a647810886 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -266,6 +266,7 @@ xg_display_open (char *display_name, GdkDisplay **dpy) static int xg_get_gdk_scale (void) { +#ifdef HAVE_GTK3 const char *sscale = getenv ("GDK_SCALE"); if (sscale) @@ -274,6 +275,7 @@ xg_get_gdk_scale (void) if (0 < scale) return min (scale, INT_MAX); } +#endif return 1; } @@ -4223,13 +4225,13 @@ xg_event_is_for_menubar (struct frame *f, const XEvent *event) } else { -#else +#endif rec.x = event->xbutton.x / scale; rec.y = event->xbutton.y / scale; -#endif #ifdef HAVE_XINPUT2 } #endif + rec.width = 1; rec.height = 1; diff --git a/src/xterm.c b/src/xterm.c index 68f7588af4a..0d77ea0c198 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -11652,11 +11652,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, #if defined (USE_X_TOOLKIT) || defined (USE_GTK) f = x_menubar_window_to_frame (dpyinfo, event); - /* For a down-event in the menu bar, - don't pass it to Xt right now. - Instead, save it away - and we will pass it to Xt from kbd_buffer_get_event. - That way, we can run some Lisp code first. */ + /* For a down-event in the menu bar, don't pass it to Xt or + GTK right away. Instead, save it and pass it to Xt or GTK + from kbd_buffer_get_event. That way, we can run some Lisp + code first. */ if (! popup_activated () #ifdef USE_GTK /* Gtk+ menus only react to the first three buttons. */ -- 2.39.2