From b8cc7f47feb9f6c102bc40ac16d7248327a7c2e0 Mon Sep 17 00:00:00 2001 From: monsta Date: Fri, 23 Dec 2016 14:15:52 +0300 Subject: mouse: added helper to check if property exists on device same as done here: https://github.com/linuxmint/cinnamon-settings-daemon/commit/c35f95210f025132e2e551024a01f6102371a0a0 --- plugins/mouse/msd-mouse-manager.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index 43fd124..71d691f 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -243,6 +243,40 @@ touchpad_has_single_button (XDevice *device) return is_single_button; } +static gboolean +property_exists_on_device (XDeviceInfo *device_info, + const char *property_name) +{ + XDevice *device; + int rc; + Atom type, prop; + int format; + unsigned long nitems, bytes_after; + unsigned char *data; + + prop = property_from_name (property_name); + if (!prop) + return FALSE; + + gdk_error_trap_push (); + device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device_info->id); + if ((gdk_error_trap_pop () != 0) || (device == NULL)) + return FALSE; + + gdk_error_trap_push (); + rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), + device, prop, 0, 1, False, XA_INTEGER, &type, &format, + &nitems, &bytes_after, &data); + + if (rc == Success) + XFree (data); + + XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); + gdk_error_trap_pop_ignored (); + + return rc == Success; +} + static void property_set_bool (XDeviceInfo *device_info, XDevice *device, -- cgit v1.2.1