From 1dd121002f46f1160a7762a26297240af900e4b8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 13 May 2016 14:28:52 +0200 Subject: [PATCH] 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 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c index 007db20e2..3aeb09cf5 100644 --- a/src/backends/meta-input-settings.c +++ b/src/backends/meta-input-settings.c @@ -837,15 +837,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 @@ -863,16 +870,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), info); - 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); @@ -989,7 +995,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",