summaryrefslogtreecommitdiff
path: root/plugins/mouse/msd-mouse-manager.c
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-10-28 15:01:10 +0300
committermonsta <[email protected]>2016-10-28 15:01:10 +0300
commit5ea8b63e92e23e1c6d167727a8c264d8c2cd5e14 (patch)
treead140d589b868365763ef057ee8f5bf336e3f5a6 /plugins/mouse/msd-mouse-manager.c
parent1fcff3818a787e5730f230b4bffcb267632138be (diff)
downloadmate-settings-daemon-5ea8b63e92e23e1c6d167727a8c264d8c2cd5e14.tar.bz2
mate-settings-daemon-5ea8b63e92e23e1c6d167727a8c264d8c2cd5e14.tar.xz
mouse: move setting bool property for one device to new function
Diffstat (limited to 'plugins/mouse/msd-mouse-manager.c')
-rw-r--r--plugins/mouse/msd-mouse-manager.c83
1 files changed, 47 insertions, 36 deletions
diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c
index e6c8a54..27225f4 100644
--- a/plugins/mouse/msd-mouse-manager.c
+++ b/plugins/mouse/msd-mouse-manager.c
@@ -708,64 +708,75 @@ set_natural_scroll_all (MsdMouseManager *manager)
}
static void
-synaptics_set_bool (const char * property_name, int property_index, gboolean enabled)
+synaptics_set_bool (XDeviceInfo *device_info,
+ const char *property_name,
+ int property_index,
+ gboolean enabled)
{
- int numdevices, i, rc;
- XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &numdevices);
XDevice *device;
- Atom act_type, property;
- int act_format;
+ int rc;
unsigned long nitems, bytes_after;
unsigned char *data;
-
- if (devicelist == NULL)
- return;
+ int act_format;
+ Atom act_type, property;
property = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), property_name, False);
if (!property)
return;
- int value = 0;
- if (enabled) {
- value = 1;
+ device = device_is_touchpad (device_info);
+ if (device == NULL) {
+ return;
}
- for (i = 0; i < numdevices; i++) {
- if ((device = device_is_touchpad (&devicelist[i]))) {
- gdk_error_trap_push ();
- rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device,
- property, 0, 1, False,
- XA_INTEGER, &act_type, &act_format, &nitems,
- &bytes_after, &data);
- if (rc == Success && act_type == XA_INTEGER && act_format == 8 && nitems > property_index) {
- data[property_index] = value;
- XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device,
- property, XA_INTEGER, 8,
- PropModeReplace, data, nitems);
- }
+ gdk_error_trap_push ();
+ rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device,
+ property, 0, 1, False,
+ XA_INTEGER, &act_type, &act_format, &nitems,
+ &bytes_after, &data);
- XFree (data);
+ if (rc == Success && act_type == XA_INTEGER && act_format == 8 && nitems > property_index) {
+ data[property_index] = enabled ? 1 : 0;
+ XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device,
+ property, XA_INTEGER, 8,
+ PropModeReplace, data, nitems);
+ }
- XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
- if (gdk_error_trap_pop ()) {
- g_warning ("Error while setting %s on \"%s\"", property_name, devicelist[i].name);
- continue;
- }
- }
+ 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
+synaptics_set_bool_all (const char *property_name,
+ int property_index,
+ gboolean enabled)
+{
+ int numdevices, i;
+ XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &numdevices);
+
+ if (devicelist == NULL)
+ return;
+
+ for (i = 0; i < numdevices; i++) {
+ synaptics_set_bool (&devicelist[i], property_name, property_index, enabled);
}
XFreeDeviceList (devicelist);
}
-
static void
set_scrolling (GSettings *settings)
{
- synaptics_set_bool ("Synaptics Edge Scrolling", 0, g_settings_get_boolean (settings, KEY_VERT_EDGE_SCROLL));
- synaptics_set_bool ("Synaptics Edge Scrolling", 1, g_settings_get_boolean (settings, KEY_HORIZ_EDGE_SCROLL));
- synaptics_set_bool ("Synaptics Two-Finger Scrolling", 0, g_settings_get_boolean (settings, KEY_VERT_TWO_FINGER_SCROLL));
- synaptics_set_bool ("Synaptics Two-Finger Scrolling", 1, g_settings_get_boolean (settings, KEY_HORIZ_TWO_FINGER_SCROLL));
+ synaptics_set_bool_all ("Synaptics Edge Scrolling", 0, g_settings_get_boolean (settings, KEY_VERT_EDGE_SCROLL));
+ synaptics_set_bool_all ("Synaptics Edge Scrolling", 1, g_settings_get_boolean (settings, KEY_HORIZ_EDGE_SCROLL));
+ synaptics_set_bool_all ("Synaptics Two-Finger Scrolling", 0, g_settings_get_boolean (settings, KEY_VERT_TWO_FINGER_SCROLL));
+ synaptics_set_bool_all ("Synaptics Two-Finger Scrolling", 1, g_settings_get_boolean (settings, KEY_HORIZ_TWO_FINGER_SCROLL));
}
static void