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

Side by Side Diff: ui/display/chromeos/update_display_configuration_task.cc

Issue 1634323002: Fix dock mode with 2+ external displays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix broken tests Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/display/chromeos/update_display_configuration_task.h" 5 #include "ui/display/chromeos/update_display_configuration_task.h"
6 6
7 #include "ui/display/chromeos/configure_displays_task.h" 7 #include "ui/display/chromeos/configure_displays_task.h"
8 #include "ui/display/chromeos/display_layout_manager.h" 8 #include "ui/display/chromeos/display_layout_manager.h"
9 #include "ui/display/chromeos/display_util.h" 9 #include "ui/display/chromeos/display_util.h"
10 #include "ui/display/types/display_snapshot.h" 10 #include "ui/display/types/display_snapshot.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return true; 174 return true;
175 175
176 if (new_display_state_ != layout_manager_->GetDisplayState()) 176 if (new_display_state_ != layout_manager_->GetDisplayState())
177 return true; 177 return true;
178 178
179 return false; 179 return false;
180 } 180 }
181 181
182 MultipleDisplayState UpdateDisplayConfigurationTask::ChooseDisplayState() 182 MultipleDisplayState UpdateDisplayConfigurationTask::ChooseDisplayState()
183 const { 183 const {
184 int num_displays = cached_displays_.size();
184 int num_on_displays = 185 int num_on_displays =
185 GetDisplayPower(cached_displays_, new_power_state_, NULL); 186 GetDisplayPower(cached_displays_, new_power_state_, nullptr);
186 switch (cached_displays_.size()) { 187
187 case 0: 188 if (num_displays == 0)
188 return MULTIPLE_DISPLAY_STATE_HEADLESS; 189 return MULTIPLE_DISPLAY_STATE_HEADLESS;
189 case 1: 190
190 return MULTIPLE_DISPLAY_STATE_SINGLE; 191 if (num_displays == 1 || num_on_displays == 1) {
191 default: { 192 // If only one display is currently turned on, return the "single" state
192 if (num_on_displays == 1) { 193 // so that its native mode will be used.
193 // If only one display is currently turned on, return the "single" 194 return MULTIPLE_DISPLAY_STATE_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 }
209 } 195 }
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
210 return MULTIPLE_DISPLAY_STATE_INVALID; 212 return MULTIPLE_DISPLAY_STATE_INVALID;
211 } 213 }
212 214
213 } // namespace ui 215 } // namespace ui
OLDNEW
« 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