[mutter/wip/tablet-protocol-v2: 34/48] backends: Store mappable devices' info in the hashtable



commit 82023ce56d080e4e5a277d5f5ff8f05f21c3d9dd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri May 13 14:28:52 2016 +0200

    backends: Store mappable devices' info in the hashtable
    
    Instead of as closure data. We will need to store (and query) more
    per-device info, so access to this struct is necessary.

 src/backends/meta-input-settings.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index d5d1757..5d9e940 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -828,15 +828,22 @@ monitors_changed_cb (MetaMonitorManager *monitor_manager,
 {
   MetaInputSettingsPrivate *priv;
   ClutterInputDevice *device;
-  GSettings *settings;
+  DeviceMappingInfo *info;
   GHashTableIter iter;
 
   priv = meta_input_settings_get_instance_private (input_settings);
   g_hash_table_iter_init (&iter, priv->mappable_devices);
 
   while (g_hash_table_iter_next (&iter, (gpointer *) &device,
-                                 (gpointer *) &settings))
-    update_device_display (input_settings, settings, device);
+                                 (gpointer *) &info))
+    update_device_display (input_settings, info->settings, device);
+}
+
+static void
+device_mapping_info_free (DeviceMappingInfo *info)
+{
+  g_object_unref (info->settings);
+  g_slice_free (DeviceMappingInfo, info);
 }
 
 static gboolean
@@ -854,16 +861,15 @@ check_add_mappable_device (MetaInputSettings  *input_settings,
 
   priv = meta_input_settings_get_instance_private (input_settings);
 
-  info = g_new0 (DeviceMappingInfo, 1);
+  info = g_slice_new0 (DeviceMappingInfo);
   info->input_settings = input_settings;
   info->device = device;
   info->settings = settings;
 
-  g_signal_connect_data (settings, "changed",
-                         G_CALLBACK (mapped_device_changed_cb),
-                         info, (GClosureNotify) g_free, 0);
+  g_signal_connect (settings, "changed",
+                    G_CALLBACK (mapped_device_changed_cb), NULL);
 
-  g_hash_table_insert (priv->mappable_devices, device, settings);
+  g_hash_table_insert (priv->mappable_devices, device, info);
 
   apply_mappable_device_settings (input_settings, info);
 
@@ -980,7 +986,7 @@ meta_input_settings_init (MetaInputSettings *settings)
                     G_CALLBACK (meta_input_settings_changed_cb), settings);
 
   priv->mappable_devices =
-    g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_object_unref);
+    g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) device_mapping_info_free);
 
   priv->monitor_manager = g_object_ref (meta_monitor_manager_get ());
   g_signal_connect (priv->monitor_manager, "monitors-changed",


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