summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2023-05-15 00:56:19 +0200
committerMarge Bot <marge-bot@gnome.org>2023-05-16 16:02:43 +0000
commit18e06c248436625faf5f992030a333ef138550e0 (patch)
tree8e5894fa186a1ba78b71057bb721a8cc2890d0d2
parent3218626d7e1c1c9466ad5c64558cf9ace5b68926 (diff)
downloadmutter-18e06c248436625faf5f992030a333ef138550e0.tar.gz
backends/x11: Use backend-side error traps for input configuration
While it's obviously good to trap possible errors from X calls, we are mixing the Clutter error trap with the MetaX11Display one for these calls. This may result in situations where a X call within a Clutter error trap fails, but it's actually handled in these sections using the MetaX11Display error trap. This one will consider the serial out of the "handled" parts and raise an error. It is better to stay consistent here, and use the same error traps than the rest of the X11 backend. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2796 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3002>
-rw-r--r--src/backends/x11/meta-input-settings-x11.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c
index 459636d23..f390faefb 100644
--- a/src/backends/x11/meta-input-settings-x11.c
+++ b/src/backends/x11/meta-input-settings-x11.c
@@ -58,27 +58,17 @@ get_backend (MetaInputSettings *settings)
return meta_input_settings_get_backend (settings);
}
-static MetaDisplay *
-get_display (MetaInputSettings *settings)
-{
- MetaBackend *backend = get_backend (settings);
- MetaContext *context = meta_backend_get_context (backend);
-
- return meta_context_get_display (context);
-}
-
static void
device_handle_free (gpointer user_data)
{
DeviceHandle *handle = user_data;
MetaInputSettings *settings = handle->settings;
- MetaDisplay *display = get_display (settings);
MetaBackend *backend = get_backend (settings);
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
- meta_x11_error_trap_push (display->x11_display);
+ meta_clutter_x11_trap_x_errors ();
XCloseDevice (xdisplay, handle->xdev);
- meta_x11_error_trap_pop (display->x11_display);
+ meta_clutter_x11_untrap_x_errors ();
g_free (handle);
}
@@ -87,7 +77,6 @@ static XDevice *
device_ensure_xdevice (MetaInputSettings *settings,
ClutterInputDevice *device)
{
- MetaDisplay *display = get_display (settings);
MetaBackend *backend = get_backend (settings);
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
int device_id = meta_input_device_x11_get_device_id (device);
@@ -98,9 +87,9 @@ device_ensure_xdevice (MetaInputSettings *settings,
if (handle)
return handle->xdev;
- meta_x11_error_trap_push (display->x11_display);
+ meta_clutter_x11_trap_x_errors ();
xdev = XOpenDevice (xdisplay, device_id);
- meta_x11_error_trap_pop (display->x11_display);
+ meta_clutter_x11_untrap_x_errors ();
if (xdev)
{
@@ -617,16 +606,12 @@ meta_input_settings_x11_set_tablet_mapping (MetaInputSettings *settings,
ClutterInputDevice *device,
GDesktopTabletMapping mapping)
{
- MetaDisplay *display = get_display (settings);
MetaBackend *backend = get_backend (settings);
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
XDevice *xdev;
- if (!display)
- return;
-
/* Grab the puke bucket! */
- meta_x11_error_trap_push (display->x11_display);
+ meta_clutter_x11_trap_x_errors ();
xdev = device_ensure_xdevice (settings, device);
if (xdev)
{
@@ -635,11 +620,7 @@ meta_input_settings_x11_set_tablet_mapping (MetaInputSettings *settings,
Absolute : Relative);
}
- if (meta_x11_error_trap_pop_with_return (display->x11_display))
- {
- g_warning ("Could not set tablet mapping for %s",
- clutter_input_device_get_device_name (device));
- }
+ meta_clutter_x11_untrap_x_errors ();
}
static gboolean
@@ -774,16 +755,12 @@ meta_input_settings_x11_set_stylus_button_map (MetaInputSettings *setti
GDesktopStylusButtonAction secondary,
GDesktopStylusButtonAction tertiary)
{
- MetaDisplay *display = get_display (settings);
MetaBackend *backend = get_backend (settings);
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
XDevice *xdev;
- if (!display)
- return;
-
/* Grab the puke bucket! */
- meta_x11_error_trap_push (display->x11_display);
+ meta_clutter_x11_trap_x_errors ();
xdev = device_ensure_xdevice (settings, device);
if (xdev)
{
@@ -801,11 +778,7 @@ meta_input_settings_x11_set_stylus_button_map (MetaInputSettings *setti
XSetDeviceButtonMapping (xdisplay, xdev, map, G_N_ELEMENTS (map));
}
- if (meta_x11_error_trap_pop_with_return (display->x11_display))
- {
- g_warning ("Could not set stylus button map for %s",
- clutter_input_device_get_device_name (device));
- }
+ meta_clutter_x11_untrap_x_errors ();
}
static void