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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
This commit is contained in:
Carlos Garnacho 2023-02-22 16:08:55 +01:00 committed by Marge Bot
parent ab3b12052d
commit a7e89453a7

View File

@ -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);
}