summaryrefslogtreecommitdiff
path: root/plugins/mouse/msd-mouse-manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mouse/msd-mouse-manager.c')
-rw-r--r--plugins/mouse/msd-mouse-manager.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c
index 71d691f..823c448 100644
--- a/plugins/mouse/msd-mouse-manager.c
+++ b/plugins/mouse/msd-mouse-manager.c
@@ -336,10 +336,10 @@ touchpad_set_bool (XDeviceInfo *device_info,
}
static void
-set_left_handed (MsdMouseManager *manager,
- XDeviceInfo *device_info,
- gboolean mouse_left_handed,
- gboolean touchpad_left_handed)
+set_left_handed_legacy_driver (MsdMouseManager *manager,
+ XDeviceInfo *device_info,
+ gboolean mouse_left_handed,
+ gboolean touchpad_left_handed)
{
XDevice *device;
guchar *buttons;
@@ -409,6 +409,48 @@ set_left_handed (MsdMouseManager *manager,
}
static void
+set_left_handed_libinput (XDeviceInfo *device_info,
+ gboolean mouse_left_handed,
+ gboolean touchpad_left_handed)
+{
+ XDevice *device;
+ gboolean want_lefthanded;
+
+ device = device_is_touchpad (device_info);
+ if (device == NULL) {
+ 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;
+
+ want_lefthanded = mouse_left_handed;
+ } else {
+ /* touchpad device is already open after
+ * return from device_is_touchpad function
+ */
+ want_lefthanded = touchpad_left_handed;
+ }
+
+ property_set_bool (device_info, device, "libinput Left Handed Enabled", 0, want_lefthanded);
+
+ gdk_error_trap_push ();
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
+ gdk_error_trap_pop_ignored ();
+}
+
+static void
+set_left_handed (MsdMouseManager *manager,
+ XDeviceInfo *device_info,
+ gboolean mouse_left_handed,
+ gboolean touchpad_left_handed)
+{
+ if (property_exists_on_device (device_info, "libinput Left Handed Enabled"))
+ set_left_handed_libinput (device_info, mouse_left_handed, touchpad_left_handed);
+ else
+ set_left_handed_legacy_driver (manager, device_info, mouse_left_handed, touchpad_left_handed);
+}
+
+static void
set_left_handed_all (MsdMouseManager *manager,
gboolean mouse_left_handed,
gboolean touchpad_left_handed)