| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 mirroring_display_id_(gfx::Display::kInvalidDisplayID), | 134 mirroring_display_id_(gfx::Display::kInvalidDisplayID), |
| 135 registered_internal_display_rotation_lock_(false), | 135 registered_internal_display_rotation_lock_(false), |
| 136 registered_internal_display_rotation_(gfx::Display::ROTATE_0), | 136 registered_internal_display_rotation_(gfx::Display::ROTATE_0), |
| 137 weak_ptr_factory_(this) { | 137 weak_ptr_factory_(this) { |
| 138 #if defined(OS_CHROMEOS) | 138 #if defined(OS_CHROMEOS) |
| 139 // Enable only on the device so that DisplayManagerFontTest passes. | 139 // Enable only on the device so that DisplayManagerFontTest passes. |
| 140 if (base::SysInfo::IsRunningOnChromeOS()) | 140 if (base::SysInfo::IsRunningOnChromeOS()) |
| 141 DisplayInfo::SetUse125DSFForUIScaling(true); | 141 DisplayInfo::SetUse125DSFForUIScaling(true); |
| 142 | 142 |
| 143 if (switches::UnifiedDesktopEnabled()) | 143 if (switches::UnifiedDesktopEnabled()) |
| 144 multi_display_mode_ = default_multi_display_mode_ = UNIFIED; | 144 default_multi_display_mode_ = UNIFIED; |
| 145 | 145 |
| 146 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); | 146 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); |
| 147 #endif | 147 #endif |
| 148 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_.get()); | 148 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_.get()); |
| 149 gfx::Screen* current_native = | 149 gfx::Screen* current_native = |
| 150 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); | 150 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); |
| 151 // If there is no native, or the native was for shutdown, | 151 // If there is no native, or the native was for shutdown, |
| 152 // use ash's screen. | 152 // use ash's screen. |
| 153 if (!current_native || | 153 if (!current_native || |
| 154 current_native == screen_for_shutdown) { | 154 current_native == screen_for_shutdown) { |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 "skip (don't disable) the test using SupportsMultipleDisplays()"; | 667 "skip (don't disable) the test using SupportsMultipleDisplays()"; |
| 668 #endif | 668 #endif |
| 669 | 669 |
| 670 DisplayInfoList new_display_info_list = updated_display_info_list; | 670 DisplayInfoList new_display_info_list = updated_display_info_list; |
| 671 std::sort(active_display_list_.begin(), active_display_list_.end(), | 671 std::sort(active_display_list_.begin(), active_display_list_.end(), |
| 672 DisplaySortFunctor()); | 672 DisplaySortFunctor()); |
| 673 std::sort(new_display_info_list.begin(), | 673 std::sort(new_display_info_list.begin(), |
| 674 new_display_info_list.end(), | 674 new_display_info_list.end(), |
| 675 DisplayInfoSortFunctor()); | 675 DisplayInfoSortFunctor()); |
| 676 | 676 |
| 677 if (multi_display_mode_ != MIRRORING) |
| 678 multi_display_mode_ = default_multi_display_mode_; |
| 679 |
| 677 CreateSoftwareMirroringDisplayInfo(&new_display_info_list); | 680 CreateSoftwareMirroringDisplayInfo(&new_display_info_list); |
| 678 | 681 |
| 679 // Close the mirroring window if any here to avoid creating two compositor on | 682 // Close the mirroring window if any here to avoid creating two compositor on |
| 680 // one display. | 683 // one display. |
| 681 if (delegate_) | 684 if (delegate_) |
| 682 delegate_->CloseMirroringDisplayIfNotNecessary(); | 685 delegate_->CloseMirroringDisplayIfNotNecessary(); |
| 683 | 686 |
| 684 DisplayList new_displays; | 687 DisplayList new_displays; |
| 685 DisplayList removed_displays; | 688 DisplayList removed_displays; |
| 686 std::map<size_t, uint32_t> display_changes; | 689 std::map<size_t, uint32_t> display_changes; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 if (iter->id() == kUnifiedDisplayId) | 947 if (iter->id() == kUnifiedDisplayId) |
| 945 continue; | 948 continue; |
| 946 display_info_list.push_back(GetDisplayInfo(iter->id())); | 949 display_info_list.push_back(GetDisplayInfo(iter->id())); |
| 947 } | 950 } |
| 948 for (auto iter = software_mirroring_display_list_.begin(); | 951 for (auto iter = software_mirroring_display_list_.begin(); |
| 949 (display_info_list.size() < 2 && | 952 (display_info_list.size() < 2 && |
| 950 iter != software_mirroring_display_list_.end()); | 953 iter != software_mirroring_display_list_.end()); |
| 951 ++iter) { | 954 ++iter) { |
| 952 display_info_list.push_back(GetDisplayInfo(iter->id())); | 955 display_info_list.push_back(GetDisplayInfo(iter->id())); |
| 953 } | 956 } |
| 954 | 957 multi_display_mode_ = mirror ? MIRRORING : default_multi_display_mode_; |
| 955 SetSoftwareMirroring(mirror); | 958 ReconfigureDisplays(); |
| 956 UpdateDisplays(display_info_list); | |
| 957 if (Shell::GetInstance()->display_configurator_animation()) { | 959 if (Shell::GetInstance()->display_configurator_animation()) { |
| 958 Shell::GetInstance()->display_configurator_animation()-> | 960 Shell::GetInstance()->display_configurator_animation()-> |
| 959 StartFadeInAnimation(); | 961 StartFadeInAnimation(); |
| 960 } | 962 } |
| 961 RunPendingTasksForTest(); | 963 RunPendingTasksForTest(); |
| 962 #endif | 964 #endif |
| 963 } | 965 } |
| 964 | 966 |
| 965 void DisplayManager::AddRemoveDisplay() { | 967 void DisplayManager::AddRemoveDisplay() { |
| 966 DCHECK(!active_display_list_.empty()); | 968 DCHECK(!active_display_list_.empty()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 } | 1012 } |
| 1011 #endif | 1013 #endif |
| 1012 | 1014 |
| 1013 void DisplayManager::SetMultiDisplayMode(MultiDisplayMode mode) { | 1015 void DisplayManager::SetMultiDisplayMode(MultiDisplayMode mode) { |
| 1014 multi_display_mode_ = mode; | 1016 multi_display_mode_ = mode; |
| 1015 mirroring_display_id_ = gfx::Display::kInvalidDisplayID; | 1017 mirroring_display_id_ = gfx::Display::kInvalidDisplayID; |
| 1016 software_mirroring_display_list_.clear(); | 1018 software_mirroring_display_list_.clear(); |
| 1017 } | 1019 } |
| 1018 | 1020 |
| 1019 void DisplayManager::SetDefaultMultiDisplayMode(MultiDisplayMode mode) { | 1021 void DisplayManager::SetDefaultMultiDisplayMode(MultiDisplayMode mode) { |
| 1020 // TODO(oshima): Remove this constrain. | 1022 DCHECK_NE(mode, MIRRORING); |
| 1021 DCHECK_EQ(default_multi_display_mode_, EXTENDED); | |
| 1022 DCHECK_EQ(mode, UNIFIED); | |
| 1023 default_multi_display_mode_ = mode; | 1023 default_multi_display_mode_ = mode; |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 void DisplayManager::ReconfigureDisplays() { |
| 1027 DisplayInfoList display_info_list; |
| 1028 for (DisplayList::const_iterator iter = active_display_list_.begin(); |
| 1029 (display_info_list.size() < 2 && iter != active_display_list_.end()); |
| 1030 ++iter) { |
| 1031 if (iter->id() == kUnifiedDisplayId) |
| 1032 continue; |
| 1033 display_info_list.push_back(GetDisplayInfo(iter->id())); |
| 1034 } |
| 1035 for (auto iter = software_mirroring_display_list_.begin(); |
| 1036 (display_info_list.size() < 2 && |
| 1037 iter != software_mirroring_display_list_.end()); |
| 1038 ++iter) { |
| 1039 display_info_list.push_back(GetDisplayInfo(iter->id())); |
| 1040 } |
| 1041 mirroring_display_id_ = gfx::Display::kInvalidDisplayID; |
| 1042 software_mirroring_display_list_.clear(); |
| 1043 UpdateDisplays(display_info_list); |
| 1044 } |
| 1045 |
| 1026 bool DisplayManager::UpdateDisplayBounds(int64 display_id, | 1046 bool DisplayManager::UpdateDisplayBounds(int64 display_id, |
| 1027 const gfx::Rect& new_bounds) { | 1047 const gfx::Rect& new_bounds) { |
| 1028 if (change_display_upon_host_resize_) { | 1048 if (change_display_upon_host_resize_) { |
| 1029 display_info_[display_id].SetBounds(new_bounds); | 1049 display_info_[display_id].SetBounds(new_bounds); |
| 1030 // Don't notify observers if the mirrored window has changed. | 1050 // Don't notify observers if the mirrored window has changed. |
| 1031 if (software_mirroring_enabled() && mirroring_display_id_ == display_id) | 1051 if (software_mirroring_enabled() && mirroring_display_id_ == display_id) |
| 1032 return false; | 1052 return false; |
| 1033 gfx::Display* display = FindDisplayForId(display_id); | 1053 gfx::Display* display = FindDisplayForId(display_id); |
| 1034 display->SetSize(display_info_[display_id].size_in_pixel()); | 1054 display->SetSize(display_info_[display_id].size_in_pixel()); |
| 1035 screen_->NotifyMetricsChanged(*display, | 1055 screen_->NotifyMetricsChanged(*display, |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1333 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 1314 secondary_display->UpdateWorkAreaFromInsets(insets); | 1334 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 1315 } | 1335 } |
| 1316 | 1336 |
| 1317 void DisplayManager::RunPendingTasksForTest() { | 1337 void DisplayManager::RunPendingTasksForTest() { |
| 1318 if (!software_mirroring_display_list_.empty()) | 1338 if (!software_mirroring_display_list_.empty()) |
| 1319 base::RunLoop().RunUntilIdle(); | 1339 base::RunLoop().RunUntilIdle(); |
| 1320 } | 1340 } |
| 1321 | 1341 |
| 1322 } // namespace ash | 1342 } // namespace ash |
| OLD | NEW |