OLD | NEW |
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/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 DECLARE_WINDOW_PROPERTY_TYPE(int64); | 48 DECLARE_WINDOW_PROPERTY_TYPE(int64); |
49 | 49 |
50 namespace ash { | 50 namespace ash { |
51 namespace internal { | 51 namespace internal { |
52 typedef std::vector<gfx::Display> DisplayList; | 52 typedef std::vector<gfx::Display> DisplayList; |
53 typedef std::vector<DisplayInfo> DisplayInfoList; | 53 typedef std::vector<DisplayInfo> DisplayInfoList; |
54 | 54 |
55 namespace { | 55 namespace { |
56 | 56 |
| 57 // List of value UI Scale values. These scales are equivalent to 1024, |
| 58 // 1280, 1600 and 1920 pixel width respectively on 2560 pixel width 2x |
| 59 // density display. |
| 60 const float kUIScales[] = {0.8f, 1.0f, 1.25f, 1.5f}; |
| 61 const size_t kUIScaleTableSize = arraysize(kUIScales); |
| 62 |
57 struct DisplaySortFunctor { | 63 struct DisplaySortFunctor { |
58 bool operator()(const gfx::Display& a, const gfx::Display& b) { | 64 bool operator()(const gfx::Display& a, const gfx::Display& b) { |
59 return a.id() < b.id(); | 65 return a.id() < b.id(); |
60 } | 66 } |
61 }; | 67 }; |
62 | 68 |
63 struct DisplayInfoSortFunctor { | 69 struct DisplayInfoSortFunctor { |
64 bool operator()(const DisplayInfo& a, const DisplayInfo& b) { | 70 bool operator()(const DisplayInfo& a, const DisplayInfo& b) { |
65 return a.id() < b.id(); | 71 return a.id() < b.id(); |
66 } | 72 } |
67 }; | 73 }; |
68 | 74 |
69 gfx::Display& GetInvalidDisplay() { | 75 gfx::Display& GetInvalidDisplay() { |
70 static gfx::Display* invalid_display = new gfx::Display(); | 76 static gfx::Display* invalid_display = new gfx::Display(); |
71 return *invalid_display; | 77 return *invalid_display; |
72 } | 78 } |
73 | 79 |
| 80 bool IsValidUIScale(float scale) { |
| 81 for (size_t i = 0; i < kUIScaleTableSize; ++i) { |
| 82 if (kUIScales[i] == scale) |
| 83 return true; |
| 84 } |
| 85 return false; |
| 86 } |
| 87 |
74 } // namespace | 88 } // namespace |
75 | 89 |
76 using aura::RootWindow; | 90 using aura::RootWindow; |
77 using aura::Window; | 91 using aura::Window; |
78 using std::string; | 92 using std::string; |
79 using std::vector; | 93 using std::vector; |
80 | 94 |
81 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, | 95 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, |
82 gfx::Display::kInvalidDisplayID); | 96 gfx::Display::kInvalidDisplayID); |
83 | 97 |
(...skipping 15 matching lines...) Expand all Loading... |
99 // static | 113 // static |
100 void DisplayManager::CycleDisplay() { | 114 void DisplayManager::CycleDisplay() { |
101 Shell::GetInstance()->display_manager()->CycleDisplayImpl(); | 115 Shell::GetInstance()->display_manager()->CycleDisplayImpl(); |
102 } | 116 } |
103 | 117 |
104 // static | 118 // static |
105 void DisplayManager::ToggleDisplayScaleFactor() { | 119 void DisplayManager::ToggleDisplayScaleFactor() { |
106 Shell::GetInstance()->display_manager()->ScaleDisplayImpl(); | 120 Shell::GetInstance()->display_manager()->ScaleDisplayImpl(); |
107 } | 121 } |
108 | 122 |
| 123 // static |
| 124 float DisplayManager::GetNextUIScale(float scale, bool up) { |
| 125 for (size_t i = 0; i < kUIScaleTableSize; ++i) { |
| 126 if (kUIScales[i] == scale) { |
| 127 if (up && i != kUIScaleTableSize -1) |
| 128 return kUIScales[i + 1]; |
| 129 if (!up && i != 0) |
| 130 return kUIScales[i - 1]; |
| 131 return kUIScales[i]; |
| 132 } |
| 133 } |
| 134 // Fallback to 1.0f if the |scale| wasn't in the list. |
| 135 return 1.0f; |
| 136 } |
| 137 |
109 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const { | 138 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const { |
110 for (DisplayList::const_iterator iter = displays_.begin(); | 139 for (DisplayList::const_iterator iter = displays_.begin(); |
111 iter != displays_.end(); ++iter) { | 140 iter != displays_.end(); ++iter) { |
112 if ((*iter).id() == display.id()) | 141 if ((*iter).id() == display.id()) |
113 return true; | 142 return true; |
114 } | 143 } |
115 return false; | 144 return false; |
116 } | 145 } |
117 | 146 |
118 bool DisplayManager::HasInternalDisplay() const { | 147 bool DisplayManager::HasInternalDisplay() const { |
(...skipping 30 matching lines...) Expand all Loading... |
149 } | 178 } |
150 | 179 |
151 void DisplayManager::SetOverscanInsets(int64 display_id, | 180 void DisplayManager::SetOverscanInsets(int64 display_id, |
152 const gfx::Insets& insets_in_dip) { | 181 const gfx::Insets& insets_in_dip) { |
153 // TODO(oshima): insets has to be rotated according to the | 182 // TODO(oshima): insets has to be rotated according to the |
154 // the current display rotation. | 183 // the current display rotation. |
155 display_info_[display_id].SetOverscanInsets(true, insets_in_dip); | 184 display_info_[display_id].SetOverscanInsets(true, insets_in_dip); |
156 DisplayInfoList display_info_list; | 185 DisplayInfoList display_info_list; |
157 for (DisplayList::const_iterator iter = displays_.begin(); | 186 for (DisplayList::const_iterator iter = displays_.begin(); |
158 iter != displays_.end(); ++iter) { | 187 iter != displays_.end(); ++iter) { |
159 display_info_list.push_back(GetDisplayInfo(*iter)); | 188 display_info_list.push_back(GetDisplayInfo(iter->id())); |
160 } | 189 } |
161 UpdateDisplays(display_info_list); | 190 UpdateDisplays(display_info_list); |
162 } | 191 } |
163 | 192 |
164 void DisplayManager::ClearCustomOverscanInsets(int64 display_id) { | 193 void DisplayManager::ClearCustomOverscanInsets(int64 display_id) { |
165 display_info_[display_id].clear_has_custom_overscan_insets(); | 194 display_info_[display_id].clear_has_custom_overscan_insets(); |
166 DisplayInfoList display_info_list; | 195 DisplayInfoList display_info_list; |
167 for (DisplayList::const_iterator iter = displays_.begin(); | 196 for (DisplayList::const_iterator iter = displays_.begin(); |
168 iter != displays_.end(); ++iter) { | 197 iter != displays_.end(); ++iter) { |
169 display_info_list.push_back(GetDisplayInfo(*iter)); | 198 display_info_list.push_back(GetDisplayInfo(iter->id())); |
170 } | 199 } |
171 UpdateDisplays(display_info_list); | 200 UpdateDisplays(display_info_list); |
172 } | 201 } |
173 | 202 |
174 void DisplayManager::SetDisplayRotation(int64 display_id, | 203 void DisplayManager::SetDisplayRotation(int64 display_id, |
175 gfx::Display::Rotation rotation) { | 204 gfx::Display::Rotation rotation) { |
176 if (!IsDisplayRotationEnabled()) | 205 if (!IsDisplayRotationEnabled()) |
177 return; | 206 return; |
178 DisplayInfoList display_info_list; | 207 DisplayInfoList display_info_list; |
179 for (DisplayList::const_iterator iter = displays_.begin(); | 208 for (DisplayList::const_iterator iter = displays_.begin(); |
180 iter != displays_.end(); ++iter) { | 209 iter != displays_.end(); ++iter) { |
181 DisplayInfo info = GetDisplayInfo(*iter); | 210 DisplayInfo info = GetDisplayInfo(iter->id()); |
182 if (info.id() == display_id) { | 211 if (info.id() == display_id) { |
183 if (info.rotation() == rotation) | 212 if (info.rotation() == rotation) |
184 return; | 213 return; |
185 info.set_rotation(rotation); | 214 info.set_rotation(rotation); |
186 } | 215 } |
187 display_info_list.push_back(info); | 216 display_info_list.push_back(info); |
188 } | 217 } |
189 UpdateDisplays(display_info_list); | 218 UpdateDisplays(display_info_list); |
190 } | 219 } |
191 | 220 |
192 void DisplayManager::SetDisplayUIScale(int64 display_id, | 221 void DisplayManager::SetDisplayUIScale(int64 display_id, |
193 float ui_scale) { | 222 float ui_scale) { |
194 if (!IsDisplayUIScalingEnabled()) | 223 if (!IsDisplayUIScalingEnabled() || !IsValidUIScale(ui_scale)) |
195 return; | 224 return; |
| 225 |
196 DisplayInfoList display_info_list; | 226 DisplayInfoList display_info_list; |
197 for (DisplayList::const_iterator iter = displays_.begin(); | 227 for (DisplayList::const_iterator iter = displays_.begin(); |
198 iter != displays_.end(); ++iter) { | 228 iter != displays_.end(); ++iter) { |
199 DisplayInfo info = GetDisplayInfo(*iter); | 229 DisplayInfo info = GetDisplayInfo(iter->id()); |
200 if (info.id() == display_id) { | 230 if (info.id() == display_id) { |
201 if (info.ui_scale() == ui_scale) | 231 if (info.ui_scale() == ui_scale) |
202 return; | 232 return; |
203 info.set_ui_scale(ui_scale); | 233 info.set_ui_scale(ui_scale); |
204 } | 234 } |
205 display_info_list.push_back(info); | 235 display_info_list.push_back(info); |
206 } | 236 } |
207 UpdateDisplays(display_info_list); | 237 UpdateDisplays(display_info_list); |
208 } | 238 } |
209 | 239 |
| 240 void DisplayManager::RegisterDisplayProperty( |
| 241 int64 display_id, |
| 242 gfx::Display::Rotation rotation, |
| 243 float ui_scale, |
| 244 const gfx::Insets* overscan_insets) { |
| 245 display_info_[display_id].set_rotation(rotation); |
| 246 |
| 247 if (IsValidUIScale(ui_scale)) |
| 248 display_info_[display_id].set_ui_scale(ui_scale); |
| 249 if (overscan_insets) |
| 250 display_info_[display_id].SetOverscanInsets(true, *overscan_insets); |
| 251 } |
210 | 252 |
211 bool DisplayManager::IsDisplayRotationEnabled() const { | 253 bool DisplayManager::IsDisplayRotationEnabled() const { |
212 static bool enabled = !CommandLine::ForCurrentProcess()-> | 254 static bool enabled = !CommandLine::ForCurrentProcess()-> |
213 HasSwitch(switches::kAshDisableDisplayRotation); | 255 HasSwitch(switches::kAshDisableDisplayRotation); |
214 return enabled; | 256 return enabled; |
215 } | 257 } |
216 | 258 |
217 bool DisplayManager::IsDisplayUIScalingEnabled() const { | 259 bool DisplayManager::IsDisplayUIScalingEnabled() const { |
218 static bool enabled = !CommandLine::ForCurrentProcess()-> | 260 static bool enabled = !CommandLine::ForCurrentProcess()-> |
219 HasSwitch(switches::kAshDisableUIScaling); | 261 HasSwitch(switches::kAshDisableUIScaling); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 false)); | 330 false)); |
289 internal_display_info_->SetBounds(gfx::Rect(0, 0, 800, 600)); | 331 internal_display_info_->SetBounds(gfx::Rect(0, 0, 800, 600)); |
290 } | 332 } |
291 new_display_info_list.push_back(*internal_display_info_.get()); | 333 new_display_info_list.push_back(*internal_display_info_.get()); |
292 // An internal display is always considered *connected*. | 334 // An internal display is always considered *connected*. |
293 num_connected_displays_++; | 335 num_connected_displays_++; |
294 } | 336 } |
295 UpdateDisplays(new_display_info_list); | 337 UpdateDisplays(new_display_info_list); |
296 } | 338 } |
297 | 339 |
| 340 void DisplayManager::UpdateDisplays() { |
| 341 DisplayInfoList display_info_list; |
| 342 for (DisplayList::const_iterator iter = displays_.begin(); |
| 343 iter != displays_.end(); ++iter) { |
| 344 display_info_list.push_back(GetDisplayInfo(iter->id())); |
| 345 } |
| 346 UpdateDisplays(display_info_list); |
| 347 } |
| 348 |
298 void DisplayManager::UpdateDisplays( | 349 void DisplayManager::UpdateDisplays( |
299 const std::vector<DisplayInfo>& updated_display_info_list) { | 350 const std::vector<DisplayInfo>& updated_display_info_list) { |
300 DisplayInfoList new_display_info_list = updated_display_info_list; | 351 DisplayInfoList new_display_info_list = updated_display_info_list; |
301 std::sort(displays_.begin(), displays_.end(), DisplaySortFunctor()); | 352 std::sort(displays_.begin(), displays_.end(), DisplaySortFunctor()); |
302 std::sort(new_display_info_list.begin(), | 353 std::sort(new_display_info_list.begin(), |
303 new_display_info_list.end(), | 354 new_display_info_list.end(), |
304 DisplayInfoSortFunctor()); | 355 DisplayInfoSortFunctor()); |
305 DisplayList removed_displays; | 356 DisplayList removed_displays; |
306 std::vector<size_t> changed_display_indices; | 357 std::vector<size_t> changed_display_indices; |
307 std::vector<size_t> added_display_indices; | 358 std::vector<size_t> added_display_indices; |
(...skipping 14 matching lines...) Expand all Loading... |
322 new_displays.push_back( | 373 new_displays.push_back( |
323 CreateDisplayFromDisplayInfoById(new_info_iter->id())); | 374 CreateDisplayFromDisplayInfoById(new_info_iter->id())); |
324 ++new_info_iter; | 375 ++new_info_iter; |
325 } else if (new_info_iter == new_display_info_list.end()) { | 376 } else if (new_info_iter == new_display_info_list.end()) { |
326 // more displays in current list. | 377 // more displays in current list. |
327 removed_displays.push_back(*curr_iter); | 378 removed_displays.push_back(*curr_iter); |
328 ++curr_iter; | 379 ++curr_iter; |
329 } else if (curr_iter->id() == new_info_iter->id()) { | 380 } else if (curr_iter->id() == new_info_iter->id()) { |
330 const gfx::Display& current_display = *curr_iter; | 381 const gfx::Display& current_display = *curr_iter; |
331 // Copy the info because |CreateDisplayFromInfo| updates the instance. | 382 // Copy the info because |CreateDisplayFromInfo| updates the instance. |
332 const DisplayInfo current_display_info = GetDisplayInfo(current_display); | 383 const DisplayInfo current_display_info = |
| 384 GetDisplayInfo(current_display.id()); |
333 InsertAndUpdateDisplayInfo(*new_info_iter); | 385 InsertAndUpdateDisplayInfo(*new_info_iter); |
334 gfx::Display new_display = | 386 gfx::Display new_display = |
335 CreateDisplayFromDisplayInfoById(new_info_iter->id()); | 387 CreateDisplayFromDisplayInfoById(new_info_iter->id()); |
336 const DisplayInfo& new_display_info = GetDisplayInfo(new_display); | 388 const DisplayInfo& new_display_info = GetDisplayInfo(new_display.id()); |
337 // TODO(oshima): Rotating square dislay doesn't work as the size | 389 // TODO(oshima): Rotating square dislay doesn't work as the size |
338 // won't change. This doesn't cause a problem now as there is no | 390 // won't change. This doesn't cause a problem now as there is no |
339 // such display. This will be fixed by comparing the rotation as | 391 // such display. This will be fixed by comparing the rotation as |
340 // well when the rotation variable is added to gfx::Display. | 392 // well when the rotation variable is added to gfx::Display. |
341 if (force_bounds_changed_ || | 393 if (force_bounds_changed_ || |
342 (current_display_info.bounds_in_pixel() != | 394 (current_display_info.bounds_in_pixel() != |
343 new_display_info.bounds_in_pixel()) || | 395 new_display_info.bounds_in_pixel()) || |
344 (current_display.device_scale_factor() != | 396 (current_display.device_scale_factor() != |
345 new_display.device_scale_factor()) || | 397 new_display.device_scale_factor()) || |
346 (current_display_info.size_in_pixel() != | 398 (current_display_info.size_in_pixel() != |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 return index < displays_.size() ? &displays_[index] : NULL; | 465 return index < displays_.size() ? &displays_[index] : NULL; |
414 } | 466 } |
415 | 467 |
416 const gfx::Display* DisplayManager::GetPrimaryDisplayCandidate() const { | 468 const gfx::Display* DisplayManager::GetPrimaryDisplayCandidate() const { |
417 const gfx::Display* primary_candidate = &displays_[0]; | 469 const gfx::Display* primary_candidate = &displays_[0]; |
418 #if defined(OS_CHROMEOS) | 470 #if defined(OS_CHROMEOS) |
419 if (base::chromeos::IsRunningOnChromeOS()) { | 471 if (base::chromeos::IsRunningOnChromeOS()) { |
420 // On ChromeOS device, root windows are stacked vertically, and | 472 // On ChromeOS device, root windows are stacked vertically, and |
421 // default primary is the one on top. | 473 // default primary is the one on top. |
422 int count = GetNumDisplays(); | 474 int count = GetNumDisplays(); |
423 int y = GetDisplayInfo(*primary_candidate).bounds_in_pixel().y(); | 475 int y = GetDisplayInfo(primary_candidate->id()).bounds_in_pixel().y(); |
424 for (int i = 1; i < count; ++i) { | 476 for (int i = 1; i < count; ++i) { |
425 const gfx::Display* display = &displays_[i]; | 477 const gfx::Display* display = &displays_[i]; |
426 const DisplayInfo& display_info = GetDisplayInfo(*display); | 478 const DisplayInfo& display_info = GetDisplayInfo(display->id()); |
427 if (display->IsInternal()) { | 479 if (display->IsInternal()) { |
428 primary_candidate = display; | 480 primary_candidate = display; |
429 break; | 481 break; |
430 } else if (display_info.bounds_in_pixel().y() < y) { | 482 } else if (display_info.bounds_in_pixel().y() < y) { |
431 primary_candidate = display; | 483 primary_candidate = display; |
432 y = display_info.bounds_in_pixel().y(); | 484 y = display_info.bounds_in_pixel().y(); |
433 } | 485 } |
434 } | 486 } |
435 } | 487 } |
436 #endif | 488 #endif |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 int area = intersect.width() * intersect.height(); | 526 int area = intersect.width() * intersect.height(); |
475 if (area > max) { | 527 if (area > max) { |
476 max = area; | 528 max = area; |
477 matching = &(*iter); | 529 matching = &(*iter); |
478 } | 530 } |
479 } | 531 } |
480 // Fallback to the primary display if there is no matching display. | 532 // Fallback to the primary display if there is no matching display. |
481 return matching ? *matching : DisplayController::GetPrimaryDisplay(); | 533 return matching ? *matching : DisplayController::GetPrimaryDisplay(); |
482 } | 534 } |
483 | 535 |
484 const DisplayInfo& DisplayManager::GetDisplayInfo( | 536 const DisplayInfo& DisplayManager::GetDisplayInfo(int64 display_id) const { |
485 const gfx::Display& display) const { | |
486 std::map<int64, DisplayInfo>::const_iterator iter = | 537 std::map<int64, DisplayInfo>::const_iterator iter = |
487 display_info_.find(display.id()); | 538 display_info_.find(display_id); |
488 CHECK(iter != display_info_.end()); | 539 CHECK(iter != display_info_.end()); |
489 return iter->second; | 540 return iter->second; |
490 } | 541 } |
491 | 542 |
492 std::string DisplayManager::GetDisplayNameForId(int64 id) { | 543 std::string DisplayManager::GetDisplayNameForId(int64 id) { |
493 if (id == gfx::Display::kInvalidDisplayID) | 544 if (id == gfx::Display::kInvalidDisplayID) |
494 return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); | 545 return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); |
495 | 546 |
496 std::map<int64, DisplayInfo>::const_iterator iter = display_info_.find(id); | 547 std::map<int64, DisplayInfo>::const_iterator iter = display_info_.find(id); |
497 if (iter != display_info_.end() && !iter->second.name().empty()) | 548 if (iter != display_info_.end() && !iter->second.name().empty()) |
(...skipping 30 matching lines...) Expand all Loading... |
528 if (displays_.empty()) | 579 if (displays_.empty()) |
529 AddDisplayFromSpec(std::string() /* default */); | 580 AddDisplayFromSpec(std::string() /* default */); |
530 first_display_id_ = displays_[0].id(); | 581 first_display_id_ = displays_[0].id(); |
531 num_connected_displays_ = displays_.size(); | 582 num_connected_displays_ = displays_.size(); |
532 } | 583 } |
533 | 584 |
534 void DisplayManager::CycleDisplayImpl() { | 585 void DisplayManager::CycleDisplayImpl() { |
535 DCHECK(!displays_.empty()); | 586 DCHECK(!displays_.empty()); |
536 std::vector<DisplayInfo> new_display_info_list; | 587 std::vector<DisplayInfo> new_display_info_list; |
537 new_display_info_list.push_back( | 588 new_display_info_list.push_back( |
538 GetDisplayInfo(DisplayController::GetPrimaryDisplay())); | 589 GetDisplayInfo(DisplayController::GetPrimaryDisplay().id())); |
539 // Add if there is only one display. | 590 // Add if there is only one display. |
540 if (displays_.size() == 1) { | 591 if (displays_.size() == 1) { |
541 // Layout the 2nd display below the primary as with the real device. | 592 // Layout the 2nd display below the primary as with the real device. |
542 aura::RootWindow* primary = Shell::GetPrimaryRootWindow(); | 593 aura::RootWindow* primary = Shell::GetPrimaryRootWindow(); |
543 gfx::Rect host_bounds = | 594 gfx::Rect host_bounds = |
544 gfx::Rect(primary->GetHostOrigin(), primary->GetHostSize()); | 595 gfx::Rect(primary->GetHostOrigin(), primary->GetHostSize()); |
545 new_display_info_list.push_back(DisplayInfo::CreateFromSpec( | 596 new_display_info_list.push_back(DisplayInfo::CreateFromSpec( |
546 base::StringPrintf( | 597 base::StringPrintf( |
547 "%d+%d-500x400", host_bounds.x(), host_bounds.bottom()))); | 598 "%d+%d-500x400", host_bounds.x(), host_bounds.bottom()))); |
548 } | 599 } |
549 UpdateDisplays(new_display_info_list); | 600 UpdateDisplays(new_display_info_list); |
550 } | 601 } |
551 | 602 |
552 void DisplayManager::ScaleDisplayImpl() { | 603 void DisplayManager::ScaleDisplayImpl() { |
553 DCHECK(!displays_.empty()); | 604 DCHECK(!displays_.empty()); |
554 std::vector<DisplayInfo> new_display_info_list; | 605 std::vector<DisplayInfo> new_display_info_list; |
555 for (DisplayList::const_iterator iter = displays_.begin(); | 606 for (DisplayList::const_iterator iter = displays_.begin(); |
556 iter != displays_.end(); ++iter) { | 607 iter != displays_.end(); ++iter) { |
557 DisplayInfo display_info = GetDisplayInfo(*iter); | 608 DisplayInfo display_info = GetDisplayInfo(iter->id()); |
558 display_info.set_device_scale_factor( | 609 display_info.set_device_scale_factor( |
559 display_info.device_scale_factor() == 1.0f ? 2.0f : 1.0f); | 610 display_info.device_scale_factor() == 1.0f ? 2.0f : 1.0f); |
560 new_display_info_list.push_back(display_info); | 611 new_display_info_list.push_back(display_info); |
561 } | 612 } |
562 UpdateDisplays(new_display_info_list); | 613 UpdateDisplays(new_display_info_list); |
563 } | 614 } |
564 | 615 |
565 gfx::Display& DisplayManager::FindDisplayForRootWindow( | 616 gfx::Display& DisplayManager::FindDisplayForRootWindow( |
566 const aura::RootWindow* root_window) { | 617 const aura::RootWindow* root_window) { |
567 int64 id = root_window->GetProperty(kDisplayIdKey); | 618 int64 id = root_window->GetProperty(kDisplayIdKey); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 aura::client::GetScreenPositionClient(root_window); | 675 aura::client::GetScreenPositionClient(root_window); |
625 client->ConvertPointFromScreen(root_window, &target_location); | 676 client->ConvertPointFromScreen(root_window, &target_location); |
626 | 677 |
627 root_window->MoveCursorTo(target_location); | 678 root_window->MoveCursorTo(target_location); |
628 } | 679 } |
629 | 680 |
630 void DisplayManager::InsertAndUpdateDisplayInfo(const DisplayInfo& new_info) { | 681 void DisplayManager::InsertAndUpdateDisplayInfo(const DisplayInfo& new_info) { |
631 std::map<int64, DisplayInfo>::iterator info = | 682 std::map<int64, DisplayInfo>::iterator info = |
632 display_info_.find(new_info.id()); | 683 display_info_.find(new_info.id()); |
633 if (info != display_info_.end()) | 684 if (info != display_info_.end()) |
634 info->second.CopyFromNative(new_info); | 685 info->second.Copy(new_info); |
635 else | 686 else { |
636 display_info_[new_info.id()] = new_info; | 687 display_info_[new_info.id()] = new_info; |
| 688 display_info_[new_info.id()].set_native(false); |
| 689 } |
637 bool on_chromeos = false; | 690 bool on_chromeos = false; |
638 #if defined(OS_CHROMEOS) | 691 #if defined(OS_CHROMEOS) |
639 on_chromeos = base::chromeos::IsRunningOnChromeOS(); | 692 on_chromeos = base::chromeos::IsRunningOnChromeOS(); |
640 #endif | 693 #endif |
641 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 694 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
642 if ((new_info.id() == gfx::Display::InternalDisplayId() || !on_chromeos) && | 695 if ((new_info.id() == gfx::Display::InternalDisplayId() || !on_chromeos) && |
643 command_line->HasSwitch(switches::kAshInternalDisplayUIScale)) { | 696 command_line->HasSwitch(switches::kAshInternalDisplayUIScale)) { |
644 double scale_in_double = 1.0; | 697 double scale_in_double = 1.0; |
645 std::string value = CommandLine::ForCurrentProcess()-> | 698 std::string value = CommandLine::ForCurrentProcess()-> |
646 GetSwitchValueASCII(switches::kAshInternalDisplayUIScale); | 699 GetSwitchValueASCII(switches::kAshInternalDisplayUIScale); |
(...skipping 16 matching lines...) Expand all Loading... |
663 // always (0,0) and the secondary display's bounds will be updated | 716 // always (0,0) and the secondary display's bounds will be updated |
664 // by |DisplayController::UpdateDisplayBoundsForLayout|. | 717 // by |DisplayController::UpdateDisplayBoundsForLayout|. |
665 new_display.SetScaleAndBounds( | 718 new_display.SetScaleAndBounds( |
666 display_info.device_scale_factor(), gfx::Rect(bounds_in_pixel.size())); | 719 display_info.device_scale_factor(), gfx::Rect(bounds_in_pixel.size())); |
667 new_display.set_rotation(display_info.rotation()); | 720 new_display.set_rotation(display_info.rotation()); |
668 return new_display; | 721 return new_display; |
669 } | 722 } |
670 | 723 |
671 } // namespace internal | 724 } // namespace internal |
672 } // namespace ash | 725 } // namespace ash |
OLD | NEW |