Blame SOURCES/0001-backends-Monitor-changes-in-active-tools-settings.patch

e3f29c
From 62f0fb12b1fa946779f0efa406159a355811fdc5 Mon Sep 17 00:00:00 2001
e3f29c
From: Carlos Garnacho <carlosg@gnome.org>
e3f29c
Date: Mon, 19 Feb 2018 16:50:52 +0100
e3f29c
Subject: [PATCH] backends: Monitor changes in active tools' settings
e3f29c
e3f29c
So the changes can be instantly applied while the tool is in proximity.
e3f29c
Before we would just do it on proximity-in, which doesn't provide a
e3f29c
good look&feel while modifying the tool settings in g-c-c.
e3f29c
e3f29c
https://gitlab.gnome.org/GNOME/mutter/issues/38
e3f29c
e3f29c
Closes: #38
e3f29c
---
e3f29c
 src/backends/meta-input-settings.c | 71 ++++++++++++++++++++++++++++++++++++--
e3f29c
 1 file changed, 68 insertions(+), 3 deletions(-)
e3f29c
e3f29c
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
e3f29c
index 0658755..ec0fc9f 100644
e3f29c
--- a/src/backends/meta-input-settings.c
e3f29c
+++ b/src/backends/meta-input-settings.c
e3f29c
@@ -41,6 +41,16 @@ static GQuark quark_tool_settings = 0;
e3f29c
 
e3f29c
 typedef struct _MetaInputSettingsPrivate MetaInputSettingsPrivate;
e3f29c
 typedef struct _DeviceMappingInfo DeviceMappingInfo;
e3f29c
+typedef struct _CurrentToolInfo CurrentToolInfo;
e3f29c
+
e3f29c
+struct _CurrentToolInfo
e3f29c
+{
e3f29c
+  MetaInputSettings *input_settings;
e3f29c
+  ClutterInputDevice *device;
e3f29c
+  ClutterInputDeviceTool *tool;
e3f29c
+  GSettings *settings;
e3f29c
+  guint changed_id;
e3f29c
+};
e3f29c
 
e3f29c
 struct _DeviceMappingInfo
e3f29c
 {
e3f29c
@@ -68,6 +78,8 @@ struct _MetaInputSettingsPrivate
e3f29c
 
e3f29c
   GHashTable *mappable_devices;
e3f29c
 
e3f29c
+  GHashTable *current_tools;
e3f29c
+
e3f29c
   ClutterVirtualInputDevice *virtual_pad_keyboard;
e3f29c
 
e3f29c
 #ifdef HAVE_LIBWACOM
e3f29c
@@ -144,6 +156,7 @@ meta_input_settings_dispose (GObject *object)
e3f29c
   g_clear_object (&priv->keyboard_settings);
e3f29c
   g_clear_object (&priv->gsd_settings);
e3f29c
   g_clear_pointer (&priv->mappable_devices, g_hash_table_unref);
e3f29c
+  g_clear_pointer (&priv->current_tools, g_hash_table_unref);
e3f29c
 
e3f29c
   if (priv->monitors_changed_id && priv->monitor_manager)
e3f29c
     {
e3f29c
@@ -1510,22 +1523,71 @@ meta_input_settings_device_removed (ClutterDeviceManager *device_manager,
e3f29c
 
e3f29c
   priv = meta_input_settings_get_instance_private (input_settings);
e3f29c
   g_hash_table_remove (priv->mappable_devices, device);
e3f29c
+  g_hash_table_remove (priv->current_tools, device);
e3f29c
 
e3f29c
   if (g_hash_table_remove (priv->two_finger_devices, device) &&
e3f29c
       g_hash_table_size (priv->two_finger_devices) == 0)
e3f29c
     apply_device_settings (input_settings, NULL);
e3f29c
 }
e3f29c
 
e3f29c
+static void
e3f29c
+current_tool_changed_cb (GSettings  *settings,
e3f29c
+                         const char *key,
e3f29c
+                         gpointer    user_data)
e3f29c
+{
e3f29c
+  CurrentToolInfo *info = user_data;
e3f29c
+
e3f29c
+  apply_stylus_settings (info->input_settings, info->device, info->tool);
e3f29c
+}
e3f29c
+
e3f29c
+static CurrentToolInfo *
e3f29c
+current_tool_info_new (MetaInputSettings      *input_settings,
e3f29c
+                       ClutterInputDevice     *device,
e3f29c
+                       ClutterInputDeviceTool *tool)
e3f29c
+{
e3f29c
+  CurrentToolInfo *info;
e3f29c
+
e3f29c
+  info = g_new0 (CurrentToolInfo, 1);
e3f29c
+  info->input_settings = input_settings;
e3f29c
+  info->device = device;
e3f29c
+  info->tool = tool;
e3f29c
+  info->settings = lookup_tool_settings (tool, device);
e3f29c
+  info->changed_id =
e3f29c
+    g_signal_connect (info->settings, "changed",
e3f29c
+                      G_CALLBACK (current_tool_changed_cb),
e3f29c
+                      info);
e3f29c
+  return info;
e3f29c
+}
e3f29c
+
e3f29c
+static void
e3f29c
+current_tool_info_free (CurrentToolInfo *info)
e3f29c
+{
e3f29c
+  g_signal_handler_disconnect (info->settings, info->changed_id);
e3f29c
+  g_free (info);
e3f29c
+}
e3f29c
+
e3f29c
 static void
e3f29c
 meta_input_settings_tool_changed (ClutterDeviceManager   *device_manager,
e3f29c
                                   ClutterInputDevice     *device,
e3f29c
                                   ClutterInputDeviceTool *tool,
e3f29c
                                   MetaInputSettings      *input_settings)
e3f29c
 {
e3f29c
-  if (!tool)
e3f29c
-    return;
e3f29c
+  MetaInputSettingsPrivate *priv;
e3f29c
 
e3f29c
-  apply_stylus_settings (input_settings, device, tool);
e3f29c
+  priv = meta_input_settings_get_instance_private (input_settings);
e3f29c
+
e3f29c
+  if (tool)
e3f29c
+    {
e3f29c
+      CurrentToolInfo *current_tool;
e3f29c
+
e3f29c
+      current_tool = current_tool_info_new (input_settings, device, tool);
e3f29c
+      g_hash_table_insert (priv->current_tools, device, current_tool);
e3f29c
+      apply_stylus_settings (input_settings, device, tool);
e3f29c
+    }
e3f29c
+  else
e3f29c
+    {
e3f29c
+      g_hash_table_remove (priv->current_tools, device);
e3f29c
+    }
e3f29c
 }
e3f29c
 
e3f29c
 static void
e3f29c
@@ -1616,6 +1678,9 @@ meta_input_settings_init (MetaInputSettings *settings)
e3f29c
   priv->mappable_devices =
e3f29c
     g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) device_mapping_info_free);
e3f29c
 
e3f29c
+  priv->current_tools =
e3f29c
+    g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) current_tool_info_free);
e3f29c
+
e3f29c
   priv->monitor_manager = g_object_ref (meta_monitor_manager_get ());
e3f29c
   g_signal_connect (priv->monitor_manager, "monitors-changed-internal",
e3f29c
                     G_CALLBACK (monitors_changed_cb), settings);
e3f29c
-- 
e3f29c
2.16.1
e3f29c