From 513fe2d6ff9808d54e9a9ff6eb82ef1518d4d6ad Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 21 Dec 2021 09:58:14 +0800 Subject: Fix touch event menu bar detection * src/xterm.c (handle_one_event): Don't drop menu bar touch events. --- src/xterm.c | 74 ++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 1691db19659..cd135056a2c 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10878,6 +10878,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, case XI_TouchBegin: { struct xi_device_t *device; + bool menu_bar_p = false; device = xi_device_from_id (dpyinfo, xev->deviceid); x_display_set_last_user_time (dpyinfo, xev->time); @@ -10889,47 +10890,54 @@ handle_one_xevent (struct x_display_info *dpyinfo, f = x_any_window_to_frame (dpyinfo, xev->event); - if (f && device->direct_p) +#ifdef HAVE_GTK3 + menu_bar_p = (FRAME_X_OUTPUT (f)->menubar_widget + && xg_event_is_for_menubar (f, event)); +#endif + + if (!menu_bar_p) { - *finish = X_EVENT_DROP; - x_catch_errors (dpyinfo->display); - XIAllowTouchEvents (dpyinfo->display, xev->deviceid, - xev->detail, xev->event, XIAcceptTouch); - if (!x_had_errors_p (dpyinfo->display)) + if (f && device->direct_p) { - xi_link_touch_point (device, xev->detail, xev->event_x, - xev->event_y); - -#ifdef HAVE_GTK3 - if (FRAME_X_OUTPUT (f)->menubar_widget - && xg_event_is_for_menubar (f, event)) + *finish = X_EVENT_DROP; + x_catch_errors (dpyinfo->display); + XIAllowTouchEvents (dpyinfo->display, xev->deviceid, + xev->detail, xev->event, XIAcceptTouch); + if (!x_had_errors_p (dpyinfo->display)) { - bool was_waiting_for_input = waiting_for_input; - /* This hack was adopted from the NS port. Whether - or not it is actually safe is a different story - altogether. */ - if (waiting_for_input) - waiting_for_input = 0; - set_frame_menubar (f, true); - waiting_for_input = was_waiting_for_input; - } -#endif + xi_link_touch_point (device, xev->detail, xev->event_x, + xev->event_y); - inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT; - inev.ie.timestamp = xev->time; - XSETFRAME (inev.ie.frame_or_window, f); - XSETINT (inev.ie.x, lrint (xev->event_x)); - XSETINT (inev.ie.y, lrint (xev->event_y)); - XSETINT (inev.ie.arg, xev->detail); + inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT; + inev.ie.timestamp = xev->time; + XSETFRAME (inev.ie.frame_or_window, f); + XSETINT (inev.ie.x, lrint (xev->event_x)); + XSETINT (inev.ie.y, lrint (xev->event_y)); + XSETINT (inev.ie.arg, xev->detail); + } + x_uncatch_errors_after_check (); } - x_uncatch_errors_after_check (); + else + { + x_catch_errors (dpyinfo->display); + XIAllowTouchEvents (dpyinfo->display, xev->deviceid, + xev->detail, xev->event, XIRejectTouch); + x_uncatch_errors (); + } + } else { - x_catch_errors (dpyinfo->display); - XIAllowTouchEvents (dpyinfo->display, xev->deviceid, - xev->detail, xev->event, XIRejectTouch); - x_uncatch_errors (); +#ifdef HAVE_GTK3 + bool was_waiting_for_input = waiting_for_input; + /* This hack was adopted from the NS port. Whether + or not it is actually safe is a different story + altogether. */ + if (waiting_for_input) + waiting_for_input = 0; + set_frame_menubar (f, true); + waiting_for_input = was_waiting_for_input; +#endif } goto XI_OTHER; -- cgit v1.2.3