Blame SOURCES/0001-backends-Check-both-input-settings-and-mapper-for-ta.patch

e82d74
From 20fcc3e045287c1ca591f3e795b19e120479a89a Mon Sep 17 00:00:00 2001
e82d74
From: Carlos Garnacho <carlosg@gnome.org>
e82d74
Date: Wed, 12 Feb 2020 20:26:56 +0100
e82d74
Subject: [PATCH 1/2] backends/x11: Implement is_grouped for X11
e82d74
e82d74
If the devices have a wacom description, compare those. Otherwise,
e82d74
look up the devices' VID:PID, if they match they should also be
e82d74
grouped.
e82d74
e82d74
https://gitlab.gnome.org/GNOME/mutter/merge_requests/971
e82d74
---
e82d74
 .../clutter/x11/clutter-input-device-xi2.c    | 25 +++++++++++++++++++
e82d74
 1 file changed, 25 insertions(+)
e82d74
e82d74
diff --git a/clutter/clutter/x11/clutter-input-device-xi2.c b/clutter/clutter/x11/clutter-input-device-xi2.c
e82d74
index ae2fa27..9eca34d 100644
e82d74
--- a/clutter/clutter/x11/clutter-input-device-xi2.c
e82d74
+++ b/clutter/clutter/x11/clutter-input-device-xi2.c
e82d74
@@ -98,6 +98,31 @@ static gboolean
e82d74
 clutter_input_device_xi2_is_grouped (ClutterInputDevice *device,
e82d74
                                      ClutterInputDevice *other_device)
e82d74
 {
e82d74
+#ifdef HAVE_LIBWACOM
e82d74
+  ClutterInputDeviceXI2 *device_x11 = CLUTTER_INPUT_DEVICE_XI2 (device);
e82d74
+  ClutterInputDeviceXI2 *other_device_x11 = CLUTTER_INPUT_DEVICE_XI2 (other_device);
e82d74
+
e82d74
+  if (device_x11->wacom_device &&
e82d74
+      other_device_x11->wacom_device &&
e82d74
+      libwacom_compare (device_x11->wacom_device,
e82d74
+                        other_device_x11->wacom_device,
e82d74
+                        WCOMPARE_NORMAL) == 0)
e82d74
+    return TRUE;
e82d74
+#endif
e82d74
+
e82d74
+  /* Devices with the same VID:PID get grouped together */
e82d74
+  if (clutter_input_device_get_vendor_id (device) &&
e82d74
+      clutter_input_device_get_product_id (device) &&
e82d74
+      clutter_input_device_get_vendor_id (other_device) &&
e82d74
+      clutter_input_device_get_product_id (other_device))
e82d74
+    {
e82d74
+      if (strcmp (clutter_input_device_get_vendor_id (device),
e82d74
+                  clutter_input_device_get_vendor_id (other_device)) == 0 &&
e82d74
+          strcmp (clutter_input_device_get_product_id (device),
e82d74
+                  clutter_input_device_get_product_id (other_device)) == 0)
e82d74
+        return TRUE;
e82d74
+    }
e82d74
+
e82d74
   return FALSE;
e82d74
 }
e82d74
 
e82d74
-- 
e82d74
2.24.1
e82d74
e82d74
e82d74
From 5914ab9ac79ce42da054036c4a8f118a3a868cc0 Mon Sep 17 00:00:00 2001
1a3082
From: Carlos Garnacho <carlosg@gnome.org>
1a3082
Date: Fri, 13 Dec 2019 15:26:05 +0100
e82d74
Subject: [PATCH 2/2] backends: Check both input settings and mapper for tablet
1a3082
 monitors
1a3082
1a3082
The upper layers (OSDs basically) want to know the monitor that a
1a3082
tablet is currently assigned to, not the monitor just as configured
1a3082
through settings.
1a3082
1a3082
This broke proper OSD positioning for display-attached tablets since
1a3082
commit 87858a4e01d9, as the MetaInputMapper kicks in precisely when
1a3082
there is no configured monitor for the given device.
1a3082
1a3082
Consulting both about the assigned output will make OSDs pop up
1a3082
again in the right place.
1a3082
1a3082
https://gitlab.gnome.org/GNOME/mutter/merge_requests/971
1a3082
---
e82d74
 src/backends/meta-input-mapper-private.h |  3 ++
e82d74
 src/backends/meta-input-mapper.c         | 26 ++++++++++++
e82d74
 src/backends/meta-input-settings.c       | 54 +++++++++++++++++++++++-
e82d74
 3 files changed, 81 insertions(+), 2 deletions(-)
1a3082
1a3082
diff --git a/src/backends/meta-input-mapper-private.h b/src/backends/meta-input-mapper-private.h
e82d74
index 3431457..cdfdccd 100644
1a3082
--- a/src/backends/meta-input-mapper-private.h
1a3082
+++ b/src/backends/meta-input-mapper-private.h
1a3082
@@ -42,5 +42,8 @@ ClutterInputDevice *
1a3082
 meta_input_mapper_get_logical_monitor_device (MetaInputMapper        *mapper,
1a3082
                                               MetaLogicalMonitor     *logical_monitor,
1a3082
                                               ClutterInputDeviceType  device_type);
1a3082
+MetaLogicalMonitor *
1a3082
+meta_input_mapper_get_device_logical_monitor (MetaInputMapper *mapper,
1a3082
+                                              ClutterInputDevice *device);
1a3082
 
1a3082
 #endif /* META_INPUT_MAPPER_H */
1a3082
diff --git a/src/backends/meta-input-mapper.c b/src/backends/meta-input-mapper.c
e82d74
index fc4f3bd..fe02ab8 100644
1a3082
--- a/src/backends/meta-input-mapper.c
1a3082
+++ b/src/backends/meta-input-mapper.c
e82d74
@@ -675,3 +675,29 @@ meta_input_mapper_get_logical_monitor_device (MetaInputMapper        *mapper,
1a3082
 
1a3082
   return NULL;
1a3082
 }
1a3082
+
1a3082
+MetaLogicalMonitor *
1a3082
+meta_input_mapper_get_device_logical_monitor (MetaInputMapper    *mapper,
1a3082
+                                              ClutterInputDevice *device)
1a3082
+{
1a3082
+  MetaMapperOutputInfo *output;
1a3082
+  MetaLogicalMonitor *logical_monitor;
1a3082
+  GHashTableIter iter;
1a3082
+  GList *l;
1a3082
+
1a3082
+  g_hash_table_iter_init (&iter, mapper->output_devices);
1a3082
+
1a3082
+  while (g_hash_table_iter_next (&iter, (gpointer *) &logical_monitor,
1a3082
+                                 (gpointer *) &output))
1a3082
+    {
1a3082
+      for (l = output->input_devices; l; l = l->next)
1a3082
+        {
1a3082
+          MetaMapperInputInfo *input = l->data;
1a3082
+
1a3082
+          if (input->device == device)
1a3082
+            return logical_monitor;
1a3082
+        }
1a3082
+    }
1a3082
+
1a3082
+  return NULL;
1a3082
+}
1a3082
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
e82d74
index b84595e..ab80bee 100644
1a3082
--- a/src/backends/meta-input-settings.c
1a3082
+++ b/src/backends/meta-input-settings.c
e82d74
@@ -1937,6 +1937,42 @@ meta_input_settings_get_tablet_settings (MetaInputSettings  *settings,
e82d74
   return info ? g_object_ref (info->settings) : NULL;
e82d74
 }
e82d74
 
e82d74
+static ClutterInputDevice *
e82d74
+find_grouped_pen (MetaInputSettings  *settings,
e82d74
+                  ClutterInputDevice *device)
e82d74
+{
e82d74
+  MetaInputSettingsPrivate *priv;
e82d74
+  GSList *l, *devices;
e82d74
+  ClutterInputDeviceType device_type;
e82d74
+  ClutterInputDevice *pen = NULL;
e82d74
+
e82d74
+  device_type = clutter_input_device_get_device_type (device);
e82d74
+
e82d74
+  if (device_type == CLUTTER_TABLET_DEVICE ||
e82d74
+      device_type == CLUTTER_PEN_DEVICE)
e82d74
+    return device;
e82d74
+
e82d74
+  priv = meta_input_settings_get_instance_private (settings);
e82d74
+  devices = clutter_device_manager_peek_devices (priv->device_manager);
e82d74
+
e82d74
+  for (l = devices; l; l = l->next)
e82d74
+    {
e82d74
+      ClutterInputDevice *device = l->data;
e82d74
+
e82d74
+      device_type = clutter_input_device_get_device_type (l->data);
e82d74
+
e82d74
+      if ((device_type == CLUTTER_TABLET_DEVICE ||
e82d74
+           device_type == CLUTTER_PEN_DEVICE) &&
e82d74
+          clutter_input_device_is_grouped (device, l->data))
e82d74
+        {
e82d74
+          pen = l->data;
e82d74
+          break;
e82d74
+        }
e82d74
+    }
e82d74
+
e82d74
+  return pen;
e82d74
+}
e82d74
+
e82d74
 MetaLogicalMonitor *
e82d74
 meta_input_settings_get_tablet_logical_monitor (MetaInputSettings  *settings,
e82d74
                                                 ClutterInputDevice *device)
e82d74
@@ -1948,13 +1984,27 @@ meta_input_settings_get_tablet_logical_monitor (MetaInputSettings  *settings,
e82d74
   g_return_val_if_fail (META_IS_INPUT_SETTINGS (settings), NULL);
e82d74
   g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
e82d74
 
e82d74
+  if (clutter_input_device_get_device_type (device) == CLUTTER_PAD_DEVICE)
e82d74
+    {
e82d74
+      device = find_grouped_pen (settings, device);
e82d74
+      if (!device)
e82d74
+        return NULL;
e82d74
+    }
e82d74
+
e82d74
   priv = meta_input_settings_get_instance_private (settings);
e82d74
   info = g_hash_table_lookup (priv->mappable_devices, device);
1a3082
   if (!info)
1a3082
     return NULL;
1a3082
 
1a3082
-  meta_input_settings_find_monitor (settings, info->settings, device,
1a3082
-                                    NULL, &logical_monitor);
1a3082
+  logical_monitor =
1a3082
+    meta_input_mapper_get_device_logical_monitor (priv->input_mapper, device);
1a3082
+
1a3082
+  if (!logical_monitor)
1a3082
+    {
1a3082
+      meta_input_settings_find_monitor (settings, info->settings, device,
1a3082
+                                        NULL, &logical_monitor);
1a3082
+    }
1a3082
+
1a3082
   return logical_monitor;
1a3082
 }
1a3082
 
1a3082
-- 
e82d74
2.24.1
1a3082