summaryrefslogtreecommitdiff
path: root/plugins/mouse/msd-mouse-manager.c
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-12-23 14:15:52 +0300
committermonsta <[email protected]>2017-01-02 16:53:33 +0300
commitb8cc7f47feb9f6c102bc40ac16d7248327a7c2e0 (patch)
treef8e2f29adc600334cf6a90d901728301d7b45d36 /plugins/mouse/msd-mouse-manager.c
parente3800c8a9a865b4ddeb4aef10081ac0b52996883 (diff)
downloadmate-settings-daemon-b8cc7f47feb9f6c102bc40ac16d7248327a7c2e0.tar.bz2
mate-settings-daemon-b8cc7f47feb9f6c102bc40ac16d7248327a7c2e0.tar.xz
mouse: added helper to check if property exists on device
same as done here: https://github.com/linuxmint/cinnamon-settings-daemon/commit/c35f95210f025132e2e551024a01f6102371a0a0
Diffstat (limited to 'plugins/mouse/msd-mouse-manager.c')
-rw-r--r--plugins/mouse/msd-mouse-manager.c34
1 files changed, 34 insertions, 0 deletions
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,