mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
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
This commit is contained in:
parent
bb52fa81ce
commit
83cd36e95f
@ -222,6 +222,32 @@ is_touch_device (XIAnyClassInfo **classes,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static gboolean
|
||||||
get_device_ids (ClutterBackendX11 *backend_x11,
|
get_device_ids (ClutterBackendX11 *backend_x11,
|
||||||
XIDeviceInfo *info,
|
XIDeviceInfo *info,
|
||||||
@ -267,7 +293,13 @@ create_device (ClutterDeviceManagerXI2 *manager_xi2,
|
|||||||
gchar *vendor_id = NULL, *product_id = NULL;
|
gchar *vendor_id = NULL, *product_id = NULL;
|
||||||
|
|
||||||
if (info->use == XIMasterKeyboard || info->use == XISlaveKeyboard)
|
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 &&
|
else if (info->use == XISlavePointer &&
|
||||||
is_touch_device (info->classes, info->num_classes,
|
is_touch_device (info->classes, info->num_classes,
|
||||||
&touch_source,
|
&touch_source,
|
||||||
|
Loading…
Reference in New Issue
Block a user