From c42ef4e7c142a93e2ccfea904d72735a6030e978 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 8 Apr 2022 11:22:06 +0800 Subject: [PATCH] Ignore input extension errors caused by grabbing * src/xterm.c (x_error_handler): Ignore GrabDevice and UngrabDevice errors. --- src/xterm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index 9336b9420f6..9b0fe6f3f7b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -19200,6 +19200,10 @@ static void x_error_quitter (Display *, XErrorEvent *); static int x_error_handler (Display *display, XErrorEvent *event) { +#ifdef HAVE_XINPUT2 + struct x_display_info *dpyinfo; +#endif + #if defined USE_GTK && defined HAVE_GTK3 if ((event->error_code == BadMatch || event->error_code == BadWindow) && event->request_code == X_SetInputFocus) @@ -19208,6 +19212,20 @@ x_error_handler (Display *display, XErrorEvent *event) } #endif + /* If we try to ungrab or grab a device that doesn't exist anymore + (that happens a lot in xmenu.c), just ignore the error. */ + +#ifdef HAVE_XINPUT2 + dpyinfo = x_display_info_for_display (display); + + /* 51 is X_XIGrabDevice and 52 is X_XIUngrabDevice. */ + if (dpyinfo && dpyinfo->supports_xi2 + && event->request_code == dpyinfo->xi2_opcode + && (event->minor_code == 51 + || event->minor_code == 52)) + return 0; +#endif + if (x_error_message) x_error_catcher (display, event); else -- 2.39.2