From 91ba20fff159cc88c87e09f5a8256d6412c98990 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 3 Sep 2022 19:55:31 +0800 Subject: [PATCH] Work around potential X server bug * src/xterm.c (handle_one_xevent): Ignore core crossing events on input extension builds. The X server is not actually supposed to deliver them to us, and it messes up MPX focus tracking. (bug#57468) --- src/xterm.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 138fa7ea6c8..19d2198cdf6 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -19276,6 +19276,18 @@ handle_one_xevent (struct x_display_info *dpyinfo, x_display_set_last_user_time (dpyinfo, event->xcrossing.time, event->xcrossing.send_event); +#ifdef HAVE_XINPUT2 + /* For whatever reason, the X server continues to deliver + EnterNotify and LeaveNotify events despite us selecting for + related XI_Enter and XI_Leave events. It's not just our + problem, since windows created by "xinput test-xi2" suffer + from the same defect. Simply ignore all such events while + the input extension is enabled. (bug#57468) */ + + if (dpyinfo->supports_xi2) + goto OTHER; +#endif + if (x_top_window_to_frame (dpyinfo, event->xcrossing.window)) x_detect_focus_change (dpyinfo, any, event, &inev.ie); @@ -19377,6 +19389,18 @@ handle_one_xevent (struct x_display_info *dpyinfo, x_display_set_last_user_time (dpyinfo, event->xcrossing.time, event->xcrossing.send_event); +#ifdef HAVE_XINPUT2 + /* For whatever reason, the X server continues to deliver + EnterNotify and LeaveNotify events despite us selecting for + related XI_Enter and XI_Leave events. It's not just our + problem, since windows created by "xinput test-xi2" suffer + from the same defect. Simply ignore all such events while + the input extension is enabled. (bug#57468) */ + + if (dpyinfo->supports_xi2) + goto OTHER; +#endif + #ifdef HAVE_XWIDGETS { struct xwidget_view *xvw = xwidget_view_from_window (event->xcrossing.window); @@ -19402,14 +19426,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, #else f = x_top_window_to_frame (dpyinfo, event->xcrossing.window); #endif -#if defined USE_X_TOOLKIT && defined HAVE_XINPUT2 && !defined USE_MOTIF - /* The XI2 event mask is set on the frame widget, so this event - likely originates from the shell widget, which we aren't - interested in. (But don't ignore this on Motif, since we - want to clear the mouse face when a popup is active.) */ - if (dpyinfo->supports_xi2) - f = NULL; -#endif + if (f) { /* Now clear dpyinfo->last_mouse_motion_frame, or -- 2.39.2