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 <cmath> | 7 #include <cmath> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "ui/gfx/rect.h" | 26 #include "ui/gfx/rect.h" |
27 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
28 #include "ui/gfx/size_conversions.h" | 28 #include "ui/gfx/size_conversions.h" |
29 | 29 |
30 #if defined(USE_X11) | 30 #if defined(USE_X11) |
31 #include "ui/base/x/x11_util.h" | 31 #include "ui/base/x/x11_util.h" |
32 #endif | 32 #endif |
33 | 33 |
34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
35 #include "ash/display/output_configurator_animation.h" | 35 #include "ash/display/output_configurator_animation.h" |
36 #include "base/chromeos/chromeos_version.h" | 36 #include "base/sys_info.h" |
37 #include "chromeos/display/output_configurator.h" | 37 #include "chromeos/display/output_configurator.h" |
38 #endif | 38 #endif |
39 | 39 |
40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
41 #include "base/win/windows_version.h" | 41 #include "base/win/windows_version.h" |
42 #endif | 42 #endif |
43 | 43 |
44 namespace ash { | 44 namespace ash { |
45 namespace internal { | 45 namespace internal { |
46 typedef std::vector<gfx::Display> DisplayList; | 46 typedef std::vector<gfx::Display> DisplayList; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 DisplayManager::DisplayManager() | 143 DisplayManager::DisplayManager() |
144 : delegate_(NULL), | 144 : delegate_(NULL), |
145 layout_store_(new DisplayLayoutStore), | 145 layout_store_(new DisplayLayoutStore), |
146 first_display_id_(gfx::Display::kInvalidDisplayID), | 146 first_display_id_(gfx::Display::kInvalidDisplayID), |
147 num_connected_displays_(0), | 147 num_connected_displays_(0), |
148 force_bounds_changed_(false), | 148 force_bounds_changed_(false), |
149 change_display_upon_host_resize_(false), | 149 change_display_upon_host_resize_(false), |
150 software_mirroring_enabled_(false) { | 150 software_mirroring_enabled_(false) { |
151 #if defined(OS_CHROMEOS) | 151 #if defined(OS_CHROMEOS) |
152 change_display_upon_host_resize_ = !base::chromeos::IsRunningOnChromeOS(); | 152 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); |
153 #endif | 153 #endif |
154 } | 154 } |
155 | 155 |
156 DisplayManager::~DisplayManager() { | 156 DisplayManager::~DisplayManager() { |
157 } | 157 } |
158 | 158 |
159 // static | 159 // static |
160 std::vector<float> DisplayManager::GetScalesForDisplay( | 160 std::vector<float> DisplayManager::GetScalesForDisplay( |
161 const DisplayInfo& info) { | 161 const DisplayInfo& info) { |
162 std::vector<float> ret; | 162 std::vector<float> ret; |
163 if (info.device_scale_factor() == 2.0f) { | 163 if (info.device_scale_factor() == 2.0f) { |
164 ret.assign(kUIScalesFor2x, kUIScalesFor2x + arraysize(kUIScalesFor2x)); | 164 ret.assign(kUIScalesFor2x, kUIScalesFor2x + arraysize(kUIScalesFor2x)); |
165 return ret; | 165 return ret; |
166 } | 166 } |
167 switch (info.bounds_in_native().width()) { | 167 switch (info.bounds_in_native().width()) { |
168 case 1280: | 168 case 1280: |
169 ret.assign(kUIScalesFor1280, | 169 ret.assign(kUIScalesFor1280, |
170 kUIScalesFor1280 + arraysize(kUIScalesFor1280)); | 170 kUIScalesFor1280 + arraysize(kUIScalesFor1280)); |
171 break; | 171 break; |
172 case 1366: | 172 case 1366: |
173 ret.assign(kUIScalesFor1366, | 173 ret.assign(kUIScalesFor1366, |
174 kUIScalesFor1366 + arraysize(kUIScalesFor1366)); | 174 kUIScalesFor1366 + arraysize(kUIScalesFor1366)); |
175 break; | 175 break; |
176 default: | 176 default: |
177 ret.assign(kUIScalesFor1280, | 177 ret.assign(kUIScalesFor1280, |
178 kUIScalesFor1280 + arraysize(kUIScalesFor1280)); | 178 kUIScalesFor1280 + arraysize(kUIScalesFor1280)); |
179 #if defined(OS_CHROMEOS) | 179 #if defined(OS_CHROMEOS) |
180 if (base::chromeos::IsRunningOnChromeOS()) | 180 if (base::SysInfo::IsRunningOnChromeOS()) |
181 NOTREACHED() << "Unknown resolution:" << info.ToString(); | 181 NOTREACHED() << "Unknown resolution:" << info.ToString(); |
182 #endif | 182 #endif |
183 } | 183 } |
184 return ret; | 184 return ret; |
185 } | 185 } |
186 | 186 |
187 // static | 187 // static |
188 float DisplayManager::GetNextUIScale(const DisplayInfo& info, bool up) { | 188 float DisplayManager::GetNextUIScale(const DisplayInfo& info, bool up) { |
189 float scale = info.ui_scale(); | 189 float scale = info.ui_scale(); |
190 std::vector<float> scales = GetScalesForDisplay(info); | 190 std::vector<float> scales = GetScalesForDisplay(info); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 LOG(WARNING) << "Unsupported resolution was requested:" | 381 LOG(WARNING) << "Unsupported resolution was requested:" |
382 << resolution.ToString(); | 382 << resolution.ToString(); |
383 return; | 383 return; |
384 } else if (iter == resolutions.begin()) { | 384 } else if (iter == resolutions.begin()) { |
385 // The best resolution was set, so forget it. | 385 // The best resolution was set, so forget it. |
386 resolutions_.erase(display_id); | 386 resolutions_.erase(display_id); |
387 } else { | 387 } else { |
388 resolutions_[display_id] = resolution; | 388 resolutions_[display_id] = resolution; |
389 } | 389 } |
390 #if defined(OS_CHROMEOS) && defined(USE_X11) | 390 #if defined(OS_CHROMEOS) && defined(USE_X11) |
391 if (base::chromeos::IsRunningOnChromeOS()) | 391 if (base::SysInfo::IsRunningOnChromeOS()) |
392 Shell::GetInstance()->output_configurator()->ScheduleConfigureOutputs(); | 392 Shell::GetInstance()->output_configurator()->ScheduleConfigureOutputs(); |
393 #endif | 393 #endif |
394 } | 394 } |
395 | 395 |
396 void DisplayManager::RegisterDisplayProperty( | 396 void DisplayManager::RegisterDisplayProperty( |
397 int64 display_id, | 397 int64 display_id, |
398 gfx::Display::Rotation rotation, | 398 gfx::Display::Rotation rotation, |
399 float ui_scale, | 399 float ui_scale, |
400 const gfx::Insets* overscan_insets, | 400 const gfx::Insets* overscan_insets, |
401 const gfx::Size& resolution_in_pixels) { | 401 const gfx::Size& resolution_in_pixels) { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // from dock mode to software mirror mode. | 670 // from dock mode to software mirror mode. |
671 mirror_window_updater.reset(); | 671 mirror_window_updater.reset(); |
672 for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); | 672 for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); |
673 iter != changed_display_indices.end(); ++iter) { | 673 iter != changed_display_indices.end(); ++iter) { |
674 Shell::GetInstance()->screen()->NotifyBoundsChanged(displays_[*iter]); | 674 Shell::GetInstance()->screen()->NotifyBoundsChanged(displays_[*iter]); |
675 } | 675 } |
676 if (delegate_) | 676 if (delegate_) |
677 delegate_->PostDisplayConfigurationChange(); | 677 delegate_->PostDisplayConfigurationChange(); |
678 | 678 |
679 #if defined(USE_X11) && defined(OS_CHROMEOS) | 679 #if defined(USE_X11) && defined(OS_CHROMEOS) |
680 if (!changed_display_indices.empty() && base::chromeos::IsRunningOnChromeOS()) | 680 if (!changed_display_indices.empty() && base::SysInfo::IsRunningOnChromeOS()) |
681 ui::ClearX11DefaultRootWindow(); | 681 ui::ClearX11DefaultRootWindow(); |
682 #endif | 682 #endif |
683 } | 683 } |
684 | 684 |
685 const gfx::Display& DisplayManager::GetDisplayAt(size_t index) const { | 685 const gfx::Display& DisplayManager::GetDisplayAt(size_t index) const { |
686 DCHECK_LT(index, displays_.size()); | 686 DCHECK_LT(index, displays_.size()); |
687 return displays_[index]; | 687 return displays_[index]; |
688 } | 688 } |
689 | 689 |
690 const gfx::Display& DisplayManager::GetPrimaryDisplayCandidate() const { | 690 const gfx::Display& DisplayManager::GetPrimaryDisplayCandidate() const { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 display_id = first_display_id(); | 729 display_id = first_display_id(); |
730 #endif | 730 #endif |
731 return display_id; | 731 return display_id; |
732 } | 732 } |
733 | 733 |
734 void DisplayManager::SetMirrorMode(bool mirrored) { | 734 void DisplayManager::SetMirrorMode(bool mirrored) { |
735 if (num_connected_displays() <= 1) | 735 if (num_connected_displays() <= 1) |
736 return; | 736 return; |
737 | 737 |
738 #if defined(OS_CHROMEOS) | 738 #if defined(OS_CHROMEOS) |
739 if (base::chromeos::IsRunningOnChromeOS()) { | 739 if (base::SysInfo::IsRunningOnChromeOS()) { |
740 chromeos::OutputState new_state = mirrored ? | 740 chromeos::OutputState new_state = mirrored ? |
741 chromeos::STATE_DUAL_MIRROR : chromeos::STATE_DUAL_EXTENDED; | 741 chromeos::STATE_DUAL_MIRROR : chromeos::STATE_DUAL_EXTENDED; |
742 Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state); | 742 Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state); |
743 return; | 743 return; |
744 } | 744 } |
745 #endif | 745 #endif |
746 SetSoftwareMirroring(mirrored); | 746 SetSoftwareMirroring(mirrored); |
747 DisplayInfoList display_info_list; | 747 DisplayInfoList display_info_list; |
748 int count = 0; | 748 int count = 0; |
749 for (std::map<int64, DisplayInfo>::const_iterator iter = | 749 for (std::map<int64, DisplayInfo>::const_iterator iter = |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 break; | 942 break; |
943 } | 943 } |
944 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 944 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
945 secondary_display->set_bounds( | 945 secondary_display->set_bounds( |
946 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 946 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
947 secondary_display->UpdateWorkAreaFromInsets(insets); | 947 secondary_display->UpdateWorkAreaFromInsets(insets); |
948 } | 948 } |
949 | 949 |
950 } // namespace internal | 950 } // namespace internal |
951 } // namespace ash | 951 } // namespace ash |
OLD | NEW |