summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-12-23 12:59:55 +0300
committermonsta <[email protected]>2017-01-02 16:53:33 +0300
commit4bb98214c441bfc870af156b71ea059ea6e5ec58 (patch)
tree06ce09527d12b3ff7b27ca7ab59927be84528829 /plugins
parent28d68cffb504d62bb2610cdb5aecdbc44bc59bd6 (diff)
downloadmate-settings-daemon-4bb98214c441bfc870af156b71ea059ea6e5ec58.tar.bz2
mate-settings-daemon-4bb98214c441bfc870af156b71ea059ea6e5ec58.tar.xz
mouse: libinput - hook up middle button emulation
adapted from: https://github.com/linuxmint/cinnamon-settings-daemon/commit/31942ecdaae153dc500d8699785fbb6bf58ec44b
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mouse/msd-mouse-manager.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c
index 612f481..bed7d88 100644
--- a/plugins/mouse/msd-mouse-manager.c
+++ b/plugins/mouse/msd-mouse-manager.c
@@ -542,8 +542,8 @@ set_motion_all (MsdMouseManager *manager)
}
static void
-set_middle_button (XDeviceInfo *device_info,
- gboolean middle_button)
+set_middle_button_evdev (XDeviceInfo *device_info,
+ gboolean middle_button)
{
XDevice *device;
Atom prop;
@@ -585,6 +585,46 @@ set_middle_button (XDeviceInfo *device_info,
}
static void
+set_middle_button_libinput (XDeviceInfo *device_info,
+ gboolean middle_button)
+{
+ XDevice *device;
+
+ /* touchpad devices are excluded as the old code
+ * only applies to evdev devices
+ */
+ device = device_is_touchpad (device_info);
+ if (device != NULL) {
+ gdk_error_trap_push ();
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
+ gdk_error_trap_pop_ignored ();
+ return;
+ }
+
+ 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;
+
+ property_set_bool (device_info, device, "libinput Middle Emulation Enabled", 0, middle_button);
+
+ gdk_error_trap_push ();
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
+ gdk_error_trap_pop_ignored ();
+}
+
+static void
+set_middle_button (XDeviceInfo *device_info,
+ gboolean middle_button)
+{
+ if (property_from_name ("Evdev Middle Button Emulation"))
+ set_middle_button_evdev (device_info, middle_button);
+
+ if (property_from_name ("libinput Middle Emulation Enabled"))
+ set_middle_button_libinput (device_info, middle_button);
+}
+
+static void
set_middle_button_all (gboolean middle_button)
{
XDeviceInfo *device_info;