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

Side by Side Diff: ash/display/multi_display_manager.cc

Issue 10905288: Switch primary display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/display/multi_display_manager.h" 5 #include "ash/display/multi_display_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
(...skipping 12 matching lines...) Expand all
23 #if defined(USE_X11) 23 #if defined(USE_X11)
24 #include "ui/base/x/x11_util.h" 24 #include "ui/base/x/x11_util.h"
25 #endif 25 #endif
26 26
27 #if defined(OS_CHROMEOS) 27 #if defined(OS_CHROMEOS)
28 #include "base/chromeos/chromeos_version.h" 28 #include "base/chromeos/chromeos_version.h"
29 #include "chromeos/display/output_configurator.h" 29 #include "chromeos/display/output_configurator.h"
30 #endif 30 #endif
31 31
32 DECLARE_WINDOW_PROPERTY_TYPE(int64); 32 DECLARE_WINDOW_PROPERTY_TYPE(int64);
33 typedef std::vector<gfx::Display> DisplayList;
33 34
34 namespace ash { 35 namespace ash {
35 namespace internal { 36 namespace internal {
36 namespace { 37 namespace {
37 38
39 struct DisplaySortFunctor {
40 bool operator()(const gfx::Display& a, const gfx::Display& b) {
41 return a.id() < b.id();
42 }
43 };
44
38 gfx::Display& GetInvalidDisplay() { 45 gfx::Display& GetInvalidDisplay() {
39 static gfx::Display* invalid_display = new gfx::Display(); 46 static gfx::Display* invalid_display = new gfx::Display();
40 return *invalid_display; 47 return *invalid_display;
41 } 48 }
42 49
50 #if defined(OS_CHROMEOS)
51 int64 GetDisplayIdForOutput(XID output) {
52 uint16 manufacturer_id = 0;
53 uint32 serial_number = 0;
54 ui::GetOutputDeviceData(
55 output, &manufacturer_id, &serial_number, NULL);
56 return gfx::Display::GetID(manufacturer_id, serial_number);
57 }
58 #endif
59
43 } // namespace 60 } // namespace
44 61
45 using aura::RootWindow; 62 using aura::RootWindow;
46 using aura::Window; 63 using aura::Window;
47 using std::string; 64 using std::string;
48 using std::vector; 65 using std::vector;
49 66
50 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, 67 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey,
51 gfx::Display::kInvalidDisplayID); 68 gfx::Display::kInvalidDisplayID);
52 69
53 MultiDisplayManager::MultiDisplayManager() : 70 MultiDisplayManager::MultiDisplayManager() :
54 internal_display_id_(gfx::Display::kInvalidDisplayID) { 71 internal_display_id_(gfx::Display::kInvalidDisplayID),
72 force_bounds_changed_(false) {
55 Init(); 73 Init();
56 } 74 }
57 75
58 MultiDisplayManager::~MultiDisplayManager() { 76 MultiDisplayManager::~MultiDisplayManager() {
59 } 77 }
60 78
61 // static 79 // static
62 void MultiDisplayManager::CycleDisplay() { 80 void MultiDisplayManager::CycleDisplay() {
63 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>( 81 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>(
64 aura::Env::GetInstance()->display_manager()); 82 aura::Env::GetInstance()->display_manager());
(...skipping 10 matching lines...) Expand all
75 void MultiDisplayManager::InitInternalDisplayInfo() { 93 void MultiDisplayManager::InitInternalDisplayInfo() {
76 #if defined(OS_CHROMEOS) 94 #if defined(OS_CHROMEOS)
77 if (!base::chromeos::IsRunningOnChromeOS()) 95 if (!base::chromeos::IsRunningOnChromeOS())
78 return; 96 return;
79 std::vector<XID> outputs; 97 std::vector<XID> outputs;
80 ui::GetOutputDeviceHandles(&outputs); 98 ui::GetOutputDeviceHandles(&outputs);
81 std::vector<std::string> output_names = ui::GetOutputNames(outputs); 99 std::vector<std::string> output_names = ui::GetOutputNames(outputs);
82 for (size_t i = 0; i < output_names.size(); ++i) { 100 for (size_t i = 0; i < output_names.size(); ++i) {
83 if (chromeos::OutputConfigurator::IsInternalOutputName( 101 if (chromeos::OutputConfigurator::IsInternalOutputName(
84 output_names[i])) { 102 output_names[i])) {
85 XID internal_output = outputs[i]; 103 internal_display_id_ = GetDisplayIdForOutput(outputs[i]);
86 uint16 manufacturer_id = 0;
87 uint32 serial_number = 0;
88 ui::GetOutputDeviceData(
89 internal_output, &manufacturer_id, &serial_number, NULL);
90 internal_display_id_ =
91 gfx::Display::GetID(manufacturer_id, serial_number);
92 return; 104 return;
93 } 105 }
94 } 106 }
95 #endif 107 #endif
96 } 108 }
97 109
110 bool MultiDisplayManager::IsActiveDisplay(const gfx::Display& display) const {
111 for (DisplayList::const_iterator iter = displays_.begin();
112 iter != displays_.end(); ++iter) {
113 if ((*iter).id() == display.id())
114 return true;
115 }
116 return false;
117 }
118
98 bool MultiDisplayManager::HasInternalDisplay() const { 119 bool MultiDisplayManager::HasInternalDisplay() const {
99 return internal_display_id_ != gfx::Display::kInvalidDisplayID; 120 return internal_display_id_ != gfx::Display::kInvalidDisplayID;
100 } 121 }
101 122
102 bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow( 123 bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow(
103 const aura::Window* window, 124 const aura::Window* window,
104 const gfx::Insets& insets) { 125 const gfx::Insets& insets) {
105 const RootWindow* root = window->GetRootWindow(); 126 const RootWindow* root = window->GetRootWindow();
106 gfx::Display& display = FindDisplayForRootWindow(root); 127 gfx::Display& display = FindDisplayForRootWindow(root);
107 gfx::Rect old_work_area = display.work_area(); 128 gfx::Rect old_work_area = display.work_area();
108 display.UpdateWorkAreaFromInsets(insets); 129 display.UpdateWorkAreaFromInsets(insets);
109 return old_work_area != display.work_area(); 130 return old_work_area != display.work_area();
110 } 131 }
111 132
112 const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint( 133 const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint(
113 const gfx::Point& point_in_screen) const { 134 const gfx::Point& point_in_screen) const {
114 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); 135 for (DisplayList::const_iterator iter = displays_.begin();
115 iter != displays_.end(); ++iter) { 136 iter != displays_.end(); ++iter) {
116 const gfx::Display& display = *iter; 137 const gfx::Display& display = *iter;
117 if (display.bounds().Contains(point_in_screen)) 138 if (display.bounds().Contains(point_in_screen))
118 return display; 139 return display;
119 } 140 }
120 return GetInvalidDisplay(); 141 return GetInvalidDisplay();
121 } 142 }
122 143
123 void MultiDisplayManager::OnNativeDisplaysChanged( 144 void MultiDisplayManager::OnNativeDisplaysChanged(
124 const std::vector<gfx::Display>& updated_displays) { 145 const std::vector<gfx::Display>& updated_displays) {
125 if (updated_displays.size() == 0) { 146 if (updated_displays.size() == 0) {
sky 2012/09/18 03:52:47 empty
oshima 2012/09/18 09:30:48 Done.
126 // Don't update the displays when all displays are disconnected. 147 // Don't update the displays when all displays are disconnected.
127 // This happens when: 148 // This happens when:
128 // - the device is idle and powerd requested to turn off all displays. 149 // - the device is idle and powerd requested to turn off all displays.
129 // - the device is suspended. (kernel turns off all displays) 150 // - the device is suspended. (kernel turns off all displays)
130 // - the internal display's brightness is set to 0 and no external 151 // - the internal display's brightness is set to 0 and no external
131 // display is connected. 152 // display is connected.
132 // - the internal display's brightness is 0 and external display is 153 // - the internal display's brightness is 0 and external display is
133 // disconnected. 154 // disconnected.
134 // The display will be updated when one of displays is turned on, and the 155 // The display will be updated when one of displays is turned on, and the
135 // display list will be updated correctly. 156 // display list will be updated correctly.
136 return; 157 return;
137 } 158 }
138 std::vector<gfx::Display> new_displays; 159 DisplayList new_displays = updated_displays;
139 if (internal_display_id_ != gfx::Display::kInvalidDisplayID) { 160 if (internal_display_id_ != gfx::Display::kInvalidDisplayID) {
140 bool internal_display_connected = false; 161 bool internal_display_connected = false;
141 for (Displays::const_iterator iter = updated_displays.begin(); 162 for (DisplayList::const_iterator iter = updated_displays.begin();
142 iter != updated_displays.end(); ++iter) { 163 iter != updated_displays.end(); ++iter) {
143 if ((*iter).id() == internal_display_id_) { 164 if ((*iter).id() == internal_display_id_) {
144 internal_display_connected = true; 165 internal_display_connected = true;
145 // Update the internal display cache. 166 // Update the internal display cache.
146 internal_display_.reset(new gfx::Display); 167 internal_display_.reset(new gfx::Display);
147 *internal_display_.get() = *iter; 168 *internal_display_.get() = *iter;
148 break; 169 break;
149 } 170 }
150 } 171 }
151 // If the internal display wasn't connected, use the cached value. 172 // If the internal display wasn't connected, use the cached value.
152 if (!internal_display_connected) 173 if (!internal_display_connected)
153 new_displays.push_back(*internal_display_.get()); 174 new_displays.push_back(*internal_display_.get());
154 new_displays.insert(
155 new_displays.end(), updated_displays.begin(), updated_displays.end());
156 } else { 175 } else {
157 new_displays = updated_displays; 176 new_displays = updated_displays;
158 } 177 }
159 178
160 size_t min = std::min(displays_.size(), new_displays.size()); 179 std::sort(displays_.begin(), displays_.end(), DisplaySortFunctor());
180 std::sort(new_displays.begin(), new_displays.end(), DisplaySortFunctor());
161 181
162 // TODO(oshima): Fix this so that we can differentiate outputs 182 DisplayList removed_displays;
163 // and keep a content on one display stays on the same display 183 std::vector<size_t> changed_display_indices;
164 // when a display is added or removed. 184 std::vector<size_t> added_display_indices;
165 for (size_t i = 0; i < min; ++i) { 185
166 gfx::Display& current_display = displays_[i]; 186 DisplayList::iterator curr_iter = displays_.begin();
sky 2012/09/18 03:52:47 move iterators into for loop.
oshima 2012/09/18 09:30:48 Done.
167 const gfx::Display& new_display = new_displays[i]; 187 DisplayList::iterator new_iter = new_displays.begin();
168 if (current_display.bounds_in_pixel() != new_display.bounds_in_pixel() || 188 for (; curr_iter != displays_.end() || new_iter != new_displays.end();) {
169 current_display.device_scale_factor() != 189 if (curr_iter == displays_.end()) {
170 new_display.device_scale_factor()) { 190 // more displays in new list.
171 current_display.SetScaleAndBounds(new_display.device_scale_factor(), 191 added_display_indices.push_back(new_iter - new_displays.begin());
172 new_display.bounds_in_pixel()); 192 ++new_iter;
173 NotifyBoundsChanged(current_display); 193 } else if (new_iter == new_displays.end()) {
194 // more displays in current list.
195 removed_displays.push_back(*curr_iter);
196 ++curr_iter;
197 } else if ((*curr_iter).id() == (*new_iter).id()) {
198 const gfx::Display& current_display = *curr_iter;
199 gfx::Display& new_display = *new_iter;
200 if (force_bounds_changed_ ||
201 current_display.bounds_in_pixel() != new_display.bounds_in_pixel() ||
202 current_display.device_scale_factor() !=
203 new_display.device_scale_factor()) {
204 changed_display_indices.push_back(new_iter - new_displays.begin());
205 }
206 new_display.UpdateWorkAreaFromInsets(current_display.GetWorkAreaInsets());
207 ++curr_iter;
208 ++new_iter;
209 } else if ((*curr_iter).id() < (*new_iter).id()) {
210 // more displays in current list between ids, which means it is deleted.
211 removed_displays.push_back(*curr_iter);
212 ++curr_iter;
213 } else {
214 // more displays in new list between ids, which means it is added.
215 added_display_indices.push_back(new_iter - new_displays.begin());
216 ++new_iter;
174 } 217 }
175 } 218 }
176 219 displays_ = new_displays;
177 if (displays_.size() < new_displays.size()) { 220 // Temporarily add displays to be removed because display object
178 // New displays added 221 // being removed are accessed during shutting the root.
sky 2012/09/18 03:52:47 shutting down the root
oshima 2012/09/18 09:30:48 Done.
179 for (size_t i = min; i < new_displays.size(); ++i) { 222 displays_.insert(displays_.end(), removed_displays.begin(),
180 const gfx::Display& new_display = new_displays[i]; 223 removed_displays.end());
181 displays_.push_back(gfx::Display(new_display.id())); 224 for (std::vector<size_t>::iterator iter = changed_display_indices.begin();
182 gfx::Display& display = displays_.back(); 225 iter != changed_display_indices.end(); ++iter) {
183 display.SetScaleAndBounds(new_display.device_scale_factor(), 226 NotifyBoundsChanged(displays_[*iter]);
184 new_display.bounds_in_pixel()); 227 }
185 NotifyDisplayAdded(display); 228 for (std::vector<size_t>::iterator iter = added_display_indices.begin();
186 } 229 iter != added_display_indices.end(); ++iter) {
187 } else { 230 NotifyDisplayAdded(displays_[*iter]);
188 // Displays are removed. We keep the display for the primary 231 }
189 // display (at index 0) because it needs the display information 232 for (DisplayList::const_reverse_iterator iter = removed_displays.rbegin();
190 // even if it doesn't exit. 233 iter != removed_displays.rend(); ++iter) {
191 while (displays_.size() > new_displays.size() && displays_.size() > 1) { 234 NotifyDisplayRemoved(displays_.back());
192 Displays::reverse_iterator iter = displays_.rbegin(); 235 displays_.erase(displays_.end());
sky 2012/09/18 03:52:47 Don't you need displays_.end() - 1?
oshima 2012/09/18 09:30:48 I should have used pop_back()
193 NotifyDisplayRemoved(*iter);
194 displays_.erase(iter.base() - 1);
195 }
196 } 236 }
197 } 237 }
198 238
199 RootWindow* MultiDisplayManager::CreateRootWindowForDisplay( 239 RootWindow* MultiDisplayManager::CreateRootWindowForDisplay(
200 const gfx::Display& display) { 240 const gfx::Display& display) {
201 RootWindow* root_window = 241 RootWindow* root_window =
202 new RootWindow(RootWindow::CreateParams(display.bounds_in_pixel())); 242 new RootWindow(RootWindow::CreateParams(display.bounds_in_pixel()));
203 // No need to remove RootWindowObserver because 243 // No need to remove RootWindowObserver because
204 // the DisplayManager object outlives RootWindow objects. 244 // the DisplayManager object outlives RootWindow objects.
205 root_window->AddRootWindowObserver(this); 245 root_window->AddRootWindowObserver(this);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 int area = intersect.width() * intersect.height(); 287 int area = intersect.width() * intersect.height();
248 if (area > max) { 288 if (area > max) {
249 max = area; 289 max = area;
250 matching = &(*iter); 290 matching = &(*iter);
251 } 291 }
252 } 292 }
253 // Fallback to the primary display if there is no matching display. 293 // Fallback to the primary display if there is no matching display.
254 return matching ? *matching : displays_[0]; 294 return matching ? *matching : displays_[0];
255 } 295 }
256 296
257 std::string MultiDisplayManager::GetDisplayNameAt(size_t index) { 297 std::string MultiDisplayManager::GetDisplayNameFor(
298 const gfx::Display& display) {
258 #if defined(USE_X11) 299 #if defined(USE_X11)
259 gfx::Display* display = GetDisplayAt(index);
260 std::vector<XID> outputs; 300 std::vector<XID> outputs;
261 if (display && display->id() != gfx::Display::kInvalidDisplayID && 301 if (display.id() != gfx::Display::kInvalidDisplayID &&
262 ui::GetOutputDeviceHandles(&outputs)) { 302 ui::GetOutputDeviceHandles(&outputs)) {
263 for (size_t i = 0; i < outputs.size(); ++i) { 303 for (size_t i = 0; i < outputs.size(); ++i) {
264 uint16 manufacturer_id = 0; 304 uint16 manufacturer_id = 0;
265 uint32 serial_number = 0; 305 uint32 serial_number = 0;
266 std::string name; 306 std::string name;
267 if (ui::GetOutputDeviceData( 307 if (ui::GetOutputDeviceData(
268 outputs[i], &manufacturer_id, &serial_number, &name) && 308 outputs[i], &manufacturer_id, &serial_number, &name) &&
269 display->id() == 309 display.id() ==
270 gfx::Display::GetID(manufacturer_id, serial_number)) { 310 gfx::Display::GetID(manufacturer_id, serial_number)) {
271 return name; 311 return name;
272 } 312 }
273 } 313 }
274 } 314 }
275 #endif 315 #endif
276 316 return base::StringPrintf("Display %d", static_cast<int>(display.id()));
277 return base::StringPrintf("Display %d", static_cast<int>(index + 1));
278 } 317 }
279 318
280 void MultiDisplayManager::OnRootWindowResized(const aura::RootWindow* root, 319 void MultiDisplayManager::OnRootWindowResized(const aura::RootWindow* root,
281 const gfx::Size& old_size) { 320 const gfx::Size& old_size) {
282 if (!use_fullscreen_host_window()) { 321 if (!use_fullscreen_host_window()) {
283 gfx::Display& display = FindDisplayForRootWindow(root); 322 gfx::Display& display = FindDisplayForRootWindow(root);
284 if (display.size() != root->GetHostSize()) { 323 if (display.size() != root->GetHostSize()) {
285 display.SetSize(root->GetHostSize()); 324 display.SetSize(root->GetHostSize());
286 NotifyBoundsChanged(display); 325 NotifyBoundsChanged(display);
287 } 326 }
(...skipping 12 matching lines...) Expand all
300 } 339 }
301 if (displays_.empty()) 340 if (displays_.empty())
302 AddDisplayFromSpec(std::string() /* default */); 341 AddDisplayFromSpec(std::string() /* default */);
303 } 342 }
304 343
305 void MultiDisplayManager::CycleDisplayImpl() { 344 void MultiDisplayManager::CycleDisplayImpl() {
306 std::vector<gfx::Display> new_displays; 345 std::vector<gfx::Display> new_displays;
307 if (displays_.size() > 1) { 346 if (displays_.size() > 1) {
308 // Remove if there is more than one display. 347 // Remove if there is more than one display.
309 int count = displays_.size() - 1; 348 int count = displays_.size() - 1;
310 for (Displays::const_iterator iter = displays_.begin(); count-- > 0; ++iter) 349 for (DisplayList::const_iterator iter = displays_.begin();
350 count-- > 0; ++iter) {
311 new_displays.push_back(*iter); 351 new_displays.push_back(*iter);
352 }
312 } else { 353 } else {
313 // Add if there is only one display. 354 // Add if there is only one display.
314 new_displays.push_back(displays_[0]); 355 new_displays.push_back(displays_[0]);
315 new_displays.push_back(CreateDisplayFromSpec("100+200-500x400")); 356 new_displays.push_back(CreateDisplayFromSpec("100+200-500x400"));
316 } 357 }
317 if (new_displays.size()) 358 if (new_displays.size())
318 OnNativeDisplaysChanged(new_displays); 359 OnNativeDisplaysChanged(new_displays);
319 } 360 }
320 361
321 void MultiDisplayManager::ScaleDisplayImpl() { 362 void MultiDisplayManager::ScaleDisplayImpl() {
322 if (displays_.size() > 0) { 363 if (displays_.size() > 0) {
323 std::vector<gfx::Display> new_displays; 364 std::vector<gfx::Display> new_displays;
324 for (Displays::const_iterator iter = displays_.begin(); 365 for (DisplayList::const_iterator iter = displays_.begin();
325 iter != displays_.end(); ++iter) { 366 iter != displays_.end(); ++iter) {
326 gfx::Display display = *iter; 367 gfx::Display display = *iter;
327 float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f; 368 float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f;
328 display.SetScaleAndBounds( 369 display.SetScaleAndBounds(
329 factor, gfx::Rect(display.bounds_in_pixel().origin(), 370 factor, gfx::Rect(display.bounds_in_pixel().origin(),
330 display.size().Scale(factor))); 371 display.size().Scale(factor)));
331 new_displays.push_back(display); 372 new_displays.push_back(display);
332 } 373 }
333 OnNativeDisplaysChanged(new_displays); 374 OnNativeDisplaysChanged(new_displays);
334 } 375 }
335 } 376 }
336 377
337 gfx::Display& MultiDisplayManager::FindDisplayForRootWindow( 378 gfx::Display& MultiDisplayManager::FindDisplayForRootWindow(
338 const aura::RootWindow* root_window) { 379 const aura::RootWindow* root_window) {
339 int64 id = root_window->GetProperty(kDisplayIdKey); 380 int64 id = root_window->GetProperty(kDisplayIdKey);
340 // if id is |kInvaildDisplayID|, it's being deleted. 381 // if id is |kInvaildDisplayID|, it's being deleted.
341 DCHECK(id != gfx::Display::kInvalidDisplayID); 382 DCHECK(id != gfx::Display::kInvalidDisplayID);
342 for (Displays::iterator iter = displays_.begin(); 383 return FindDisplayForId(id);
384 }
385
386 gfx::Display& MultiDisplayManager::FindDisplayForId(int64 id) {
387 for (DisplayList::iterator iter = displays_.begin();
343 iter != displays_.end(); ++iter) { 388 iter != displays_.end(); ++iter) {
344 if ((*iter).id() == id) 389 if ((*iter).id() == id)
345 return *iter; 390 return *iter;
346 } 391 }
347 DLOG(FATAL) << "Could not find display by id:" << id; 392 DLOG(FATAL) << "Could not find display:" << id;
348 return GetInvalidDisplay(); 393 return GetInvalidDisplay();
349 } 394 }
350 395
351 void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) { 396 void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) {
352 gfx::Display display = CreateDisplayFromSpec(spec); 397 gfx::Display display = CreateDisplayFromSpec(spec);
353 398
354 const gfx::Insets insets = display.GetWorkAreaInsets(); 399 const gfx::Insets insets = display.GetWorkAreaInsets();
355 const gfx::Rect& native_bounds = display.bounds_in_pixel(); 400 const gfx::Rect& native_bounds = display.bounds_in_pixel();
356 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds); 401 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds);
357 display.UpdateWorkAreaFromInsets(insets); 402 display.UpdateWorkAreaFromInsets(insets);
358 displays_.push_back(display); 403 displays_.push_back(display);
359 } 404 }
360 405
361 int64 MultiDisplayManager::EnableInternalDisplayForTest() { 406 int64 MultiDisplayManager::SetFirstDisplayAsInternalDisplayForTest() {
362 const int64 kInternalDisplayIdForTest = 9999; 407 internal_display_id_ = displays_[0].id();
363 internal_display_id_ = kInternalDisplayIdForTest; 408 internal_display_.reset(new gfx::Display);
364 internal_display_.reset(new gfx::Display(internal_display_id_, 409 *internal_display_ = displays_[0];
365 gfx::Rect(800, 600))); 410 return internal_display_id_;
366 return kInternalDisplayIdForTest; 411 }
412
413 void MultiDisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const {
414 DisplayList::iterator iter_to_update = to_update->begin();
415 DisplayList::const_iterator iter = displays_.begin();
416 for (; iter != displays_.end() && iter_to_update != to_update->end();
417 ++iter, ++iter_to_update) {
418 (*iter_to_update).set_id((*iter).id());
419 }
367 } 420 }
368 421
369 } // namespace internal 422 } // namespace internal
370 } // namespace ash 423 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698