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

Commit

Permalink
Fix dock mode with 2+ external displays.
Browse files Browse the repository at this point in the history
BUG=575728

Review URL: https://codereview.chromium.org/1634323002

Cr-Commit-Position: refs/heads/master@{#372480}
(cherry picked from commit 802c997)

Review URL: https://codereview.chromium.org/1652213002 .

Cr-Commit-Position: refs/branch-heads/2623@{#218}
Cr-Branched-From: 92d7753-refs/heads/master@{#369907}
  • Loading branch information
jacobdufault-google committed Feb 1, 2016
1 parent f4040e4 commit 4c95200
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
6 changes: 2 additions & 4 deletions ui/display/chromeos/display_configurator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,9 @@ bool DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayLayout(
case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED:
case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED: {
if ((new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED &&
states.size() != 2) ||
states.size() != 2 && num_on_displays != 2) ||
(new_display_state == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED &&
states.size() <= 2) ||
(num_on_displays != 0 &&
num_on_displays != static_cast<int>(displays.size()))) {
num_on_displays <= 2)) {
LOG(WARNING) << "Ignoring request to enter extended mode with "
<< states.size() << " connected display(s) and "
<< num_on_displays << " turned on";
Expand Down
50 changes: 26 additions & 24 deletions ui/display/chromeos/update_display_configuration_task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 4c95200

Please sign in to comment.