Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: ui/display/chromeos/update_display_configuration_task.cc

Issue 1652213002: Fix dock mode with 2+ external displays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/chromeos/update_display_configuration_task.cc
diff --git a/ui/display/chromeos/update_display_configuration_task.cc b/ui/display/chromeos/update_display_configuration_task.cc
index 6b412714d8fb93c91214e60b6bd1bed2901e5d32..5fa7ac7f9fb303d72afa24fc5ab02ff590c4203d 100644
--- a/ui/display/chromeos/update_display_configuration_task.cc
+++ b/ui/display/chromeos/update_display_configuration_task.cc
@@ -181,32 +181,34 @@ bool UpdateDisplayConfigurationTask::ShouldConfigure() const {
MultipleDisplayState UpdateDisplayConfigurationTask::ChooseDisplayState()
const {
+ int num_displays = cached_displays_.size();
int num_on_displays =
- GetDisplayPower(cached_displays_, new_power_state_, NULL);
- switch (cached_displays_.size()) {
- case 0:
- return MULTIPLE_DISPLAY_STATE_HEADLESS;
- case 1:
- return MULTIPLE_DISPLAY_STATE_SINGLE;
- default: {
- if (num_on_displays == 1) {
- // If only one display is currently turned on, return the "single"
- // state so that its native mode will be used.
- return MULTIPLE_DISPLAY_STATE_SINGLE;
- }
- if (num_on_displays >= 3) {
- return MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED;
- } else if (cached_displays_.size() == 2) {
- if (!layout_manager_->GetStateController())
- return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED;
- // With either both displays on or both displays off, use one of the
- // dual modes.
- return layout_manager_->GetStateController()->GetStateForDisplayIds(
- cached_displays_);
- }
- NOTREACHED();
- }
+ GetDisplayPower(cached_displays_, new_power_state_, nullptr);
+
+ if (num_displays == 0)
+ return MULTIPLE_DISPLAY_STATE_HEADLESS;
+
+ if (num_displays == 1 || num_on_displays == 1) {
+ // If only one display is currently turned on, return the "single" state
+ // so that its native mode will be used.
+ return MULTIPLE_DISPLAY_STATE_SINGLE;
}
+
+ if (num_displays == 2 || num_on_displays == 2) {
+ // Try to use the saved configuration; otherwise, default to extended.
+ DisplayConfigurator::StateController* state_controller =
+ layout_manager_->GetStateController();
+
+ if (!state_controller)
+ return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED;
+ return state_controller->GetStateForDisplayIds(cached_displays_);
+ }
+
+ if (num_on_displays >= 3) {
+ // 3+ displays are always extended
+ return MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED;
+ }
+
return MULTIPLE_DISPLAY_STATE_INVALID;
}
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698