[gnome-control-center/benzea/ensure-valid-config-after-loading: 5/9] display: Only enforce single mode when desired by UI



commit ce5b44db8f8beb649dfdd3d290e1f3627f486ad6
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Mar 20 15:07:47 2019 +0100

    display: Only enforce single mode when desired by UI
    
    We should only enforce single mode, when we have exactly two monitors
    and the two button UI is used to switch between them in single mode.
    Move the code to ensure the single configuration into the relevant
    callback handler, rather than trying to solve this globally.

 panels/display/cc-display-panel.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index faf5ee05b..0cb18f034 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -542,9 +542,33 @@ on_output_selection_combo_changed_cb (CcDisplayPanel *panel)
 static void
 on_output_selection_two_toggled_cb (CcDisplayPanel *panel, GtkRadioButton *btn)
 {
+  CcDisplayMonitor *output;
+
+  if (panel->rebuilding)
+    return;
+
   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btn)))
     return;
 
+  output = g_object_get_data (G_OBJECT (btn), "display");
+
+  /* Stay in single mode when we are in single mode.
+   * This UI must never cause a switch between the configuration type.
+   * this is in contrast to the combobox monitor selection, which may
+   * switch to a disabled output both in SINGLE/MULTI mode without
+   * anything changing.
+   */
+  if (cc_panel_get_selected_type (panel) == CC_DISPLAY_CONFIG_SINGLE)
+    {
+      if (panel->current_output)
+        cc_display_monitor_set_active (panel->current_output, FALSE);
+      if (output)
+        cc_display_monitor_set_active (output, TRUE);
+
+      update_apply_button (panel);
+    }
+
+
   set_current_output (panel, g_object_get_data (G_OBJECT (btn), "display"), FALSE);
 }
 
@@ -635,16 +659,6 @@ set_current_output (CcDisplayPanel   *panel,
 
   panel->rebuilding += 1;
 
-  if (changed && cc_panel_get_selected_type (panel) == CC_DISPLAY_CONFIG_SINGLE)
-    {
-      if (output)
-        cc_display_monitor_set_active (output, TRUE);
-      if (panel->current_output && output != panel->current_output)
-        cc_display_monitor_set_active (panel->current_output, FALSE);
-
-      update_apply_button (panel);
-    }
-
   panel->current_output = output;
 
   if (panel->current_output)


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