Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 802c997

Browse files
jdufaultCommit bot
jdufault
authored and
Commit bot
committed
Fix dock mode with 2+ external displays.
BUG=575728 Review URL: https://codereview.chromium.org/1634323002 Cr-Commit-Position: refs/heads/master@{#372480}
1 parent 671fa5b commit 802c997

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

ui/display/chromeos/display_configurator.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,9 @@ bool DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayLayout(
303303
case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED:
304304
case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED: {
305305
if ((new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED &&
306-
states.size() != 2) ||
306+
states.size() != 2 && num_on_displays != 2) ||
307307
(new_display_state == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED &&
308-
states.size() <= 2) ||
309-
(num_on_displays != 0 &&
310-
num_on_displays != static_cast<int>(displays.size()))) {
308+
num_on_displays <= 2)) {
311309
LOG(WARNING) << "Ignoring request to enter extended mode with "
312310
<< states.size() << " connected display(s) and "
313311
<< num_on_displays << " turned on";

ui/display/chromeos/update_display_configuration_task.cc

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -181,32 +181,34 @@ bool UpdateDisplayConfigurationTask::ShouldConfigure() const {
181181

182182
MultipleDisplayState UpdateDisplayConfigurationTask::ChooseDisplayState()
183183
const {
184+
int num_displays = cached_displays_.size();
184185
int num_on_displays =
185-
GetDisplayPower(cached_displays_, new_power_state_, NULL);
186-
switch (cached_displays_.size()) {
187-
case 0:
188-
return MULTIPLE_DISPLAY_STATE_HEADLESS;
189-
case 1:
190-
return MULTIPLE_DISPLAY_STATE_SINGLE;
191-
default: {
192-
if (num_on_displays == 1) {
193-
// If only one display is currently turned on, return the "single"
194-
// state so that its native mode will be used.
195-
return MULTIPLE_DISPLAY_STATE_SINGLE;
196-
}
197-
if (num_on_displays >= 3) {
198-
return MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED;
199-
} else if (cached_displays_.size() == 2) {
200-
if (!layout_manager_->GetStateController())
201-
return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED;
202-
// With either both displays on or both displays off, use one of the
203-
// dual modes.
204-
return layout_manager_->GetStateController()->GetStateForDisplayIds(
205-
cached_displays_);
206-
}
207-
NOTREACHED();
208-
}
186+
GetDisplayPower(cached_displays_, new_power_state_, nullptr);
187+
188+
if (num_displays == 0)
189+
return MULTIPLE_DISPLAY_STATE_HEADLESS;
190+
191+
if (num_displays == 1 || num_on_displays == 1) {
192+
// If only one display is currently turned on, return the "single" state
193+
// so that its native mode will be used.
194+
return MULTIPLE_DISPLAY_STATE_SINGLE;
209195
}
196+
197+
if (num_displays == 2 || num_on_displays == 2) {
198+
// Try to use the saved configuration; otherwise, default to extended.
199+
DisplayConfigurator::StateController* state_controller =
200+
layout_manager_->GetStateController();
201+
202+
if (!state_controller)
203+
return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED;
204+
return state_controller->GetStateForDisplayIds(cached_displays_);
205+
}
206+
207+
if (num_on_displays >= 3) {
208+
// 3+ displays are always extended
209+
return MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED;
210+
}
211+
210212
return MULTIPLE_DISPLAY_STATE_INVALID;
211213
}
212214

0 commit comments

Comments
 (0)