| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_configuration_controller.h" | 5 #include "ash/display/display_configuration_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_animator.h" | 7 #include "ash/display/display_animator.h" |
| 8 #include "ash/display/display_animator_chromeos.h" | |
| 9 #include "ash/display/display_util.h" | 8 #include "ash/display/display_util.h" |
| 10 #include "ash/rotator/screen_rotation_animator.h" | 9 #include "ash/rotator/screen_rotation_animator.h" |
| 11 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "ui/display/display_layout.h" |
| 12 #include "ui/display/manager/display_manager.h" |
| 13 |
| 14 #if defined(OS_CHROMEOS) |
| 15 #include "ash/display/display_animator_chromeos.h" |
| 12 #include "chromeos/system/devicemode.h" | 16 #include "chromeos/system/devicemode.h" |
| 13 #include "grit/ash_strings.h" | 17 #include "grit/ash_strings.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/display/display_layout.h" | 19 #endif |
| 16 #include "ui/display/manager/display_manager.h" | |
| 17 | 20 |
| 18 namespace { | 21 namespace { |
| 19 | 22 |
| 20 // Specifies how long the display change should have been disabled | 23 // Specifies how long the display change should have been disabled |
| 21 // after each display change operations. | 24 // after each display change operations. |
| 22 // |kCycleDisplayThrottleTimeoutMs| is set to be longer to avoid | 25 // |kCycleDisplayThrottleTimeoutMs| is set to be longer to avoid |
| 23 // changing the settings while the system is still configurating | 26 // changing the settings while the system is still configurating |
| 24 // displays. It will be overriden by |kAfterDisplayChangeThrottleTimeoutMs| | 27 // displays. It will be overriden by |kAfterDisplayChangeThrottleTimeoutMs| |
| 25 // when the display change happens, so the actual timeout is much shorter. | 28 // when the display change happens, so the actual timeout is much shorter. |
| 26 const int64_t kAfterDisplayChangeThrottleTimeoutMs = 500; | 29 const int64_t kAfterDisplayChangeThrottleTimeoutMs = 500; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 DISALLOW_COPY_AND_ASSIGN(DisplayChangeLimiter); | 51 DISALLOW_COPY_AND_ASSIGN(DisplayChangeLimiter); |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 DisplayConfigurationController::DisplayConfigurationController( | 54 DisplayConfigurationController::DisplayConfigurationController( |
| 52 display::DisplayManager* display_manager, | 55 display::DisplayManager* display_manager, |
| 53 WindowTreeHostManager* window_tree_host_manager) | 56 WindowTreeHostManager* window_tree_host_manager) |
| 54 : display_manager_(display_manager), | 57 : display_manager_(display_manager), |
| 55 window_tree_host_manager_(window_tree_host_manager), | 58 window_tree_host_manager_(window_tree_host_manager), |
| 56 weak_ptr_factory_(this) { | 59 weak_ptr_factory_(this) { |
| 57 window_tree_host_manager_->AddObserver(this); | 60 window_tree_host_manager_->AddObserver(this); |
| 61 #if defined(OS_CHROMEOS) |
| 58 if (chromeos::IsRunningAsSystemCompositor()) | 62 if (chromeos::IsRunningAsSystemCompositor()) |
| 59 limiter_.reset(new DisplayChangeLimiter); | 63 limiter_.reset(new DisplayChangeLimiter); |
| 60 display_animator_.reset(new DisplayAnimatorChromeOS()); | 64 display_animator_.reset(new DisplayAnimatorChromeOS()); |
| 65 #endif |
| 61 } | 66 } |
| 62 | 67 |
| 63 DisplayConfigurationController::~DisplayConfigurationController() { | 68 DisplayConfigurationController::~DisplayConfigurationController() { |
| 64 window_tree_host_manager_->RemoveObserver(this); | 69 window_tree_host_manager_->RemoveObserver(this); |
| 65 } | 70 } |
| 66 | 71 |
| 67 void DisplayConfigurationController::SetDisplayLayout( | 72 void DisplayConfigurationController::SetDisplayLayout( |
| 68 std::unique_ptr<display::DisplayLayout> layout, | 73 std::unique_ptr<display::DisplayLayout> layout, |
| 69 bool user_action) { | 74 bool user_action) { |
| 70 if (user_action && display_animator_) { | 75 if (user_action && display_animator_) { |
| 71 display_animator_->StartFadeOutAnimation( | 76 display_animator_->StartFadeOutAnimation( |
| 72 base::Bind(&DisplayConfigurationController::SetDisplayLayoutImpl, | 77 base::Bind(&DisplayConfigurationController::SetDisplayLayoutImpl, |
| 73 weak_ptr_factory_.GetWeakPtr(), base::Passed(&layout))); | 78 weak_ptr_factory_.GetWeakPtr(), base::Passed(&layout))); |
| 74 } else { | 79 } else { |
| 75 SetDisplayLayoutImpl(std::move(layout)); | 80 SetDisplayLayoutImpl(std::move(layout)); |
| 76 } | 81 } |
| 77 } | 82 } |
| 78 | 83 |
| 79 void DisplayConfigurationController::SetMirrorMode(bool mirror, | 84 void DisplayConfigurationController::SetMirrorMode(bool mirror, |
| 80 bool user_action) { | 85 bool user_action) { |
| 81 if (display_manager_->num_connected_displays() > 2) { | 86 if (display_manager_->num_connected_displays() > 2) { |
| 87 #if defined(OS_CHROMEOS) |
| 82 if (user_action) { | 88 if (user_action) { |
| 83 ShowDisplayErrorNotification( | 89 ShowDisplayErrorNotification( |
| 84 l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED), | 90 l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED), |
| 85 false); | 91 false); |
| 86 } | 92 } |
| 93 #endif |
| 87 return; | 94 return; |
| 88 } | 95 } |
| 89 if (display_manager_->num_connected_displays() <= 1 || | 96 if (display_manager_->num_connected_displays() <= 1 || |
| 90 display_manager_->IsInMirrorMode() == mirror || IsLimited()) { | 97 display_manager_->IsInMirrorMode() == mirror || IsLimited()) { |
| 91 return; | 98 return; |
| 92 } | 99 } |
| 93 SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); | 100 SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); |
| 94 if (user_action && display_animator_) { | 101 if (user_action && display_animator_) { |
| 95 display_animator_->StartFadeOutAnimation( | 102 display_animator_->StartFadeOutAnimation( |
| 96 base::Bind(&DisplayConfigurationController::SetMirrorModeImpl, | 103 base::Bind(&DisplayConfigurationController::SetMirrorModeImpl, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 173 } |
| 167 | 174 |
| 168 void DisplayConfigurationController::SetPrimaryDisplayIdImpl( | 175 void DisplayConfigurationController::SetPrimaryDisplayIdImpl( |
| 169 int64_t display_id) { | 176 int64_t display_id) { |
| 170 window_tree_host_manager_->SetPrimaryDisplayId(display_id); | 177 window_tree_host_manager_->SetPrimaryDisplayId(display_id); |
| 171 if (display_animator_) | 178 if (display_animator_) |
| 172 display_animator_->StartFadeInAnimation(); | 179 display_animator_->StartFadeInAnimation(); |
| 173 } | 180 } |
| 174 | 181 |
| 175 } // namespace ash | 182 } // namespace ash |
| OLD | NEW |