[gnome-control-center/benzea/ensure-valid-config-after-loading: 91/91] display: Ensure at least one display is enabled
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/benzea/ensure-valid-config-after-loading: 91/91] display: Ensure at least one display is enabled
- Date: Wed, 20 Mar 2019 14:20:15 +0000 (UTC)
commit db9aa32a48144fbc71f5d1a1f4dd68f4b38de639
Author: Benjamin Berg <bberg redhat com>
Date: Wed Mar 20 15:16:51 2019 +0100
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.
panels/display/cc-display-panel.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 7aca0b16b..12b29bf6b 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -495,8 +495,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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]