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