| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 mirroring_display_id_(gfx::Display::kInvalidDisplayID), | 138 mirroring_display_id_(gfx::Display::kInvalidDisplayID), |
| 139 registered_internal_display_rotation_lock_(false), | 139 registered_internal_display_rotation_lock_(false), |
| 140 registered_internal_display_rotation_(gfx::Display::ROTATE_0), | 140 registered_internal_display_rotation_(gfx::Display::ROTATE_0), |
| 141 unified_desktop_enabled_(false), | 141 unified_desktop_enabled_(false), |
| 142 weak_ptr_factory_(this) { | 142 weak_ptr_factory_(this) { |
| 143 #if defined(OS_CHROMEOS) | 143 #if defined(OS_CHROMEOS) |
| 144 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); | 144 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); |
| 145 unified_desktop_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 145 unified_desktop_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 146 switches::kAshEnableUnifiedDesktop); | 146 switches::kAshEnableUnifiedDesktop); |
| 147 #endif | 147 #endif |
| 148 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_.get()); | 148 gfx::Screen* current = gfx::Screen::GetScreen(); |
| 149 gfx::Screen* current_native = | |
| 150 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); | |
| 151 // If there is no native, or the native was for shutdown, | 149 // If there is no native, or the native was for shutdown, |
| 152 // use ash's screen. | 150 // use ash's screen. |
| 153 if (!current_native || | 151 if (!current || current == screen_for_shutdown) |
| 154 current_native == screen_for_shutdown) { | 152 gfx::Screen::SetScreenInstance(screen_.get()); |
| 155 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | |
| 156 } | |
| 157 } | 153 } |
| 158 | 154 |
| 159 DisplayManager::~DisplayManager() { | 155 DisplayManager::~DisplayManager() { |
| 160 #if defined(OS_CHROMEOS) | 156 #if defined(OS_CHROMEOS) |
| 161 // Reset the font params. | 157 // Reset the font params. |
| 162 gfx::SetFontRenderParamsDeviceScaleFactor(1.0f); | 158 gfx::SetFontRenderParamsDeviceScaleFactor(1.0f); |
| 163 #endif | 159 #endif |
| 164 } | 160 } |
| 165 | 161 |
| 166 bool DisplayManager::InitFromCommandLine() { | 162 bool DisplayManager::InitFromCommandLine() { |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 if (IsInUnifiedMode() && num_connected_displays() >= 2) | 1057 if (IsInUnifiedMode() && num_connected_displays() >= 2) |
| 1062 return make_scoped_ptr(new UnifiedMouseWarpController()); | 1058 return make_scoped_ptr(new UnifiedMouseWarpController()); |
| 1063 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest | 1059 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest |
| 1064 // that injects MockScreen. | 1060 // that injects MockScreen. |
| 1065 if (GetNumDisplays() < 2 || num_connected_displays() < 2) | 1061 if (GetNumDisplays() < 2 || num_connected_displays() < 2) |
| 1066 return make_scoped_ptr(new NullMouseWarpController()); | 1062 return make_scoped_ptr(new NullMouseWarpController()); |
| 1067 return make_scoped_ptr(new ExtendedMouseWarpController(drag_source)); | 1063 return make_scoped_ptr(new ExtendedMouseWarpController(drag_source)); |
| 1068 } | 1064 } |
| 1069 | 1065 |
| 1070 void DisplayManager::CreateScreenForShutdown() const { | 1066 void DisplayManager::CreateScreenForShutdown() const { |
| 1071 bool native_is_ash = | |
| 1072 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE) == screen_.get(); | |
| 1073 delete screen_for_shutdown; | 1067 delete screen_for_shutdown; |
| 1074 screen_for_shutdown = screen_->CloneForShutdown(); | 1068 screen_for_shutdown = screen_->CloneForShutdown(); |
| 1075 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, | 1069 gfx::Screen::SetScreenInstance(screen_for_shutdown); |
| 1076 screen_for_shutdown); | |
| 1077 if (native_is_ash) { | |
| 1078 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | |
| 1079 screen_for_shutdown); | |
| 1080 } | |
| 1081 } | 1070 } |
| 1082 | 1071 |
| 1083 void DisplayManager::UpdateInternalDisplayModeListForTest() { | 1072 void DisplayManager::UpdateInternalDisplayModeListForTest() { |
| 1084 if (!gfx::Display::HasInternalDisplay() || | 1073 if (!gfx::Display::HasInternalDisplay() || |
| 1085 display_info_.count(gfx::Display::InternalDisplayId()) == 0) | 1074 display_info_.count(gfx::Display::InternalDisplayId()) == 0) |
| 1086 return; | 1075 return; |
| 1087 DisplayInfo* info = &display_info_[gfx::Display::InternalDisplayId()]; | 1076 DisplayInfo* info = &display_info_[gfx::Display::InternalDisplayId()]; |
| 1088 SetInternalDisplayModeList(info); | 1077 SetInternalDisplayModeList(info); |
| 1089 } | 1078 } |
| 1090 | 1079 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1389 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 1401 secondary_display->UpdateWorkAreaFromInsets(insets); | 1390 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 1402 } | 1391 } |
| 1403 | 1392 |
| 1404 void DisplayManager::RunPendingTasksForTest() { | 1393 void DisplayManager::RunPendingTasksForTest() { |
| 1405 if (!software_mirroring_display_list_.empty()) | 1394 if (!software_mirroring_display_list_.empty()) |
| 1406 base::RunLoop().RunUntilIdle(); | 1395 base::RunLoop().RunUntilIdle(); |
| 1407 } | 1396 } |
| 1408 | 1397 |
| 1409 } // namespace ash | 1398 } // namespace ash |
| OLD | NEW |