|
|
418c51 |
From 648f1ce9350fcab0ebaecccb115b5021c632e7b5 Mon Sep 17 00:00:00 2001
|
|
|
e47e58 |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
e47e58 |
Date: Thu, 28 Jan 2016 15:26:33 +0100
|
|
|
e47e58 |
Subject: [PATCH] monitor-manager: Consider external layout before default
|
|
|
e47e58 |
linear config
|
|
|
e47e58 |
|
|
|
e47e58 |
In case of no existing configuration, we use a default layout of
|
|
|
e47e58 |
aligning attached displays horizontally. This sidesteps any layout
|
|
|
e47e58 |
configuration that is done externally, for instance via xorg.conf,
|
|
|
e47e58 |
which is not desirable. Instead, base the initial configuration on
|
|
|
e47e58 |
the existing layout if it passes some sanity checks before falling
|
|
|
e47e58 |
back to the default linear config.
|
|
|
e47e58 |
---
|
|
|
418c51 |
src/backends/meta-monitor-config-manager.c | 75 ++++++++++++++++++++++
|
|
|
e47e58 |
src/backends/meta-monitor-config-manager.h | 1 +
|
|
|
418c51 |
src/backends/meta-monitor-manager.c | 19 ++++++
|
|
|
418c51 |
3 files changed, 95 insertions(+)
|
|
|
e47e58 |
|
|
|
e47e58 |
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
|
|
|
418c51 |
index 197892bf2..ae988f64a 100644
|
|
|
e47e58 |
--- a/src/backends/meta-monitor-config-manager.c
|
|
|
e47e58 |
+++ b/src/backends/meta-monitor-config-manager.c
|
|
|
418c51 |
@@ -559,6 +559,81 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
|
|
|
e47e58 |
return logical_monitor_config;
|
|
|
e47e58 |
}
|
|
|
e47e58 |
|
|
|
e47e58 |
+static MetaLogicalMonitorConfig *
|
|
|
e47e58 |
+create_logical_monitor_config_from_output (MetaMonitorManager *monitor_manager,
|
|
|
e47e58 |
+ MetaMonitor *monitor,
|
|
|
e47e58 |
+ MetaLogicalMonitorConfig *primary_logical_monitor_config,
|
|
|
e47e58 |
+ MetaLogicalMonitorLayoutMode layout_mode)
|
|
|
e47e58 |
+{
|
|
|
e47e58 |
+ MetaOutput *output;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ output = meta_monitor_get_main_output (monitor);
|
|
|
e47e58 |
+ return create_preferred_logical_monitor_config (monitor_manager,
|
|
|
e47e58 |
+ monitor,
|
|
|
e47e58 |
+ output->crtc->rect.x,
|
|
|
e47e58 |
+ output->crtc->rect.y,
|
|
|
e47e58 |
+ primary_logical_monitor_config,
|
|
|
e47e58 |
+ layout_mode);
|
|
|
e47e58 |
+}
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+MetaMonitorsConfig *
|
|
|
e47e58 |
+meta_monitor_config_manager_create_current (MetaMonitorConfigManager *config_manager)
|
|
|
e47e58 |
+{
|
|
|
e47e58 |
+ MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
|
|
|
e47e58 |
+ GList *logical_monitor_configs;
|
|
|
e47e58 |
+ MetaMonitor *primary_monitor;
|
|
|
e47e58 |
+ MetaLogicalMonitorLayoutMode layout_mode;
|
|
|
e47e58 |
+ MetaLogicalMonitorConfig *primary_logical_monitor_config;
|
|
|
e47e58 |
+ GList *monitors;
|
|
|
e47e58 |
+ GList *l;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ if (meta_monitor_config_store_get_config_count (config_manager->config_store) > 0)
|
|
|
e47e58 |
+ return NULL;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ primary_monitor = find_primary_monitor (monitor_manager);
|
|
|
e47e58 |
+ if (!primary_monitor || !meta_monitor_is_active (primary_monitor))
|
|
|
e47e58 |
+ return NULL;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ primary_logical_monitor_config =
|
|
|
e47e58 |
+ create_logical_monitor_config_from_output (monitor_manager,
|
|
|
e47e58 |
+ primary_monitor,
|
|
|
e47e58 |
+ NULL,
|
|
|
e47e58 |
+ layout_mode);
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ primary_logical_monitor_config->is_primary = TRUE;
|
|
|
e47e58 |
+ logical_monitor_configs = g_list_append (NULL,
|
|
|
e47e58 |
+ primary_logical_monitor_config);
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ monitors = meta_monitor_manager_get_monitors (monitor_manager);
|
|
|
e47e58 |
+ for (l = monitors; l; l = l->next)
|
|
|
e47e58 |
+ {
|
|
|
e47e58 |
+ MetaMonitor *monitor = l->data;
|
|
|
e47e58 |
+ MetaLogicalMonitorConfig *logical_monitor_config;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ if (monitor == primary_monitor)
|
|
|
e47e58 |
+ continue;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ if (!meta_monitor_is_active (monitor))
|
|
|
e47e58 |
+ continue;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ logical_monitor_config =
|
|
|
e47e58 |
+ create_logical_monitor_config_from_output (monitor_manager,
|
|
|
e47e58 |
+ monitor,
|
|
|
e47e58 |
+ primary_logical_monitor_config,
|
|
|
e47e58 |
+ layout_mode);
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ logical_monitor_configs = g_list_append (logical_monitor_configs,
|
|
|
e47e58 |
+ logical_monitor_config);
|
|
|
e47e58 |
+ }
|
|
|
418c51 |
+
|
|
|
418c51 |
+ return meta_monitors_config_new (monitor_manager,
|
|
|
418c51 |
+ logical_monitor_configs,
|
|
|
418c51 |
+ layout_mode,
|
|
|
418c51 |
+ META_MONITORS_CONFIG_FLAG_NONE);
|
|
|
e47e58 |
+}
|
|
|
e47e58 |
+
|
|
|
e47e58 |
MetaMonitorsConfig *
|
|
|
e47e58 |
meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_manager)
|
|
|
e47e58 |
{
|
|
|
e47e58 |
diff --git a/src/backends/meta-monitor-config-manager.h b/src/backends/meta-monitor-config-manager.h
|
|
|
418c51 |
index 269d8e1b7..c36df38e6 100644
|
|
|
e47e58 |
--- a/src/backends/meta-monitor-config-manager.h
|
|
|
e47e58 |
+++ b/src/backends/meta-monitor-config-manager.h
|
|
|
e47e58 |
@@ -87,6 +87,7 @@ gboolean meta_monitor_config_manager_assign (MetaMonitorManager *manager,
|
|
|
e47e58 |
|
|
|
e47e58 |
MetaMonitorsConfig * meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager);
|
|
|
e47e58 |
|
|
|
e47e58 |
+MetaMonitorsConfig * meta_monitor_config_manager_create_current (MetaMonitorConfigManager *config_manager);
|
|
|
e47e58 |
MetaMonitorsConfig * meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_manager);
|
|
|
e47e58 |
|
|
|
e47e58 |
MetaMonitorsConfig * meta_monitor_config_manager_create_fallback (MetaMonitorConfigManager *config_manager);
|
|
|
e47e58 |
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
|
|
|
418c51 |
index 0b5e54c48..263e93941 100644
|
|
|
e47e58 |
--- a/src/backends/meta-monitor-manager.c
|
|
|
e47e58 |
+++ b/src/backends/meta-monitor-manager.c
|
|
|
418c51 |
@@ -576,6 +576,25 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
|
|
|
e47e58 |
g_clear_object (&config);
|
|
|
e47e58 |
}
|
|
|
e47e58 |
|
|
|
e47e58 |
+ config = meta_monitor_config_manager_create_current (manager->config_manager);
|
|
|
e47e58 |
+ if (config)
|
|
|
e47e58 |
+ {
|
|
|
e47e58 |
+ if (!meta_monitor_manager_apply_monitors_config (manager,
|
|
|
e47e58 |
+ config,
|
|
|
e47e58 |
+ method,
|
|
|
e47e58 |
+ &error))
|
|
|
e47e58 |
+ {
|
|
|
e47e58 |
+ g_clear_object (&config);
|
|
|
e47e58 |
+ g_warning ("Failed to use current monitor configuration: %s",
|
|
|
e47e58 |
+ error->message);
|
|
|
e47e58 |
+ g_clear_error (&error);
|
|
|
e47e58 |
+ }
|
|
|
e47e58 |
+ else
|
|
|
e47e58 |
+ {
|
|
|
e47e58 |
+ goto done;
|
|
|
e47e58 |
+ }
|
|
|
e47e58 |
+ }
|
|
|
e47e58 |
+
|
|
|
e47e58 |
config = meta_monitor_config_manager_create_linear (manager->config_manager);
|
|
|
e47e58 |
if (config)
|
|
|
e47e58 |
{
|
|
|
e47e58 |
--
|
|
|
418c51 |
2.17.1
|
|
|
e47e58 |
|