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