[mutter/wip/carlosg/left-handed-tablet-touchpads] backends: Map left-handed in tablet "touchpads" together with the tablet



commit f82a0a70c0e80a335ca28c5f8d9f773d2d389f73
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jun 7 12:31:31 2019 +0200

    backends: Map left-handed in tablet "touchpads" together with the tablet
    
    Avoid those devices when applying the configuration to touchpads, and ensure
    the devices grouped with the tablet are all synchronized wrt the left handed
    setting.
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/issues/562

 src/backends/meta-input-settings.c | 45 +++++++++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 847ba1bea..61a8d4d72 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -302,9 +302,30 @@ update_touchpad_left_handed (MetaInputSettings  *input_settings,
     }
   else
     {
-      settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
-                                 input_settings_class->set_left_handed,
-                                 enabled);
+      GSList *devices, *l;
+
+      devices = meta_input_settings_get_devices (input_settings,
+                                                 CLUTTER_TOUCHPAD_DEVICE);
+
+      for (l = devices; l; l = l->next)
+        {
+#ifdef HAVE_LIBWACOM
+          WacomDevice *wacom_device;
+
+          wacom_device = meta_input_settings_get_tablet_wacom_device (input_settings,
+                                                                      device);
+          /* "Touchpads" with a wacom description will be rotated along their tablets */
+          if (wacom_device &&
+              (libwacom_get_integration_flags (wacom_device) != WACOM_DEVICE_INTEGRATED_NONE))
+            continue;
+#endif
+
+          settings_device_set_bool_setting (input_settings, l->data,
+                                            input_settings_class->set_left_handed,
+                                            enabled);
+        }
+
+      g_slist_free (devices);
     }
 }
 
@@ -1068,8 +1089,12 @@ update_tablet_left_handed (MetaInputSettings  *input_settings,
                            ClutterInputDevice *device)
 {
   MetaInputSettingsClass *input_settings_class;
+  MetaInputSettingsPrivate *priv;
+  const GSList *devices, *l;
   gboolean enabled;
 
+  priv = meta_input_settings_get_instance_private (input_settings);
+
   if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
       clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
       clutter_input_device_get_device_type (device) != CLUTTER_ERASER_DEVICE &&
@@ -1091,10 +1116,18 @@ update_tablet_left_handed (MetaInputSettings  *input_settings,
 
   input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings);
   enabled = g_settings_get_boolean (settings, "left-handed");
+  devices = clutter_device_manager_peek_devices (priv->device_manager);
 
-  settings_device_set_bool_setting (input_settings, device,
-                                    input_settings_class->set_left_handed,
-                                    enabled);
+  for (l = devices; l; l = l->next)
+    {
+      if (l->data != device &&
+          !clutter_input_device_is_grouped (device, l->data))
+        continue;
+
+      settings_device_set_bool_setting (input_settings, l->data,
+                                        input_settings_class->set_left_handed,
+                                        enabled);
+    }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]