From bf60e7d8566ccc518e44babb9632d98c01432ef3 Mon Sep 17 00:00:00 2001 From: monsta Date: Thu, 22 Dec 2016 19:56:53 +0300 Subject: common: recognize libinput touchpads as touchpads libinput touchpads are recognized by checking if they have tapping property - same as done here: https://github.com/linuxmint/cinnamon-settings-daemon/commit/7e48221e5e5c6095c73c30c4eeeb08f74fac4b16 --- plugins/common/msd-input-helper.c | 40 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'plugins') diff --git a/plugins/common/msd-input-helper.c b/plugins/common/msd-input-helper.c index 7101e43..ae64b0d 100644 --- a/plugins/common/msd-input-helper.c +++ b/plugins/common/msd-input-helper.c @@ -40,26 +40,18 @@ supports_xinput_devices (void) &error); } -XDevice* -device_is_touchpad (XDeviceInfo *deviceinfo) +static gboolean +device_has_property (XDevice *device, + const char *property_name) { - XDevice *device; Atom realtype, prop; int realformat; unsigned long nitems, bytes_after; unsigned char *data; - if (deviceinfo->type != XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_TOUCHPAD, True)) - return NULL; - - prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Synaptics Off", True); + prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), property_name, True); if (!prop) - return NULL; - - gdk_error_trap_push (); - device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), deviceinfo->id); - if (gdk_error_trap_pop () || (device == NULL)) - return NULL; + return FALSE; gdk_error_trap_push (); if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, prop, 0, 1, False, @@ -67,10 +59,30 @@ device_is_touchpad (XDeviceInfo *deviceinfo) &bytes_after, &data) == Success) && (realtype != None)) { gdk_error_trap_pop_ignored (); XFree (data); - return device; + return TRUE; } gdk_error_trap_pop_ignored (); + return FALSE; +} + +XDevice* +device_is_touchpad (XDeviceInfo *deviceinfo) +{ + XDevice *device; + + if (deviceinfo->type != XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_TOUCHPAD, True)) + return NULL; + + gdk_error_trap_push (); + device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), deviceinfo->id); + if (gdk_error_trap_pop () || (device == NULL)) + return NULL; + + if (device_has_property (device, "libinput Tapping Enabled") || + device_has_property (device, "Synaptics Off")) { + return device; + } XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); return NULL; -- cgit v1.2.1