kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

Blame SOURCES/0001-monitor-manager-only-reuse-initial-config-if-monitor.patch

776610
From 7f73a6ed3ac3244d8d1ec3ab7a74b5a45a1350d9 Mon Sep 17 00:00:00 2001
776610
From: rpm-build <rpm-build>
776610
Date: Tue, 11 Sep 2018 10:19:44 -0400
776610
Subject: [PATCH] monitor-manager: only reuse initial-config if monitor
776610
 topology matches startup
776610
776610
Right now we try to apply the current monitor config when a new
776610
monitor is attached.  The current config obviously doesn't include the
776610
new monitor, so the new monitor isn't lit up.
776610
776610
The only reason we apply the current config at all is to handle the
776610
startup case:  We want to reuse the config set in Xorg when first
776610
logging in.
776610
776610
This commit changes the code to look at the *initial config* instead
776610
of the current config, and only if the new monitor topology matches
776610
the start up topology.
776610
---
776610
 src/backends/meta-monitor-config-manager.c | 20 +++++++++++++++-----
776610
 src/backends/meta-monitor-config-manager.h |  2 +-
776610
 src/backends/meta-monitor-manager.c        | 16 +++++++++++++++-
776610
 3 files changed, 31 insertions(+), 7 deletions(-)
776610
776610
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
776610
index 585ee7034..1ad342a44 100644
776610
--- a/src/backends/meta-monitor-config-manager.c
776610
+++ b/src/backends/meta-monitor-config-manager.c
776610
@@ -40,6 +40,7 @@ struct _MetaMonitorConfigManager
776610
   MetaMonitorConfigStore *config_store;
776610
 
776610
   MetaMonitorsConfig *current_config;
776610
+  MetaMonitorsConfig *initial_config;
776610
   GQueue config_history;
776610
 };
776610
 
776610
@@ -579,9 +580,10 @@ create_logical_monitor_config_from_output (MetaMonitorManager           *monitor
776610
 }
776610
 
776610
 MetaMonitorsConfig *
776610
-meta_monitor_config_manager_create_current (MetaMonitorConfigManager *config_manager)
776610
+meta_monitor_config_manager_create_initial (MetaMonitorConfigManager *config_manager)
776610
 {
776610
   MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
776610
+  MetaMonitorsConfig *initial_config;
776610
   GList *logical_monitor_configs;
776610
   MetaMonitor *primary_monitor;
776610
   MetaLogicalMonitorLayoutMode layout_mode;
776610
@@ -589,6 +591,9 @@ meta_monitor_config_manager_create_current (MetaMonitorConfigManager *config_man
776610
   GList *monitors;
776610
   GList *l;
776610
 
776610
+  if (config_manager->initial_config != NULL)
776610
+    return g_object_ref (config_manager->initial_config);
776610
+
776610
   if (meta_monitor_config_store_get_config_count (config_manager->config_store) > 0)
776610
     return NULL;
776610
 
776610
@@ -630,10 +635,14 @@ meta_monitor_config_manager_create_current (MetaMonitorConfigManager *config_man
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
+  initial_config = meta_monitors_config_new (monitor_manager,
776610
+                                             logical_monitor_configs,
776610
+                                             layout_mode,
776610
+                                             META_MONITORS_CONFIG_FLAG_NONE);
776610
+
776610
+  config_manager->initial_config = g_object_ref (initial_config);
776610
+
776610
+  return initial_config;
776610
 }
776610
 
776610
 MetaMonitorsConfig *
776610
@@ -1162,6 +1171,7 @@ meta_monitor_config_manager_dispose (GObject *object)
776610
     META_MONITOR_CONFIG_MANAGER (object);
776610
 
776610
   g_clear_object (&config_manager->current_config);
776610
+  g_clear_object (&config_manager->initial_config);
776610
   meta_monitor_config_manager_clear_history (config_manager);
776610
 
776610
   G_OBJECT_CLASS (meta_monitor_config_manager_parent_class)->dispose (object);
776610
diff --git a/src/backends/meta-monitor-config-manager.h b/src/backends/meta-monitor-config-manager.h
776610
index c36df38e6..29ef8f8ce 100644
776610
--- a/src/backends/meta-monitor-config-manager.h
776610
+++ b/src/backends/meta-monitor-config-manager.h
776610
@@ -87,7 +87,7 @@ gboolean meta_monitor_config_manager_assign (MetaMonitorManager *manager,
776610
 
776610
 MetaMonitorsConfig * meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager);
776610
 
776610
-MetaMonitorsConfig * meta_monitor_config_manager_create_current (MetaMonitorConfigManager *config_manager);
776610
+MetaMonitorsConfig * meta_monitor_config_manager_create_initial (MetaMonitorConfigManager *config_manager);
776610
 MetaMonitorsConfig * meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_manager);
776610
 
776610
 MetaMonitorsConfig * meta_monitor_config_manager_create_fallback (MetaMonitorConfigManager *config_manager);
776610
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
776610
index 4503eb841..f7ada0136 100644
776610
--- a/src/backends/meta-monitor-manager.c
776610
+++ b/src/backends/meta-monitor-manager.c
776610
@@ -496,9 +496,11 @@ should_use_stored_config (MetaMonitorManager *manager)
776610
 MetaMonitorsConfig *
776610
 meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
776610
 {
776610
+  g_autoptr (MetaMonitorsConfig) initial_config = NULL;
776610
   MetaMonitorsConfig *config = NULL;
776610
   GError *error = NULL;
776610
   gboolean use_stored_config;
776610
+  MetaMonitorsConfigKey *current_state_key;
776610
   MetaMonitorsConfigMethod method;
776610
   MetaMonitorsConfigMethod fallback_method =
776610
     META_MONITORS_CONFIG_METHOD_TEMPORARY;
776610
@@ -509,6 +511,18 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
776610
   else
776610
     method = META_MONITORS_CONFIG_METHOD_TEMPORARY;
776610
 
776610
+  initial_config = meta_monitor_config_manager_create_initial (manager->config_manager);
776610
+
776610
+  if (initial_config)
776610
+    {
776610
+      current_state_key = meta_create_monitors_config_key_for_current_state (manager);
776610
+
776610
+      /* don't ever reuse initial configuration, if the monitor topology changed
776610
+       */
776610
+      if (current_state_key && !meta_monitors_config_key_equal (current_state_key, initial_config->key))
776610
+        g_clear_object (&initial_config);
776610
+    }
776610
+
776610
   if (use_stored_config)
776610
     {
776610
       config = meta_monitor_config_manager_get_stored (manager->config_manager);
776610
@@ -576,7 +590,7 @@ 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
+  config = g_steal_pointer (&initial_config);
776610
   if (config)
776610
     {
776610
       if (!meta_monitor_manager_apply_monitors_config (manager,
776610
-- 
776610
2.20.1
776610