summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-12-22 19:56:53 +0300
committermonsta <[email protected]>2017-01-02 16:53:33 +0300
commitbf60e7d8566ccc518e44babb9632d98c01432ef3 (patch)
tree66f6c835f1520573c383649f03035a4cce5aa9a3
parent9aa4c4e379e71ebe8436898a3af61c4c96c9cc8a (diff)
downloadmate-settings-daemon-bf60e7d8566ccc518e44babb9632d98c01432ef3.tar.bz2
mate-settings-daemon-bf60e7d8566ccc518e44babb9632d98c01432ef3.tar.xz
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
-rw-r--r--plugins/common/msd-input-helper.c40
1 files changed, 26 insertions, 14 deletions
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;