|
|
79df40 |
From f70261f80302d9f4ffd62f9dbae3d515b5778467 Mon Sep 17 00:00:00 2001
|
|
|
79df40 |
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
|
|
79df40 |
Date: Sun, 21 Jul 2019 18:18:14 +0200
|
|
|
79df40 |
Subject: [PATCH 18/28] monitor-config-manager: Always free temporary region on
|
|
|
79df40 |
error
|
|
|
79df40 |
|
|
|
79df40 |
During the config parsing we are allocating a temporary rectangles region
|
|
|
79df40 |
however in case that we find an error we return prematurely but in some cases
|
|
|
79df40 |
(when not using identical global scale, or when not using adjacent neighbors)
|
|
|
79df40 |
we didn't free the region list before.
|
|
|
79df40 |
|
|
|
79df40 |
Instead of caring of doing this manually everytime, let's just use an
|
|
|
79df40 |
auto-pointer to manage the region lifecycle.
|
|
|
79df40 |
|
|
|
79df40 |
https://gitlab.gnome.org/GNOME/mutter/merge_requests/682
|
|
|
79df40 |
---
|
|
|
79df40 |
src/backends/meta-monitor-config-manager.c | 7 +------
|
|
|
79df40 |
1 file changed, 1 insertion(+), 6 deletions(-)
|
|
|
79df40 |
|
|
|
79df40 |
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
|
|
|
79df40 |
index cb67e11e7..59a20d449 100644
|
|
|
79df40 |
--- a/src/backends/meta-monitor-config-manager.c
|
|
|
79df40 |
+++ b/src/backends/meta-monitor-config-manager.c
|
|
|
79df40 |
@@ -1578,134 +1578,129 @@ meta_logical_monitor_configs_have_monitor (GList *logical_monitor_conf
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
|
|
|
79df40 |
GList *k;
|
|
|
79df40 |
|
|
|
79df40 |
for (k = logical_monitor_config->monitor_configs; k; k = k->next)
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaMonitorConfig *monitor_config = k->data;
|
|
|
79df40 |
|
|
|
79df40 |
if (meta_monitor_spec_equals (monitor_spec,
|
|
|
79df40 |
monitor_config->monitor_spec))
|
|
|
79df40 |
return TRUE;
|
|
|
79df40 |
}
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
static gboolean
|
|
|
79df40 |
meta_monitors_config_is_monitor_enabled (MetaMonitorsConfig *config,
|
|
|
79df40 |
MetaMonitorSpec *monitor_spec)
|
|
|
79df40 |
{
|
|
|
79df40 |
return meta_logical_monitor_configs_have_monitor (config->logical_monitor_configs,
|
|
|
79df40 |
monitor_spec);
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
gboolean
|
|
|
79df40 |
meta_verify_monitors_config (MetaMonitorsConfig *config,
|
|
|
79df40 |
MetaMonitorManager *monitor_manager,
|
|
|
79df40 |
GError **error)
|
|
|
79df40 |
{
|
|
|
79df40 |
+ g_autoptr (GList) region = NULL;
|
|
|
79df40 |
int min_x, min_y;
|
|
|
79df40 |
gboolean has_primary;
|
|
|
79df40 |
- GList *region;
|
|
|
79df40 |
GList *l;
|
|
|
79df40 |
gboolean global_scale_required;
|
|
|
79df40 |
|
|
|
79df40 |
if (!config->logical_monitor_configs)
|
|
|
79df40 |
{
|
|
|
79df40 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
79df40 |
"Monitors config incomplete");
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
global_scale_required =
|
|
|
79df40 |
!!(meta_monitor_manager_get_capabilities (monitor_manager) &
|
|
|
79df40 |
META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED);
|
|
|
79df40 |
|
|
|
79df40 |
min_x = INT_MAX;
|
|
|
79df40 |
min_y = INT_MAX;
|
|
|
79df40 |
- region = NULL;
|
|
|
79df40 |
has_primary = FALSE;
|
|
|
79df40 |
for (l = config->logical_monitor_configs; l; l = l->next)
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
|
|
|
79df40 |
|
|
|
79df40 |
if (global_scale_required)
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaLogicalMonitorConfig *prev_logical_monitor_config =
|
|
|
79df40 |
l->prev ? l->prev->data : NULL;
|
|
|
79df40 |
|
|
|
79df40 |
if (prev_logical_monitor_config &&
|
|
|
79df40 |
(prev_logical_monitor_config->scale !=
|
|
|
79df40 |
logical_monitor_config->scale))
|
|
|
79df40 |
{
|
|
|
79df40 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
79df40 |
"Logical monitor scales must be identical");
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
if (meta_rectangle_overlaps_with_region (region,
|
|
|
79df40 |
&logical_monitor_config->layout))
|
|
|
79df40 |
{
|
|
|
79df40 |
- g_list_free (region);
|
|
|
79df40 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
79df40 |
"Logical monitors overlap");
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
if (has_primary && logical_monitor_config->is_primary)
|
|
|
79df40 |
{
|
|
|
79df40 |
- g_list_free (region);
|
|
|
79df40 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
79df40 |
"Config contains multiple primary logical monitors");
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
else if (logical_monitor_config->is_primary)
|
|
|
79df40 |
{
|
|
|
79df40 |
has_primary = TRUE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
if (!has_adjecent_neighbour (config, logical_monitor_config))
|
|
|
79df40 |
{
|
|
|
79df40 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
79df40 |
"Logical monitors not adjecent");
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
min_x = MIN (logical_monitor_config->layout.x, min_x);
|
|
|
79df40 |
min_y = MIN (logical_monitor_config->layout.y, min_y);
|
|
|
79df40 |
|
|
|
79df40 |
region = g_list_prepend (region, &logical_monitor_config->layout);
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
- g_list_free (region);
|
|
|
79df40 |
-
|
|
|
79df40 |
for (l = config->disabled_monitor_specs; l; l = l->next)
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaMonitorSpec *monitor_spec = l->data;
|
|
|
79df40 |
|
|
|
79df40 |
if (meta_monitors_config_is_monitor_enabled (config, monitor_spec))
|
|
|
79df40 |
{
|
|
|
79df40 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
79df40 |
"Assigned monitor explicitly disabled");
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
if (min_x != 0 || min_y != 0)
|
|
|
79df40 |
{
|
|
|
79df40 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
79df40 |
"Logical monitors positions are offset");
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
if (!has_primary)
|
|
|
79df40 |
{
|
|
|
79df40 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
79df40 |
"Config is missing primary logical");
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
return TRUE;
|
|
|
79df40 |
}
|
|
|
79df40 |
--
|
|
|
79df40 |
2.26.2
|
|
|
79df40 |
|