From be168388a752fe61ba213751435e67fbc955c9fe Mon Sep 17 00:00:00 2001 From: monsta Date: Thu, 22 Dec 2016 19:40:26 +0300 Subject: mouse: split helper for setting bool property into two separate ones one is for touchpads, another is for generic bool properties same as done in: https://github.com/linuxmint/cinnamon-settings-daemon/commit/cdcea69868ea082cfa620b87cc6cfad4279dadc1 --- plugins/mouse/msd-mouse-manager.c | 44 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'plugins/mouse') diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index 9c7a56c..9be3397 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -822,12 +822,12 @@ set_natural_scroll_all (MsdMouseManager *manager) } static void -synaptics_set_bool (XDeviceInfo *device_info, - const char *property_name, - int property_index, - gboolean enabled) +property_set_bool (XDeviceInfo *device_info, + XDevice *device, + const char *property_name, + int property_index, + gboolean enabled) { - XDevice *device; int rc; unsigned long nitems, bytes_after; unsigned char *data; @@ -838,11 +838,6 @@ synaptics_set_bool (XDeviceInfo *device_info, if (!property) return; - device = device_is_touchpad (device_info); - if (device == NULL) { - return; - } - gdk_error_trap_push (); rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, property, 0, 1, False, @@ -859,20 +854,39 @@ synaptics_set_bool (XDeviceInfo *device_info, if (rc == Success) XFree (data); - XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); if (gdk_error_trap_pop ()) { g_warning ("Error while setting %s on \"%s\"", property_name, device_info->name); } } +static void +touchpad_set_bool (XDeviceInfo *device_info, + const char *property_name, + int property_index, + gboolean enabled) +{ + XDevice *device; + + device = device_is_touchpad (device_info); + if (device == NULL) { + return; + } + + property_set_bool (device_info, device, property_name, property_index, enabled); + + gdk_error_trap_push (); + XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); + gdk_error_trap_pop_ignored (); +} + static void set_scrolling (XDeviceInfo *device_info, GSettings *settings) { - synaptics_set_bool (device_info, "Synaptics Edge Scrolling", 0, g_settings_get_boolean (settings, KEY_VERT_EDGE_SCROLL)); - synaptics_set_bool (device_info, "Synaptics Edge Scrolling", 1, g_settings_get_boolean (settings, KEY_HORIZ_EDGE_SCROLL)); - synaptics_set_bool (device_info, "Synaptics Two-Finger Scrolling", 0, g_settings_get_boolean (settings, KEY_VERT_TWO_FINGER_SCROLL)); - synaptics_set_bool (device_info, "Synaptics Two-Finger Scrolling", 1, g_settings_get_boolean (settings, KEY_HORIZ_TWO_FINGER_SCROLL)); + touchpad_set_bool (device_info, "Synaptics Edge Scrolling", 0, g_settings_get_boolean (settings, KEY_VERT_EDGE_SCROLL)); + touchpad_set_bool (device_info, "Synaptics Edge Scrolling", 1, g_settings_get_boolean (settings, KEY_HORIZ_EDGE_SCROLL)); + touchpad_set_bool (device_info, "Synaptics Two-Finger Scrolling", 0, g_settings_get_boolean (settings, KEY_VERT_TWO_FINGER_SCROLL)); + touchpad_set_bool (device_info, "Synaptics Two-Finger Scrolling", 1, g_settings_get_boolean (settings, KEY_HORIZ_TWO_FINGER_SCROLL)); } static void -- cgit v1.2.1