|
|
e3f29c |
From bc17d94ef058564c1a1adf28a8696164455fea1b Mon Sep 17 00:00:00 2001
|
|
|
e3f29c |
From: Carlos Garnacho <carlosg@gnome.org>
|
|
|
e3f29c |
Date: Tue, 30 Jan 2018 13:07:32 +0100
|
|
|
e3f29c |
Subject: [PATCH] backends/x11: Preserve XI1 XDevice throughout
|
|
|
e3f29c |
ClutterInputDevice lifetime
|
|
|
e3f29c |
|
|
|
e3f29c |
Opening and closing the device may result into XI2 grabs being cut short,
|
|
|
e3f29c |
resulting into pad buttons being rendered ineffective, and other possible
|
|
|
e3f29c |
misbehaviors. This is an XInput flaw that fell in the gap between XI1 and
|
|
|
e3f29c |
XI2, and has no easy fix. It pays us for mixing both versions, I guess...
|
|
|
e3f29c |
|
|
|
e3f29c |
Work this around by keeping the XI1 XDevice attached to the
|
|
|
e3f29c |
ClutterInputDevice, this way it will live long enough that this is not
|
|
|
e3f29c |
a concern.
|
|
|
e3f29c |
|
|
|
e3f29c |
Investigation of this bug was mostly carried by Peter Hutterer, I'm just
|
|
|
e3f29c |
the executing hand.
|
|
|
e3f29c |
|
|
|
e3f29c |
https://gitlab.gnome.org/GNOME/mutter/issues/7
|
|
|
e3f29c |
|
|
|
e3f29c |
Closes: #7
|
|
|
e3f29c |
---
|
|
|
e3f29c |
src/backends/x11/meta-input-settings-x11.c | 48 ++++++++++++++++++++++++++----
|
|
|
e3f29c |
1 file changed, 42 insertions(+), 6 deletions(-)
|
|
|
e3f29c |
|
|
|
e3f29c |
diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c
|
|
|
e3f29c |
index d1ee37a..7a876ef 100644
|
|
|
e3f29c |
--- a/src/backends/x11/meta-input-settings-x11.c
|
|
|
e3f29c |
+++ b/src/backends/x11/meta-input-settings-x11.c
|
|
|
e3f29c |
@@ -55,6 +55,46 @@ enum {
|
|
|
e3f29c |
SCROLL_METHOD_NUM_FIELDS
|
|
|
e3f29c |
};
|
|
|
e3f29c |
|
|
|
e3f29c |
+static void
|
|
|
e3f29c |
+device_free_xdevice (gpointer user_data)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+ MetaDisplay *display = meta_get_display ();
|
|
|
e3f29c |
+ MetaBackend *backend = meta_get_backend ();
|
|
|
e3f29c |
+ Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
|
|
|
e3f29c |
+ XDevice *xdev = user_data;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ meta_error_trap_push (display);
|
|
|
e3f29c |
+ XCloseDevice (xdisplay, xdev);
|
|
|
e3f29c |
+ meta_error_trap_pop (display);
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+static XDevice *
|
|
|
e3f29c |
+device_ensure_xdevice (ClutterInputDevice *device)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+ MetaDisplay *display = meta_get_display ();
|
|
|
e3f29c |
+ MetaBackend *backend = meta_get_backend ();
|
|
|
e3f29c |
+ Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
|
|
|
e3f29c |
+ int device_id = clutter_input_device_get_device_id (device);
|
|
|
e3f29c |
+ XDevice *xdev = NULL;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ xdev = g_object_get_data (G_OBJECT (device), "meta-input-settings-xdevice");
|
|
|
e3f29c |
+ if (xdev)
|
|
|
e3f29c |
+ return xdev;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ meta_error_trap_push (display);
|
|
|
e3f29c |
+ xdev = XOpenDevice (xdisplay, device_id);
|
|
|
e3f29c |
+ meta_error_trap_pop (display);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ if (xdev)
|
|
|
e3f29c |
+ {
|
|
|
e3f29c |
+ g_object_set_data_full (G_OBJECT (device),
|
|
|
e3f29c |
+ "meta-input-settings-xdevice",
|
|
|
e3f29c |
+ xdev, (GDestroyNotify) device_free_xdevice);
|
|
|
e3f29c |
+ }
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ return xdev;
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
+
|
|
|
e3f29c |
static void *
|
|
|
e3f29c |
get_property (ClutterInputDevice *device,
|
|
|
e3f29c |
const gchar *property,
|
|
|
e3f29c |
@@ -540,7 +580,6 @@ meta_input_settings_x11_set_tablet_mapping (MetaInputSettings *settings,
|
|
|
e3f29c |
MetaDisplay *display = meta_get_display ();
|
|
|
e3f29c |
MetaBackend *backend = meta_get_backend ();
|
|
|
e3f29c |
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
|
|
|
e3f29c |
- int device_id = clutter_input_device_get_device_id (device);
|
|
|
e3f29c |
XDevice *xdev;
|
|
|
e3f29c |
|
|
|
e3f29c |
if (!display)
|
|
|
e3f29c |
@@ -548,13 +587,12 @@ meta_input_settings_x11_set_tablet_mapping (MetaInputSettings *settings,
|
|
|
e3f29c |
|
|
|
e3f29c |
/* Grab the puke bucket! */
|
|
|
e3f29c |
meta_error_trap_push (display);
|
|
|
e3f29c |
- xdev = XOpenDevice (xdisplay, device_id);
|
|
|
e3f29c |
+ xdev = device_ensure_xdevice (device);
|
|
|
e3f29c |
if (xdev)
|
|
|
e3f29c |
{
|
|
|
e3f29c |
XSetDeviceMode (xdisplay, xdev,
|
|
|
e3f29c |
mapping == G_DESKTOP_TABLET_MAPPING_ABSOLUTE ?
|
|
|
e3f29c |
Absolute : Relative);
|
|
|
e3f29c |
- XCloseDevice (xdisplay, xdev);
|
|
|
e3f29c |
}
|
|
|
e3f29c |
|
|
|
e3f29c |
if (meta_error_trap_pop_with_return (display))
|
|
|
e3f29c |
@@ -737,7 +775,6 @@ meta_input_settings_x11_set_stylus_button_map (MetaInputSettings *setti
|
|
|
e3f29c |
MetaDisplay *display = meta_get_display ();
|
|
|
e3f29c |
MetaBackend *backend = meta_get_backend ();
|
|
|
e3f29c |
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
|
|
|
e3f29c |
- int device_id = clutter_input_device_get_device_id (device);
|
|
|
e3f29c |
XDevice *xdev;
|
|
|
e3f29c |
|
|
|
e3f29c |
if (!display)
|
|
|
e3f29c |
@@ -745,7 +782,7 @@ meta_input_settings_x11_set_stylus_button_map (MetaInputSettings *setti
|
|
|
e3f29c |
|
|
|
e3f29c |
/* Grab the puke bucket! */
|
|
|
e3f29c |
meta_error_trap_push (display);
|
|
|
e3f29c |
- xdev = XOpenDevice (xdisplay, device_id);
|
|
|
e3f29c |
+ xdev = device_ensure_xdevice (device);
|
|
|
e3f29c |
if (xdev)
|
|
|
e3f29c |
{
|
|
|
e3f29c |
guchar map[3] = {
|
|
|
e3f29c |
@@ -755,7 +792,6 @@ meta_input_settings_x11_set_stylus_button_map (MetaInputSettings *setti
|
|
|
e3f29c |
};
|
|
|
e3f29c |
|
|
|
e3f29c |
XSetDeviceButtonMapping (xdisplay, xdev, map, G_N_ELEMENTS (map));
|
|
|
e3f29c |
- XCloseDevice (xdisplay, xdev);
|
|
|
e3f29c |
}
|
|
|
e3f29c |
|
|
|
e3f29c |
if (meta_error_trap_pop_with_return (display))
|
|
|
e3f29c |
--
|
|
|
e3f29c |
1.8.3.1
|
|
|
e3f29c |
|