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 <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 mirroring_display_id_(gfx::Display::kInvalidDisplayID), | 139 mirroring_display_id_(gfx::Display::kInvalidDisplayID), |
| 140 registered_internal_display_rotation_lock_(false), | 140 registered_internal_display_rotation_lock_(false), |
| 141 registered_internal_display_rotation_(gfx::Display::ROTATE_0), | 141 registered_internal_display_rotation_(gfx::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::kAshEnableUnifiedDesktop); |
| 148 #endif | 148 #endif |
| 149 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_.get()); | 149 gfx::Screen* current = gfx::Screen::GetScreen(); |
| 150 gfx::Screen* current_native = | |
| 151 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); | |
| 152 // If there is no native, or the native was for shutdown, | 150 // If there is no native, or the native was for shutdown, |
| 153 // use ash's screen. | 151 // use ash's screen. |
| 154 if (!current_native || | 152 if (!current || current == screen_for_shutdown) { |
|
sky
2016/01/19 22:47:54
nit: nuke {}
scottmg
2016/01/20 00:52:57
Done.
| |
| 155 current_native == screen_for_shutdown) { | 153 gfx::Screen::SetScreenInstance(screen_.get()); |
| 156 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | |
| 157 } | 154 } |
| 158 } | 155 } |
| 159 | 156 |
| 160 DisplayManager::~DisplayManager() { | 157 DisplayManager::~DisplayManager() { |
| 161 #if defined(OS_CHROMEOS) | 158 #if defined(OS_CHROMEOS) |
| 162 // Reset the font params. | 159 // Reset the font params. |
| 163 gfx::SetFontRenderParamsDeviceScaleFactor(1.0f); | 160 gfx::SetFontRenderParamsDeviceScaleFactor(1.0f); |
| 164 #endif | 161 #endif |
| 165 } | 162 } |
| 166 | 163 |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1071 if (IsInUnifiedMode() && num_connected_displays() >= 2) | 1068 if (IsInUnifiedMode() && num_connected_displays() >= 2) |
| 1072 return make_scoped_ptr(new UnifiedMouseWarpController()); | 1069 return make_scoped_ptr(new UnifiedMouseWarpController()); |
| 1073 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest | 1070 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest |
| 1074 // that injects MockScreen. | 1071 // that injects MockScreen. |
| 1075 if (GetNumDisplays() < 2 || num_connected_displays() < 2) | 1072 if (GetNumDisplays() < 2 || num_connected_displays() < 2) |
| 1076 return make_scoped_ptr(new NullMouseWarpController()); | 1073 return make_scoped_ptr(new NullMouseWarpController()); |
| 1077 return make_scoped_ptr(new ExtendedMouseWarpController(drag_source)); | 1074 return make_scoped_ptr(new ExtendedMouseWarpController(drag_source)); |
| 1078 } | 1075 } |
| 1079 | 1076 |
| 1080 void DisplayManager::CreateScreenForShutdown() const { | 1077 void DisplayManager::CreateScreenForShutdown() const { |
| 1081 bool native_is_ash = | |
| 1082 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE) == screen_.get(); | |
| 1083 delete screen_for_shutdown; | 1078 delete screen_for_shutdown; |
| 1084 screen_for_shutdown = screen_->CloneForShutdown(); | 1079 screen_for_shutdown = screen_->CloneForShutdown(); |
| 1085 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, | 1080 gfx::Screen::SetScreenInstance(screen_for_shutdown); |
| 1086 screen_for_shutdown); | |
| 1087 if (native_is_ash) { | |
| 1088 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | |
| 1089 screen_for_shutdown); | |
| 1090 } | |
| 1091 } | 1081 } |
| 1092 | 1082 |
| 1093 void DisplayManager::UpdateInternalDisplayModeListForTest() { | 1083 void DisplayManager::UpdateInternalDisplayModeListForTest() { |
| 1094 if (!gfx::Display::HasInternalDisplay() || | 1084 if (!gfx::Display::HasInternalDisplay() || |
| 1095 display_info_.count(gfx::Display::InternalDisplayId()) == 0) | 1085 display_info_.count(gfx::Display::InternalDisplayId()) == 0) |
| 1096 return; | 1086 return; |
| 1097 DisplayInfo* info = &display_info_[gfx::Display::InternalDisplayId()]; | 1087 DisplayInfo* info = &display_info_[gfx::Display::InternalDisplayId()]; |
| 1098 SetInternalDisplayModeList(info); | 1088 SetInternalDisplayModeList(info); |
| 1099 } | 1089 } |
| 1100 | 1090 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1410 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1400 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 1411 secondary_display->UpdateWorkAreaFromInsets(insets); | 1401 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 1412 } | 1402 } |
| 1413 | 1403 |
| 1414 void DisplayManager::RunPendingTasksForTest() { | 1404 void DisplayManager::RunPendingTasksForTest() { |
| 1415 if (!software_mirroring_display_list_.empty()) | 1405 if (!software_mirroring_display_list_.empty()) |
| 1416 base::RunLoop().RunUntilIdle(); | 1406 base::RunLoop().RunUntilIdle(); |
| 1417 } | 1407 } |
| 1418 | 1408 |
| 1419 } // namespace ash | 1409 } // namespace ash |
| OLD | NEW |