summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2015-04-09 11:03:16 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2015-04-09 12:37:44 +0100
commit79849ef1d5fff9acd310cd68d59df0c7cf2cb28f (patch)
treeb4085b5e4210bc9a6b3db9950ac130f6d7f1b175
parentb292bec8a58331ac210183edd8f890b5c993c928 (diff)
downloadclutter-79849ef1d5fff9acd310cd68d59df0c7cf2cb28f.tar.gz
x11: Improve touchpad detection heuristics
We should use the same heuristics used by GDK in order to detect whether a device is a touchpad or not. Based on the similar code from Carlos Garnacho for GDK: https://git.gnome.org/browse/gtk+/commit/?id=6f07d5e7 https://bugzilla.gnome.org/show_bug.cgi?id=747436 (cherry picked from commit 83cd36e95f57fd17eb705b963dcc1ca489bb0cc0) Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
-rw-r--r--clutter/x11/clutter-device-manager-xi2.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/clutter/x11/clutter-device-manager-xi2.c b/clutter/x11/clutter-device-manager-xi2.c
index 2303fb4fc..1bad9d710 100644
--- a/clutter/x11/clutter-device-manager-xi2.c
+++ b/clutter/x11/clutter-device-manager-xi2.c
@@ -223,6 +223,32 @@ is_touch_device (XIAnyClassInfo **classes,
}
static gboolean
+is_touchpad_device (ClutterBackendX11 *backend_x11,
+ XIDeviceInfo *info)
+{
+ gulong nitems, bytes_after;
+ guint32 *data = NULL;
+ int rc, format;
+ Atom type;
+
+ clutter_x11_trap_x_errors ();
+ rc = XIGetProperty (backend_x11->xdpy,
+ info->deviceid,
+ XInternAtom (backend_x11->xdpy, "libinput Tapping Enabled", False),
+ 0, 1, False, XA_INTEGER, &type, &format, &nitems, &bytes_after,
+ (guchar **) &data);
+ clutter_x11_untrap_x_errors ();
+
+ /* We don't care about the data */
+ XFree (data);
+
+ if (rc != Success || type != XA_INTEGER || format != 32 || nitems != 1)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
get_device_ids (ClutterBackendX11 *backend_x11,
XIDeviceInfo *info,
gchar **vendor_id,
@@ -267,7 +293,13 @@ create_device (ClutterDeviceManagerXI2 *manager_xi2,
gchar *vendor_id = NULL, *product_id = NULL;
if (info->use == XIMasterKeyboard || info->use == XISlaveKeyboard)
- source = CLUTTER_KEYBOARD_DEVICE;
+ {
+ source = CLUTTER_KEYBOARD_DEVICE;
+ }
+ else if (is_touchpad_device (backend_x11, info))
+ {
+ source = CLUTTER_TOUCHPAD_DEVICE;
+ }
else if (info->use == XISlavePointer &&
is_touch_device (info->classes, info->num_classes,
&touch_source,