diff options
author | Benjamin Berg <bberg@redhat.com> | 2019-03-20 15:16:51 +0100 |
---|---|---|
committer | Benjamin Berg <bberg@redhat.com> | 2019-03-20 18:01:01 +0100 |
commit | f45dcff81f94f1ba8805fb836adbf3e5cb20087c (patch) | |
tree | d5cc76753600c7d319ab25ddb40695e16d46c96e | |
parent | defbcebfab0d9e58573e5986db471458a58c35a3 (diff) | |
download | gnome-control-center-f45dcff81f94f1ba8805fb836adbf3e5cb20087c.tar.gz |
display: Ensure at least one display is enabled
When the user has more than two monitors, then they can disable each
monitor separately. If the user creates an invalid configuration because
they disabled the last monitor, then enable a different one immediately.
-rw-r--r-- | panels/display/cc-display-panel.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index 13ff9ce88..c0a3438cb 100644 --- a/panels/display/cc-display-panel.c +++ b/panels/display/cc-display-panel.c @@ -493,8 +493,32 @@ on_output_enabled_active_changed_cb (CcDisplayPanel *panel) if (cc_display_monitor_is_active (panel->current_output) == active) return; - /* Changing the active state requires a UI rebuild. */ cc_display_monitor_set_active (panel->current_output, active); + + /* Prevent the invalid configuration of disabling the last monitor + * by switching on a different one. */ + if (config_get_current_type (panel) == CC_DISPLAY_CONFIG_INVALID_NONE) + { + GList *outputs, *l; + + outputs = cc_display_config_get_ui_sorted_monitors (panel->current_config); + for (l = outputs; l; l = l->next) + { + CcDisplayMonitor *output = CC_DISPLAY_MONITOR (l->data); + + if (output == panel->current_output) + continue; + + if (!cc_display_monitor_is_usable (output)) + continue; + + cc_display_monitor_set_active (output, TRUE); + cc_display_monitor_set_primary (output, TRUE); + break; + } + } + + /* Changing the active state requires a UI rebuild. */ rebuild_ui (panel); } |