[mutter] monitor-config-manager: Add clone_logical_monitor_config_list helper
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-config-manager: Add clone_logical_monitor_config_list helper
- Date: Fri, 7 Feb 2020 13:23:43 +0000 (UTC)
commit 0d185b21fdd9517ee95e7204ebca1bd94a0f4529
Author: Hans de Goede <hdegoede redhat com>
Date: Wed Dec 11 10:46:31 2019 +0100
monitor-config-manager: Add clone_logical_monitor_config_list helper
Add a clone_logical_monitor_config_list helper function for making a deep
copy of MetaLogicalMonitorConfig lists.
This is a preparation patch for honoring accelerometer value changes when
there is more than 1 monitor.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
src/backends/meta-monitor-config-manager.c | 66 +++++++++++++++++++++++-------
1 file changed, 52 insertions(+), 14 deletions(-)
---
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index d11f4745b..e2a5ecd3d 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -850,6 +850,55 @@ meta_monitor_config_manager_create_suggested (MetaMonitorConfigManager *config_m
META_MONITORS_CONFIG_FLAG_NONE);
}
+static GList *
+clone_monitor_config_list (GList *monitor_configs_in)
+{
+ MetaMonitorConfig *monitor_config_in;
+ MetaMonitorConfig *monitor_config_out;
+ GList *monitor_configs_out = NULL;
+ GList *l;
+
+ for (l = monitor_configs_in; l; l = l->next)
+ {
+ monitor_config_in = l->data;
+ monitor_config_out = g_new0 (MetaMonitorConfig, 1);
+ *monitor_config_out = (MetaMonitorConfig) {
+ .monitor_spec = meta_monitor_spec_clone (monitor_config_in->monitor_spec),
+ .mode_spec = g_memdup (monitor_config_in->mode_spec,
+ sizeof (MetaMonitorModeSpec)),
+ .enable_underscanning = monitor_config_in->enable_underscanning
+ };
+ monitor_configs_out =
+ g_list_append (monitor_configs_out, monitor_config_out);
+ }
+
+ return monitor_configs_out;
+}
+
+static GList *
+clone_logical_monitor_config_list (GList *logical_monitor_configs_in)
+{
+ MetaLogicalMonitorConfig *logical_monitor_config_in;
+ MetaLogicalMonitorConfig *logical_monitor_config_out;
+ GList *logical_monitor_configs_out = NULL;
+ GList *l;
+
+ for (l = logical_monitor_configs_in; l; l = l->next)
+ {
+ logical_monitor_config_in = l->data;
+
+ logical_monitor_config_out =
+ g_memdup (logical_monitor_config_in, sizeof (MetaLogicalMonitorConfig));
+ logical_monitor_config_out->monitor_configs =
+ clone_monitor_config_list (logical_monitor_config_in->monitor_configs);
+
+ logical_monitor_configs_out =
+ g_list_append (logical_monitor_configs_out, logical_monitor_config_out);
+ }
+
+ return logical_monitor_configs_out;
+}
+
static MetaMonitorsConfig *
create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
gboolean rotate,
@@ -860,8 +909,6 @@ create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
MetaLogicalMonitorConfig *current_logical_monitor_config;
GList *logical_monitor_configs;
MetaLogicalMonitorLayoutMode layout_mode;
- MetaMonitorConfig *monitor_config;
- MetaMonitorConfig *current_monitor_config;
if (!meta_monitor_manager_get_is_builtin_display_on (config_manager->monitor_manager))
return NULL;
@@ -897,17 +944,9 @@ create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
if (g_list_length (current_logical_monitor_config->monitor_configs) != 1)
return NULL;
- current_monitor_config = current_logical_monitor_config->monitor_configs->data;
-
- monitor_config = g_new0 (MetaMonitorConfig, 1);
- *monitor_config = (MetaMonitorConfig) {
- .monitor_spec = meta_monitor_spec_clone (current_monitor_config->monitor_spec),
- .mode_spec = g_memdup (current_monitor_config->mode_spec, sizeof (MetaMonitorModeSpec)),
- .enable_underscanning = current_monitor_config->enable_underscanning
- };
-
- logical_monitor_config = g_memdup (current_logical_monitor_config, sizeof (MetaLogicalMonitorConfig));
- logical_monitor_config->monitor_configs = g_list_append (NULL, monitor_config);
+ logical_monitor_configs =
+ clone_logical_monitor_config_list (config_manager->current_config->logical_monitor_configs);
+ logical_monitor_config = logical_monitor_configs->data;
logical_monitor_config->transform = transform;
if (meta_monitor_transform_is_rotated (current_logical_monitor_config->transform) !=
@@ -918,7 +957,6 @@ create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
logical_monitor_config->layout.height = temp;
}
- logical_monitor_configs = g_list_append (NULL, logical_monitor_config);
layout_mode = config_manager->current_config->layout_mode;
return meta_monitors_config_new (monitor_manager,
logical_monitor_configs,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]