| 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 25 matching lines...) Expand all Loading... |
| 36 #include "ui/gfx/font_render_params.h" | 36 #include "ui/gfx/font_render_params.h" |
| 37 #include "ui/gfx/geometry/rect.h" | 37 #include "ui/gfx/geometry/rect.h" |
| 38 #include "ui/gfx/geometry/size_conversions.h" | 38 #include "ui/gfx/geometry/size_conversions.h" |
| 39 #include "ui/gfx/screen.h" | 39 #include "ui/gfx/screen.h" |
| 40 | 40 |
| 41 #if defined(USE_X11) | 41 #if defined(USE_X11) |
| 42 #include "ui/base/x/x11_util.h" | 42 #include "ui/base/x/x11_util.h" |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 46 #include "ash/display/display_animator.h" | |
| 47 #include "base/sys_info.h" | 46 #include "base/sys_info.h" |
| 48 #endif | 47 #endif |
| 49 | 48 |
| 50 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 51 #include "base/win/windows_version.h" | 50 #include "base/win/windows_version.h" |
| 52 #endif | 51 #endif |
| 53 | 52 |
| 54 namespace ash { | 53 namespace ash { |
| 55 typedef std::vector<gfx::Display> DisplayList; | 54 typedef std::vector<gfx::Display> DisplayList; |
| 56 typedef std::vector<DisplayInfo> DisplayInfoList; | 55 typedef std::vector<DisplayInfo> DisplayInfoList; |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 return base::StringPrintf("Display %d", static_cast<int>(id)); | 926 return base::StringPrintf("Display %d", static_cast<int>(id)); |
| 928 } | 927 } |
| 929 | 928 |
| 930 int64_t DisplayManager::GetDisplayIdForUIScaling() const { | 929 int64_t DisplayManager::GetDisplayIdForUIScaling() const { |
| 931 // UI Scaling is effective on internal display. | 930 // UI Scaling is effective on internal display. |
| 932 return gfx::Display::HasInternalDisplay() ? gfx::Display::InternalDisplayId() | 931 return gfx::Display::HasInternalDisplay() ? gfx::Display::InternalDisplayId() |
| 933 : gfx::Display::kInvalidDisplayID; | 932 : gfx::Display::kInvalidDisplayID; |
| 934 } | 933 } |
| 935 | 934 |
| 936 void DisplayManager::SetMirrorMode(bool mirror) { | 935 void DisplayManager::SetMirrorMode(bool mirror) { |
| 937 #if defined(OS_CHROMEOS) | |
| 938 if (num_connected_displays() <= 1) | 936 if (num_connected_displays() <= 1) |
| 939 return; | 937 return; |
| 940 | 938 |
| 939 #if defined(OS_CHROMEOS) |
| 941 if (base::SysInfo::IsRunningOnChromeOS()) { | 940 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 942 ui::MultipleDisplayState new_state = | 941 ui::MultipleDisplayState new_state = |
| 943 mirror ? ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR | 942 mirror ? ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR |
| 944 : ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; | 943 : ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; |
| 945 Shell::GetInstance()->display_configurator()->SetDisplayMode(new_state); | 944 Shell::GetInstance()->display_configurator()->SetDisplayMode(new_state); |
| 946 return; | 945 return; |
| 947 } | 946 } |
| 947 #endif |
| 948 multi_display_mode_ = | 948 multi_display_mode_ = |
| 949 mirror ? MIRRORING : current_default_multi_display_mode_; | 949 mirror ? MIRRORING : current_default_multi_display_mode_; |
| 950 ReconfigureDisplays(); | 950 ReconfigureDisplays(); |
| 951 if (Shell::GetInstance()->display_animator()) { | |
| 952 Shell::GetInstance()->display_animator()->StartFadeInAnimation(); | |
| 953 } | |
| 954 RunPendingTasksForTest(); | |
| 955 #endif | |
| 956 } | 951 } |
| 957 | 952 |
| 958 void DisplayManager::AddRemoveDisplay() { | 953 void DisplayManager::AddRemoveDisplay() { |
| 959 DCHECK(!active_display_list_.empty()); | 954 DCHECK(!active_display_list_.empty()); |
| 960 std::vector<DisplayInfo> new_display_info_list; | 955 std::vector<DisplayInfo> new_display_info_list; |
| 961 const DisplayInfo& first_display = | 956 const DisplayInfo& first_display = |
| 962 IsInUnifiedMode() | 957 IsInUnifiedMode() |
| 963 ? GetDisplayInfo(software_mirroring_display_list_[0].id()) | 958 ? GetDisplayInfo(software_mirroring_display_list_[0].id()) |
| 964 : GetDisplayInfo(active_display_list_[0].id()); | 959 : GetDisplayInfo(active_display_list_[0].id()); |
| 965 new_display_info_list.push_back(first_display); | 960 new_display_info_list.push_back(first_display); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 return software_mirroring_enabled(); | 998 return software_mirroring_enabled(); |
| 1004 } | 999 } |
| 1005 #endif | 1000 #endif |
| 1006 | 1001 |
| 1007 void DisplayManager::SetDefaultMultiDisplayModeForCurrentDisplays( | 1002 void DisplayManager::SetDefaultMultiDisplayModeForCurrentDisplays( |
| 1008 MultiDisplayMode mode) { | 1003 MultiDisplayMode mode) { |
| 1009 DCHECK_NE(MIRRORING, mode); | 1004 DCHECK_NE(MIRRORING, mode); |
| 1010 DisplayIdPair pair = GetCurrentDisplayIdPair(); | 1005 DisplayIdPair pair = GetCurrentDisplayIdPair(); |
| 1011 layout_store_->UpdateMultiDisplayState(pair, IsInMirrorMode(), | 1006 layout_store_->UpdateMultiDisplayState(pair, IsInMirrorMode(), |
| 1012 mode == UNIFIED); | 1007 mode == UNIFIED); |
| 1008 ReconfigureDisplays(); |
| 1013 } | 1009 } |
| 1014 | 1010 |
| 1015 void DisplayManager::SetMultiDisplayMode(MultiDisplayMode mode) { | 1011 void DisplayManager::SetMultiDisplayMode(MultiDisplayMode mode) { |
| 1016 multi_display_mode_ = mode; | 1012 multi_display_mode_ = mode; |
| 1017 mirroring_display_id_ = gfx::Display::kInvalidDisplayID; | 1013 mirroring_display_id_ = gfx::Display::kInvalidDisplayID; |
| 1018 software_mirroring_display_list_.clear(); | 1014 software_mirroring_display_list_.clear(); |
| 1019 } | 1015 } |
| 1020 | 1016 |
| 1021 void DisplayManager::ReconfigureDisplays() { | 1017 void DisplayManager::ReconfigureDisplays() { |
| 1022 DisplayInfoList display_info_list; | 1018 DisplayInfoList display_info_list; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1406 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 1411 secondary_display->UpdateWorkAreaFromInsets(insets); | 1407 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 1412 } | 1408 } |
| 1413 | 1409 |
| 1414 void DisplayManager::RunPendingTasksForTest() { | 1410 void DisplayManager::RunPendingTasksForTest() { |
| 1415 if (!software_mirroring_display_list_.empty()) | 1411 if (!software_mirroring_display_list_.empty()) |
| 1416 base::RunLoop().RunUntilIdle(); | 1412 base::RunLoop().RunUntilIdle(); |
| 1417 } | 1413 } |
| 1418 | 1414 |
| 1419 } // namespace ash | 1415 } // namespace ash |
| OLD | NEW |