[gnome-flashback] monitor-conifig-manager: generate primary monitor config with others
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] monitor-conifig-manager: generate primary monitor config with others
- Date: Sat, 23 Oct 2021 18:48:45 +0000 (UTC)
commit fe9018bdcac5b1b0865d0b0c86deb517d129c889
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Sep 13 20:34:29 2021 +0300
monitor-conifig-manager: generate primary monitor config with others
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/-/commit/e59da5ad83f3
backends/gf-monitor-config-manager.c | 50 +++++++++++-------------------------
1 file changed, 15 insertions(+), 35 deletions(-)
---
diff --git a/backends/gf-monitor-config-manager.c b/backends/gf-monitor-config-manager.c
index c6d548f..f047dbd 100644
--- a/backends/gf-monitor-config-manager.c
+++ b/backends/gf-monitor-config-manager.c
@@ -146,7 +146,8 @@ monitor_matches_rule (GfMonitor *monitor,
static GList *
find_monitors (GfMonitorManager *monitor_manager,
- MonitorMatchRule match_rule)
+ MonitorMatchRule match_rule,
+ GfMonitor *not_this_one)
{
GList *result;
GList *monitors;
@@ -159,6 +160,9 @@ find_monitors (GfMonitorManager *monitor_manager,
{
GfMonitor *monitor = l->data;
+ if (not_this_one != NULL && monitor == not_this_one)
+ continue;
+
if (monitor_matches_rule (monitor, monitor_manager, match_rule))
result = g_list_prepend (result, monitor);
}
@@ -175,7 +179,7 @@ find_monitor_with_highest_preferred_resolution (GfMonitorManager *monitor_manage
int largest_area = 0;
GfMonitor *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)
{
@@ -519,10 +523,8 @@ create_monitors_config (GfMonitorConfigManager *config_manager,
GfMonitorsConfigFlag config_flags)
{
GfMonitorManager *monitor_manager = config_manager->monitor_manager;
- GfLogicalMonitorConfig *primary_logical_monitor_config = NULL;
GfMonitor *primary_monitor;
GfLogicalMonitorLayoutMode layout_mode;
- gboolean has_suggested_position;
GList *logical_monitor_configs;
float scale;
int x, y;
@@ -535,47 +537,24 @@ create_monitors_config (GfMonitorConfigManager *config_manager,
if (!primary_monitor)
return NULL;
+ x = y = 0;
layout_mode = gf_monitor_manager_get_default_layout_mode (monitor_manager);
- switch (positioning)
- {
- case MONITOR_POSITIONING_SUGGESTED:
- has_suggested_position = gf_monitor_get_suggested_position (primary_monitor,
- &x,
- &y);
- g_assert (has_suggested_position);
- break;
-
- case MONITOR_POSITIONING_LINEAR:
- default:
- x = y = 0;
- 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);
-
monitors = NULL;
if (!(match_rule & MONITOR_MATCH_PRIMARY))
- monitors = find_monitors (monitor_manager, match_rule);
+ monitors = find_monitors (monitor_manager, match_rule, primary_monitor);
- x = primary_logical_monitor_config->layout.width;
+ /*
+ * 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);
for (l = monitors; l; l = l->next)
{
GfMonitor *monitor = l->data;
GfLogicalMonitorConfig *logical_monitor_config;
-
- if (monitor == primary_monitor)
- continue;
+ gboolean has_suggested_position;
switch (positioning)
{
@@ -602,6 +581,7 @@ create_monitors_config (GfMonitorConfigManager *config_manager,
scale,
layout_mode);
+ logical_monitor_config->is_primary = (monitor == primary_monitor);
logical_monitor_configs = g_list_append (logical_monitor_configs, logical_monitor_config);
x += logical_monitor_config->layout.width;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]