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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "ash/common/ash_switches.h" | |
17 #include "ash/display/display_util.h" | 16 #include "ash/display/display_util.h" |
18 #include "ash/screen_util.h" | 17 #include "ash/screen_util.h" |
19 #include "ash/shell.h" | 18 #include "ash/shell.h" |
20 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
21 #include "base/command_line.h" | 20 #include "base/command_line.h" |
22 #include "base/logging.h" | 21 #include "base/logging.h" |
23 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
24 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
25 #include "base/run_loop.h" | 24 #include "base/run_loop.h" |
26 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
27 #include "base/strings/string_split.h" | 26 #include "base/strings/string_split.h" |
28 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
29 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
30 #include "base/threading/thread_task_runner_handle.h" | 29 #include "base/threading/thread_task_runner_handle.h" |
31 #include "grit/ash_strings.h" | 30 #include "grit/ash_strings.h" |
32 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
34 #include "ui/display/display_observer.h" | 33 #include "ui/display/display_observer.h" |
| 34 #include "ui/display/display_switches.h" |
35 #include "ui/display/manager/display_layout_store.h" | 35 #include "ui/display/manager/display_layout_store.h" |
36 #include "ui/display/manager/display_manager_utilities.h" | 36 #include "ui/display/manager/display_manager_utilities.h" |
37 #include "ui/display/manager/managed_display_info.h" | 37 #include "ui/display/manager/managed_display_info.h" |
38 #include "ui/display/screen.h" | 38 #include "ui/display/screen.h" |
39 #include "ui/gfx/font_render_params.h" | 39 #include "ui/gfx/font_render_params.h" |
40 #include "ui/gfx/geometry/rect.h" | 40 #include "ui/gfx/geometry/rect.h" |
41 #include "ui/gfx/geometry/size_conversions.h" | 41 #include "ui/gfx/geometry/size_conversions.h" |
42 | 42 |
43 #if defined(USE_X11) | 43 #if defined(USE_X11) |
44 #include "ui/base/x/x11_util.h" // nogncheck | 44 #include "ui/base/x/x11_util.h" // nogncheck |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 info->bounds_in_native().size(), 0.0 /* refresh_rate */, | 96 info->bounds_in_native().size(), 0.0 /* refresh_rate */, |
97 false /* interlaced */, false /* native_mode */, 1.0 /* ui_scale */, | 97 false /* interlaced */, false /* native_mode */, 1.0 /* ui_scale */, |
98 info->device_scale_factor()); | 98 info->device_scale_factor()); |
99 info->SetManagedDisplayModes( | 99 info->SetManagedDisplayModes( |
100 display::CreateInternalManagedDisplayModeList(native_mode)); | 100 display::CreateInternalManagedDisplayModeList(native_mode)); |
101 } | 101 } |
102 | 102 |
103 void MaybeInitInternalDisplay(display::ManagedDisplayInfo* info) { | 103 void MaybeInitInternalDisplay(display::ManagedDisplayInfo* info) { |
104 int64_t id = info->id(); | 104 int64_t id = info->id(); |
105 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 105 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
106 if (command_line->HasSwitch(switches::kAshUseFirstDisplayAsInternal)) { | 106 if (command_line->HasSwitch(::switches::kUseFirstDisplayAsInternal)) { |
107 display::Display::SetInternalDisplayId(id); | 107 display::Display::SetInternalDisplayId(id); |
108 SetInternalManagedDisplayModeList(info); | 108 SetInternalManagedDisplayModeList(info); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 gfx::Size GetMaxNativeSize(const display::ManagedDisplayInfo& info) { | 112 gfx::Size GetMaxNativeSize(const display::ManagedDisplayInfo& info) { |
113 gfx::Size size; | 113 gfx::Size size; |
114 for (auto& mode : info.display_modes()) { | 114 for (auto& mode : info.display_modes()) { |
115 if (mode->size().GetArea() > size.GetArea()) | 115 if (mode->size().GetArea() > size.GetArea()) |
116 size = mode->size(); | 116 size = mode->size(); |
(...skipping 20 matching lines...) Expand all Loading... |
137 multi_display_mode_(EXTENDED), | 137 multi_display_mode_(EXTENDED), |
138 current_default_multi_display_mode_(EXTENDED), | 138 current_default_multi_display_mode_(EXTENDED), |
139 mirroring_display_id_(display::Display::kInvalidDisplayID), | 139 mirroring_display_id_(display::Display::kInvalidDisplayID), |
140 registered_internal_display_rotation_lock_(false), | 140 registered_internal_display_rotation_lock_(false), |
141 registered_internal_display_rotation_(display::Display::ROTATE_0), | 141 registered_internal_display_rotation_(display::Display::ROTATE_0), |
142 unified_desktop_enabled_(false), | 142 unified_desktop_enabled_(false), |
143 weak_ptr_factory_(this) { | 143 weak_ptr_factory_(this) { |
144 #if defined(OS_CHROMEOS) | 144 #if defined(OS_CHROMEOS) |
145 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); | 145 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); |
146 unified_desktop_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 146 unified_desktop_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
147 switches::kAshEnableUnifiedDesktop); | 147 ::switches::kEnableUnifiedDesktop); |
148 #endif | 148 #endif |
149 } | 149 } |
150 | 150 |
151 DisplayManager::~DisplayManager() { | 151 DisplayManager::~DisplayManager() { |
152 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
153 // Reset the font params. | 153 // Reset the font params. |
154 gfx::SetFontRenderParamsDeviceScaleFactor(1.0f); | 154 gfx::SetFontRenderParamsDeviceScaleFactor(1.0f); |
155 #endif | 155 #endif |
156 } | 156 } |
157 | 157 |
158 bool DisplayManager::InitFromCommandLine() { | 158 bool DisplayManager::InitFromCommandLine() { |
159 DisplayInfoList info_list; | 159 DisplayInfoList info_list; |
160 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 160 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
161 if (!command_line->HasSwitch(switches::kAshHostWindowBounds)) | 161 if (!command_line->HasSwitch(::switches::kHostWindowBounds)) |
162 return false; | 162 return false; |
163 const string size_str = | 163 const string size_str = |
164 command_line->GetSwitchValueASCII(switches::kAshHostWindowBounds); | 164 command_line->GetSwitchValueASCII(::switches::kHostWindowBounds); |
165 for (const std::string& part : base::SplitString( | 165 for (const std::string& part : base::SplitString( |
166 size_str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | 166 size_str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
167 info_list.push_back(display::ManagedDisplayInfo::CreateFromSpec(part)); | 167 info_list.push_back(display::ManagedDisplayInfo::CreateFromSpec(part)); |
168 info_list.back().set_native(true); | 168 info_list.back().set_native(true); |
169 } | 169 } |
170 MaybeInitInternalDisplay(&info_list[0]); | 170 MaybeInitInternalDisplay(&info_list[0]); |
171 if (info_list.size() > 1 && | 171 if (info_list.size() > 1 && |
172 command_line->HasSwitch(switches::kAshEnableSoftwareMirroring)) { | 172 command_line->HasSwitch(::switches::kEnableSoftwareMirroring)) { |
173 SetMultiDisplayMode(MIRRORING); | 173 SetMultiDisplayMode(MIRRORING); |
174 } | 174 } |
175 OnNativeDisplaysChanged(info_list); | 175 OnNativeDisplaysChanged(info_list); |
176 return true; | 176 return true; |
177 } | 177 } |
178 | 178 |
179 void DisplayManager::InitDefaultDisplay() { | 179 void DisplayManager::InitDefaultDisplay() { |
180 DisplayInfoList info_list; | 180 DisplayInfoList info_list; |
181 info_list.push_back( | 181 info_list.push_back( |
182 display::ManagedDisplayInfo::CreateFromSpec(std::string())); | 182 display::ManagedDisplayInfo::CreateFromSpec(std::string())); |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 | 1401 |
1402 void DisplayManager::AddObserver(display::DisplayObserver* observer) { | 1402 void DisplayManager::AddObserver(display::DisplayObserver* observer) { |
1403 observers_.AddObserver(observer); | 1403 observers_.AddObserver(observer); |
1404 } | 1404 } |
1405 | 1405 |
1406 void DisplayManager::RemoveObserver(display::DisplayObserver* observer) { | 1406 void DisplayManager::RemoveObserver(display::DisplayObserver* observer) { |
1407 observers_.RemoveObserver(observer); | 1407 observers_.RemoveObserver(observer); |
1408 } | 1408 } |
1409 | 1409 |
1410 } // namespace ash | 1410 } // namespace ash |
OLD | NEW |