[mutter/gnome-3-28] monitor-config-manager: Fallback to closed laptop lid configuration



commit 079a625eaa39ee3adbd8b7e5bc206f3153ee3fd2
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Apr 16 00:28:05 2020 +0200

    monitor-config-manager: Fallback to closed laptop lid configuration
    
    When closing the lid of a laptop, we reconfigure all the monitors in order
    to update the CRTCs and (if enabled) the global UI scaling factor.
    
    To do this, we try first to reuse the current configuration for the usable
    monitors, but if we have only monitor enabled and this one is on the laptop
    lid we just end up creating a new configuration where the primary monitor is
    the laptop one (as per find_primary_monitor() in MetaMonitorConfigManager),
    but ignoring the user parameters.
    
    In case the user selected a different resolution / scaling compared to the
    default one, while the laptop lid is closed we might change the monitors
    layout, causing applications to rescale or reposition.
    
    To avoid this, when creating the monitors configuration from the current
    current state, in case we have only one monitor available and that one is
    the laptop panel, let's just reuse this configuration.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1200
    
    (cherry-picked from commit e48516679c02bb265a80d6680a4ea34d188127e0)

 src/backends/meta-monitor-config-manager.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index 28818ed6b..1a1899b2c 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -330,23 +330,35 @@ MetaMonitorsConfigKey *
 meta_create_monitors_config_key_for_current_state (MetaMonitorManager *monitor_manager)
 {
   MetaMonitorsConfigKey *config_key;
+  MetaMonitorSpec *laptop_monitor_spec;
   GList *l;
   GList *monitor_specs;
 
+  laptop_monitor_spec = NULL;
   monitor_specs = NULL;
   for (l = monitor_manager->monitors; l; l = l->next)
     {
       MetaMonitor *monitor = l->data;
       MetaMonitorSpec *monitor_spec;
 
-      if (meta_monitor_is_laptop_panel (monitor) &&
-          meta_monitor_manager_is_lid_closed (monitor_manager))
-        continue;
+      if (meta_monitor_is_laptop_panel (monitor))
+        {
+          laptop_monitor_spec = meta_monitor_get_spec (monitor);
+
+          if (meta_monitor_manager_is_lid_closed (monitor_manager))
+            continue;
+        }
 
       monitor_spec = meta_monitor_spec_clone (meta_monitor_get_spec (monitor));
       monitor_specs = g_list_prepend (monitor_specs, monitor_spec);
     }
 
+  if (!monitor_specs && laptop_monitor_spec)
+    {
+      monitor_specs =
+        g_list_prepend (NULL, meta_monitor_spec_clone (laptop_monitor_spec));
+    }
+
   if (!monitor_specs)
     return NULL;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]