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

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