summaryrefslogtreecommitdiff
path: root/plugins/mouse
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-12-23 13:44:56 +0300
committermonsta <[email protected]>2017-01-02 16:53:33 +0300
commit5956d7c3b2d0abf4b70ef480a9c4c455c39a3f04 (patch)
treec99bf8ba540e95f5618def78963d4463afd38e16 /plugins/mouse
parent8872b8fdd4e201031997e65fd1721ec785984d0d (diff)
downloadmate-settings-daemon-5956d7c3b2d0abf4b70ef480a9c4c455c39a3f04.tar.bz2
mate-settings-daemon-5956d7c3b2d0abf4b70ef480a9c4c455c39a3f04.tar.xz
mouse: libinput - hook up scrolling settings
note: libinput does not allow for both edge and twofinger scrolling to be enabled simultaneously. We prefer twofinger scrolling. The same goes for horizontal scrolling, it picks the setting for whatever scroll method we applied. adapted from: https://github.com/linuxmint/cinnamon-settings-daemon/commit/82442095a33b1f063f00512d438711ef092e0121
Diffstat (limited to 'plugins/mouse')
-rw-r--r--plugins/mouse/msd-mouse-manager.c81
1 files changed, 79 insertions, 2 deletions
diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c
index 80d19f2..b48189b 100644
--- a/plugins/mouse/msd-mouse-manager.c
+++ b/plugins/mouse/msd-mouse-manager.c
@@ -962,8 +962,8 @@ set_natural_scroll_all (MsdMouseManager *manager)
}
static void
-set_scrolling (XDeviceInfo *device_info,
- GSettings *settings)
+set_scrolling_synaptics (XDeviceInfo *device_info,
+ GSettings *settings)
{
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));
@@ -972,6 +972,83 @@ set_scrolling (XDeviceInfo *device_info,
}
static void
+set_scrolling_libinput (XDeviceInfo *device_info,
+ GSettings *settings)
+{
+ XDevice *device;
+ int format, rc;
+ unsigned long nitems, bytes_after;
+ unsigned char *data;
+ Atom prop, type;
+ gboolean want_edge, want_2fg;
+ gboolean want_horiz;
+
+ prop = property_from_name ("libinput Scroll Method Enabled");
+ if (!prop)
+ return;
+
+ device = device_is_touchpad (device_info);
+ if (device == NULL) {
+ return;
+ }
+
+ want_2fg = g_settings_get_boolean (settings, KEY_VERT_TWO_FINGER_SCROLL);
+ want_edge = g_settings_get_boolean (settings, KEY_VERT_EDGE_SCROLL);
+
+ /* libinput only allows for one scroll method at a time.
+ * If both are set, pick 2fg scrolling.
+ */
+ if (want_2fg)
+ want_edge = FALSE;
+
+ g_debug ("setting scroll method on %s", device_info->name);
+
+ gdk_error_trap_push ();
+ rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, prop, 0, 2,
+ False, XA_INTEGER, &type, &format, &nitems,
+ &bytes_after, &data);
+
+ if (rc == Success && type == XA_INTEGER && format == 8 && nitems >= 3) {
+ data[0] = want_2fg;
+ data[1] = want_edge;
+ XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device,
+ prop, XA_INTEGER, 8, PropModeReplace, data, nitems);
+ }
+
+ if (rc == Success)
+ XFree (data);
+
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
+ if (gdk_error_trap_pop ()) {
+ g_warning ("Error in setting scroll method on \"%s\"", device_info->name);
+ }
+
+ /* Horizontal scrolling is handled by xf86-input-libinput and
+ * there's only one bool. Pick the one matching the scroll method
+ * we picked above.
+ */
+ if (want_2fg)
+ want_horiz = g_settings_get_boolean (settings, KEY_HORIZ_TWO_FINGER_SCROLL);
+ else if (want_edge)
+ want_horiz = g_settings_get_boolean (settings, KEY_HORIZ_EDGE_SCROLL);
+ else
+ return;
+
+ touchpad_set_bool (device_info, "libinput Horizontal Scroll Enabled", 0, want_horiz);
+}
+
+static void
+set_scrolling (XDeviceInfo *device_info,
+ GSettings *settings)
+{
+ if (property_from_name ("Synaptics Edge Scrolling"))
+ set_scrolling_synaptics (device_info, settings);
+
+ if (property_from_name ("libinput Scroll Method Enabled"))
+ set_scrolling_libinput (device_info, settings);
+}
+
+static void
set_scrolling_all (GSettings *settings)
{
int numdevices, i;