[mutter] monitor-conifig-manager: Generate primary monitor config with others
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-conifig-manager: Generate primary monitor config with others
- Date: Wed, 4 Aug 2021 14:30:25 +0000 (UTC)
commit e59da5ad83f334bdfbf83f3c1563cf4de8d2fccb
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Apr 3 16:25:10 2019 +0200
monitor-conifig-manager: Generate primary monitor config with others
Primary monitor is just the same of the other monitors, but it has a
primary monitor flag. Since the computation of the scaling isn't
dependent anymore on the computed configuration we can now generate the
primary monitor config together with the others.
However, we've to ensure that the primary monitor is the first of the
configs list in order to properly compute the positioning.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
src/backends/meta-monitor-config-manager.c | 46 ++++++++++--------------------
1 file changed, 15 insertions(+), 31 deletions(-)
---
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index a05f1425ab..aca753363b 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -588,7 +588,8 @@ monitor_matches_rule (MetaMonitor *monitor,
static GList *
find_monitors (MetaMonitorManager *monitor_manager,
- MonitorMatchRule match_rule)
+ MonitorMatchRule match_rule,
+ MetaMonitor *not_this_one)
{
GList *result = NULL;
GList *monitors, *l;
@@ -598,6 +599,9 @@ find_monitors (MetaMonitorManager *monitor_manager,
{
MetaMonitor *monitor = l->data;
+ if (not_this_one && monitor == not_this_one)
+ continue;
+
if (monitor_matches_rule (monitor, monitor_manager, match_rule))
result = g_list_prepend (result, monitor);
}
@@ -614,7 +618,7 @@ find_monitor_with_highest_preferred_resolution (MetaMonitorManager *monitor_mana
int largest_area = 0;
MetaMonitor *largest_monitor = NULL;
- monitors = find_monitors (monitor_manager, match_rule);
+ monitors = find_monitors (monitor_manager, match_rule, NULL);
for (l = monitors; l; l = l->next)
{
MetaMonitor *monitor = l->data;
@@ -850,8 +854,6 @@ create_monitors_config (MetaMonitorConfigManager *config_manager,
g_autolist (MetaLogicalMonitorConfig) logical_monitor_configs = NULL;
MetaMonitor *primary_monitor;
MetaLogicalMonitorLayoutMode layout_mode;
- MetaLogicalMonitorConfig *primary_logical_monitor_config;
- gboolean has_suggested_position;
float scale;
GList *l;
int x, y;
@@ -861,41 +863,22 @@ create_monitors_config (MetaMonitorConfigManager *config_manager,
if (!primary_monitor)
return NULL;
+ x = y = 0;
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
- switch (positioning)
- {
- case MONITOR_POSITIONING_LINEAR:
- x = y = 0;
- break;
- case MONITOR_POSITIONING_SUGGESTED:
- has_suggested_position =
- meta_monitor_get_suggested_position (primary_monitor, &x, &y);
- g_assert (has_suggested_position);
- break;
- }
-
- scale = compute_scale_for_monitor (monitor_manager, primary_monitor, NULL);
- primary_logical_monitor_config =
- create_preferred_logical_monitor_config (monitor_manager,
- primary_monitor,
- x, y, scale,
- layout_mode);
- primary_logical_monitor_config->is_primary = TRUE;
- logical_monitor_configs = g_list_append (NULL,
- primary_logical_monitor_config);
-
if (!(match_rule & MONITOR_MATCH_PRIMARY))
- monitors = find_monitors (monitor_manager, match_rule);
+ monitors = find_monitors (monitor_manager, match_rule, primary_monitor);
+
+ /* The primary monitor needs to be at the head of the list for the
+ * linear positioning to be correct.
+ */
+ monitors = g_list_prepend (monitors, primary_monitor);
- x = primary_logical_monitor_config->layout.width;
for (l = monitors; l; l = l->next)
{
MetaMonitor *monitor = l->data;
MetaLogicalMonitorConfig *logical_monitor_config;
-
- if (monitor == primary_monitor)
- continue;
+ gboolean has_suggested_position;
switch (positioning)
{
@@ -915,6 +898,7 @@ create_monitors_config (MetaMonitorConfigManager *config_manager,
monitor,
x, y, scale,
layout_mode);
+ logical_monitor_config->is_primary = (monitor == primary_monitor);
logical_monitor_configs = g_list_append (logical_monitor_configs,
logical_monitor_config);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]