From e387b3bb8610307ec4e814897d30ae7a44ae44d4 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Wed, 20 Mar 2019 15:07:47 +0100 Subject: [PATCH] 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 | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index e8532ba51..03d697a0c 100644 --- a/panels/display/cc-display-panel.c +++ b/panels/display/cc-display-panel.c @@ -542,9 +542,32 @@ 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_counter > 0) + 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 +658,6 @@ set_current_output (CcDisplayPanel *panel, panel->rebuilding_counter++; - 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)