|
|
657d8e |
From 4904f1a1e5b881dfd5a051c15acecb3232dc8207 Mon Sep 17 00:00:00 2001
|
|
|
657d8e |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
657d8e |
Date: Thu, 28 Jan 2016 15:26:33 +0100
|
|
|
657d8e |
Subject: [PATCH] monitor-manager: Consider external layout before default
|
|
|
657d8e |
linear config
|
|
|
657d8e |
|
|
|
657d8e |
In case of no existing configuration, we use a default layout of
|
|
|
657d8e |
aligning attached displays horizontally. This sidesteps any layout
|
|
|
657d8e |
configuration that is done externally, for instance via xorg.conf,
|
|
|
657d8e |
which is not desirable. Instead, base the initial configuration on
|
|
|
657d8e |
the existing layout if it passes some sanity checks before falling
|
|
|
657d8e |
back to the default linear config.
|
|
|
657d8e |
---
|
|
|
657d8e |
src/backends/meta-monitor-config-manager.c | 77 ++++++++++++++++++++++
|
|
|
657d8e |
src/backends/meta-monitor-config-manager.h | 2 +
|
|
|
657d8e |
src/backends/meta-monitor-manager.c | 19 ++++++
|
|
|
657d8e |
3 files changed, 98 insertions(+)
|
|
|
657d8e |
|
|
|
657d8e |
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
|
|
|
657d8e |
index 9a54ce50f..d64ca1f79 100644
|
|
|
657d8e |
--- a/src/backends/meta-monitor-config-manager.c
|
|
|
657d8e |
+++ b/src/backends/meta-monitor-config-manager.c
|
|
|
657d8e |
@@ -643,6 +643,83 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
|
|
|
657d8e |
return logical_monitor_config;
|
|
|
657d8e |
}
|
|
|
657d8e |
|
|
|
657d8e |
+static MetaLogicalMonitorConfig *
|
|
|
657d8e |
+create_logical_monitor_config_from_output (MetaMonitorManager *monitor_manager,
|
|
|
657d8e |
+ MetaMonitor *monitor,
|
|
|
657d8e |
+ MetaLogicalMonitorConfig *primary_logical_monitor_config,
|
|
|
657d8e |
+ MetaLogicalMonitorLayoutMode layout_mode)
|
|
|
657d8e |
+{
|
|
|
657d8e |
+ MetaOutput *output;
|
|
|
657d8e |
+ MetaCrtc *crtc;
|
|
|
657d8e |
+
|
|
|
657d8e |
+ output = meta_monitor_get_main_output (monitor);
|
|
|
657d8e |
+ crtc = meta_output_get_assigned_crtc (output);
|
|
|
657d8e |
+ return create_preferred_logical_monitor_config (monitor_manager,
|
|
|
657d8e |
+ monitor,
|
|
|
657d8e |
+ crtc->rect.x,
|
|
|
657d8e |
+ crtc->rect.y,
|
|
|
657d8e |
+ primary_logical_monitor_config,
|
|
|
657d8e |
+ layout_mode);
|
|
|
657d8e |
+}
|
|
|
657d8e |
+
|
|
|
657d8e |
+MetaMonitorsConfig *
|
|
|
657d8e |
+meta_monitor_config_manager_create_current (MetaMonitorConfigManager *config_manager)
|
|
|
657d8e |
+{
|
|
|
657d8e |
+ MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
|
|
|
657d8e |
+ GList *logical_monitor_configs;
|
|
|
657d8e |
+ MetaMonitor *primary_monitor;
|
|
|
657d8e |
+ MetaLogicalMonitorLayoutMode layout_mode;
|
|
|
657d8e |
+ MetaLogicalMonitorConfig *primary_logical_monitor_config;
|
|
|
657d8e |
+ GList *monitors;
|
|
|
657d8e |
+ GList *l;
|
|
|
657d8e |
+
|
|
|
657d8e |
+ if (meta_monitor_config_store_get_config_count (config_manager->config_store) > 0)
|
|
|
657d8e |
+ return NULL;
|
|
|
657d8e |
+
|
|
|
657d8e |
+ primary_monitor = find_primary_monitor (monitor_manager);
|
|
|
657d8e |
+ if (!primary_monitor || !meta_monitor_is_active (primary_monitor))
|
|
|
657d8e |
+ return NULL;
|
|
|
657d8e |
+
|
|
|
657d8e |
+ layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
|
|
|
657d8e |
+
|
|
|
657d8e |
+ primary_logical_monitor_config =
|
|
|
657d8e |
+ create_logical_monitor_config_from_output (monitor_manager,
|
|
|
657d8e |
+ primary_monitor,
|
|
|
657d8e |
+ NULL,
|
|
|
657d8e |
+ layout_mode);
|
|
|
657d8e |
+
|
|
|
657d8e |
+ primary_logical_monitor_config->is_primary = TRUE;
|
|
|
657d8e |
+ logical_monitor_configs = g_list_append (NULL,
|
|
|
657d8e |
+ primary_logical_monitor_config);
|
|
|
657d8e |
+
|
|
|
657d8e |
+ monitors = meta_monitor_manager_get_monitors (monitor_manager);
|
|
|
657d8e |
+ for (l = monitors; l; l = l->next)
|
|
|
657d8e |
+ {
|
|
|
657d8e |
+ MetaMonitor *monitor = l->data;
|
|
|
657d8e |
+ MetaLogicalMonitorConfig *logical_monitor_config;
|
|
|
657d8e |
+
|
|
|
657d8e |
+ if (monitor == primary_monitor)
|
|
|
657d8e |
+ continue;
|
|
|
657d8e |
+
|
|
|
657d8e |
+ if (!meta_monitor_is_active (monitor))
|
|
|
657d8e |
+ continue;
|
|
|
657d8e |
+
|
|
|
657d8e |
+ logical_monitor_config =
|
|
|
657d8e |
+ create_logical_monitor_config_from_output (monitor_manager,
|
|
|
657d8e |
+ monitor,
|
|
|
657d8e |
+ primary_logical_monitor_config,
|
|
|
657d8e |
+ layout_mode);
|
|
|
657d8e |
+
|
|
|
657d8e |
+ logical_monitor_configs = g_list_append (logical_monitor_configs,
|
|
|
657d8e |
+ logical_monitor_config);
|
|
|
657d8e |
+ }
|
|
|
657d8e |
+
|
|
|
657d8e |
+ return meta_monitors_config_new (monitor_manager,
|
|
|
657d8e |
+ logical_monitor_configs,
|
|
|
657d8e |
+ layout_mode,
|
|
|
657d8e |
+ META_MONITORS_CONFIG_FLAG_NONE);
|
|
|
657d8e |
+}
|
|
|
657d8e |
+
|
|
|
657d8e |
MetaMonitorsConfig *
|
|
|
657d8e |
meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_manager)
|
|
|
657d8e |
{
|
|
|
657d8e |
diff --git a/src/backends/meta-monitor-config-manager.h b/src/backends/meta-monitor-config-manager.h
|
|
|
657d8e |
index 3875e04e9..364a2b36b 100644
|
|
|
657d8e |
--- a/src/backends/meta-monitor-config-manager.h
|
|
|
657d8e |
+++ b/src/backends/meta-monitor-config-manager.h
|
|
|
657d8e |
@@ -94,6 +94,8 @@ gboolean meta_monitor_config_manager_assign (MetaMonitorManager *manager,
|
|
|
657d8e |
META_EXPORT_TEST
|
|
|
657d8e |
MetaMonitorsConfig * meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager);
|
|
|
657d8e |
|
|
|
657d8e |
+META_EXPORT_TEST
|
|
|
657d8e |
+MetaMonitorsConfig * meta_monitor_config_manager_create_current (MetaMonitorConfigManager *config_manager);
|
|
|
657d8e |
META_EXPORT_TEST
|
|
|
657d8e |
MetaMonitorsConfig * meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_manager);
|
|
|
657d8e |
|
|
|
657d8e |
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
|
|
|
657d8e |
index 2d898c757..05b27c6be 100644
|
|
|
657d8e |
--- a/src/backends/meta-monitor-manager.c
|
|
|
657d8e |
+++ b/src/backends/meta-monitor-manager.c
|
|
|
657d8e |
@@ -614,6 +614,25 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
|
|
|
657d8e |
g_clear_object (&config);
|
|
|
657d8e |
}
|
|
|
657d8e |
|
|
|
657d8e |
+ config = meta_monitor_config_manager_create_current (manager->config_manager);
|
|
|
657d8e |
+ if (config)
|
|
|
657d8e |
+ {
|
|
|
657d8e |
+ if (!meta_monitor_manager_apply_monitors_config (manager,
|
|
|
657d8e |
+ config,
|
|
|
657d8e |
+ method,
|
|
|
657d8e |
+ &error))
|
|
|
657d8e |
+ {
|
|
|
657d8e |
+ g_clear_object (&config);
|
|
|
657d8e |
+ g_warning ("Failed to use current monitor configuration: %s",
|
|
|
657d8e |
+ error->message);
|
|
|
657d8e |
+ g_clear_error (&error);
|
|
|
657d8e |
+ }
|
|
|
657d8e |
+ else
|
|
|
657d8e |
+ {
|
|
|
657d8e |
+ goto done;
|
|
|
657d8e |
+ }
|
|
|
657d8e |
+ }
|
|
|
657d8e |
+
|
|
|
657d8e |
config = meta_monitor_config_manager_create_linear (manager->config_manager);
|
|
|
657d8e |
if (config)
|
|
|
657d8e |
{
|
|
|
657d8e |
--
|
|
|
657d8e |
2.21.0
|
|
|
657d8e |
|