From a7e89453a7dda988b18bedb47d825fee1db3ba69 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 22 Feb 2023 16:08:55 +0100 Subject: [PATCH] core: Trap errors during passive button/key grabs These are done on the backend X11 connection, so it is unclear what is the interplay through the borrowed global XSetErrorHandler() that triggers issues for us here. Anyways, better to be explicit, and use error traps the MetaBackendX11 style, in coherence with the rest of the things happening in that display. Part-of: --- src/core/keybindings.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 0b7cbeabd..64a5d6071 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -34,6 +34,7 @@ #include "backends/meta-logical-monitor.h" #include "backends/meta-monitor-manager-private.h" #include "backends/x11/meta-backend-x11.h" +#include "backends/x11/meta-clutter-backend-x11.h" #include "backends/x11/meta-input-device-x11.h" #include "compositor/compositor-private.h" #include "core/frame.h" @@ -1197,6 +1198,8 @@ meta_change_button_grab (MetaKeyBindingManager *keys, mods = calc_grab_modifiers (keys, modmask); + meta_clutter_x11_trap_x_errors (); + /* GrabModeSync means freeze until XAllowEvents */ if (grab) XIGrabButton (xdisplay, @@ -1210,6 +1213,8 @@ meta_change_button_grab (MetaKeyBindingManager *keys, META_VIRTUAL_CORE_POINTER_ID, button, xwindow, mods->len, (XIGrabModifiers *)mods->data); + meta_clutter_x11_untrap_x_errors (); + g_array_free (mods, TRUE); } @@ -1430,6 +1435,8 @@ meta_change_keygrab (MetaKeyBindingManager *keys, mods = calc_grab_modifiers (keys, resolved_combo->mask); + meta_clutter_x11_trap_x_errors (); + for (i = 0; i < resolved_combo->len; i++) { xkb_keycode_t keycode = resolved_combo->keycodes[i]; @@ -1452,6 +1459,8 @@ meta_change_keygrab (MetaKeyBindingManager *keys, mods->len, (XIGrabModifiers *)mods->data); } + meta_clutter_x11_untrap_x_errors (); + g_array_free (mods, TRUE); }