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