summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-12-23 14:00:34 +0300
committermonsta <[email protected]>2017-01-02 16:53:33 +0300
commite3800c8a9a865b4ddeb4aef10081ac0b52996883 (patch)
treef93f86451322480fda5cc698502a37cde91ffd43
parent5956d7c3b2d0abf4b70ef480a9c4c455c39a3f04 (diff)
downloadmate-settings-daemon-e3800c8a9a865b4ddeb4aef10081ac0b52996883.tar.bz2
mate-settings-daemon-e3800c8a9a865b4ddeb4aef10081ac0b52996883.tar.xz
mouse: libinput - hook up click methods
note: libinput does not allow for configuration of the click actions, the options are just "software buttons" or "clickfinger". If any clickfinger actions are set, we enable clickfinger, otherwise software buttons. adapted from: https://github.com/linuxmint/cinnamon-settings-daemon/commit/6394ea6c2754c434897cebfc6c331b4ee07ce1b8
-rw-r--r--plugins/mouse/msd-mouse-manager.c65
1 files changed, 62 insertions, 3 deletions
diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c
index b48189b..43fd124 100644
--- a/plugins/mouse/msd-mouse-manager.c
+++ b/plugins/mouse/msd-mouse-manager.c
@@ -810,9 +810,9 @@ set_tap_to_click_all (MsdMouseManager *manager)
}
static void
-set_click_actions (XDeviceInfo *device_info,
- gint enable_two_finger_click,
- gint enable_three_finger_click)
+set_click_actions_synaptics (XDeviceInfo *device_info,
+ gint enable_two_finger_click,
+ gint enable_three_finger_click)
{
XDevice *device;
int format, rc;
@@ -851,7 +851,66 @@ set_click_actions (XDeviceInfo *device_info,
if (gdk_error_trap_pop ()) {
g_warning ("Error in setting click actions on \"%s\"", device_info->name);
}
+}
+
+static void
+set_click_actions_libinput (XDeviceInfo *device_info,
+ gint enable_two_finger_click,
+ gint enable_three_finger_click)
+{
+ XDevice *device;
+ int format, rc;
+ unsigned long nitems, bytes_after;
+ unsigned char *data;
+ Atom prop, type;
+ gboolean want_clickfinger;
+ gboolean want_softwarebuttons;
+
+ prop = property_from_name ("libinput Click Method Enabled");
+ if (!prop)
+ return;
+
+ device = device_is_touchpad (device_info);
+ if (device == NULL) {
+ return;
+ }
+
+ g_debug ("setting click action to click on %s", device_info->name);
+
+ want_clickfinger = enable_two_finger_click || enable_three_finger_click;
+ want_softwarebuttons = !want_clickfinger;
+
+ 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 >= 2) {
+ data[0] = want_softwarebuttons;
+ data[1] = want_clickfinger;
+ 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 click actions on \"%s\"", device_info->name);
+ }
+}
+
+static void
+set_click_actions (XDeviceInfo *device_info,
+ gint enable_two_finger_click,
+ gint enable_three_finger_click)
+{
+ if (property_from_name ("Synaptics Click Action"))
+ set_click_actions_synaptics (device_info, enable_two_finger_click, enable_three_finger_click);
+ if (property_from_name ("libinput Click Method Enabled"))
+ set_click_actions_libinput (device_info, enable_two_finger_click, enable_three_finger_click);
}
static void