| 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" | 8 #include "ash/display/display_animator_chromeos.h" |
| 9 #include "ash/display/display_util.h" | 9 #include "ash/display/display_util.h" |
| 10 #include "ash/display/window_tree_host_manager.h" |
| 10 #include "ash/rotator/screen_rotation_animator.h" | 11 #include "ash/rotator/screen_rotation_animator.h" |
| 12 #include "ash/shell.h" |
| 11 #include "ash/strings/grit/ash_strings.h" | 13 #include "ash/strings/grit/ash_strings.h" |
| 12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 13 #include "chromeos/system/devicemode.h" | 15 #include "chromeos/system/devicemode.h" |
| 16 #include "ui/base/class_property.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/display/display_layout.h" | 18 #include "ui/display/display_layout.h" |
| 16 #include "ui/display/manager/display_manager.h" | 19 #include "ui/display/manager/display_manager.h" |
| 17 | 20 |
| 21 DECLARE_UI_CLASS_PROPERTY_TYPE(ash::ScreenRotationAnimator*); |
| 22 |
| 18 namespace { | 23 namespace { |
| 19 | 24 |
| 20 // Specifies how long the display change should have been disabled | 25 // Specifies how long the display change should have been disabled |
| 21 // after each display change operations. | 26 // after each display change operations. |
| 22 // |kCycleDisplayThrottleTimeoutMs| is set to be longer to avoid | 27 // |kCycleDisplayThrottleTimeoutMs| is set to be longer to avoid |
| 23 // changing the settings while the system is still configurating | 28 // changing the settings while the system is still configurating |
| 24 // displays. It will be overriden by |kAfterDisplayChangeThrottleTimeoutMs| | 29 // displays. It will be overriden by |kAfterDisplayChangeThrottleTimeoutMs| |
| 25 // when the display change happens, so the actual timeout is much shorter. | 30 // when the display change happens, so the actual timeout is much shorter. |
| 26 const int64_t kAfterDisplayChangeThrottleTimeoutMs = 500; | 31 const int64_t kAfterDisplayChangeThrottleTimeoutMs = 500; |
| 27 const int64_t kCycleDisplayThrottleTimeoutMs = 4000; | 32 const int64_t kCycleDisplayThrottleTimeoutMs = 4000; |
| 28 const int64_t kSetPrimaryDisplayThrottleTimeoutMs = 500; | 33 const int64_t kSetPrimaryDisplayThrottleTimeoutMs = 500; |
| 29 | 34 |
| 35 // A property key to store the ScreenRotationAnimator of the window; Used for |
| 36 // screen rotation. |
| 37 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(ash::ScreenRotationAnimator, |
| 38 kScreenRotationAnimatorKey, |
| 39 nullptr); |
| 40 |
| 41 aura::Window* GetRootWindow(int64_t display_id) { |
| 42 return ash::Shell::Get() |
| 43 ->window_tree_host_manager() |
| 44 ->GetRootWindowForDisplayId(display_id); |
| 45 } |
| 46 |
| 30 } // namespace | 47 } // namespace |
| 31 | 48 |
| 32 namespace ash { | 49 namespace ash { |
| 33 | 50 |
| 34 class DisplayConfigurationController::DisplayChangeLimiter { | 51 class DisplayConfigurationController::DisplayChangeLimiter { |
| 35 public: | 52 public: |
| 36 DisplayChangeLimiter() : throttle_timeout_(base::Time::Now()) {} | 53 DisplayChangeLimiter() : throttle_timeout_(base::Time::Now()) {} |
| 37 | 54 |
| 38 void SetThrottleTimeout(int64_t throttle_ms) { | 55 void SetThrottleTimeout(int64_t throttle_ms) { |
| 39 throttle_timeout_ = | 56 throttle_timeout_ = |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void DisplayConfigurationController::SetPrimaryDisplayIdImpl( | 184 void DisplayConfigurationController::SetPrimaryDisplayIdImpl( |
| 168 int64_t display_id) { | 185 int64_t display_id) { |
| 169 window_tree_host_manager_->SetPrimaryDisplayId(display_id); | 186 window_tree_host_manager_->SetPrimaryDisplayId(display_id); |
| 170 if (display_animator_) | 187 if (display_animator_) |
| 171 display_animator_->StartFadeInAnimation(); | 188 display_animator_->StartFadeInAnimation(); |
| 172 } | 189 } |
| 173 | 190 |
| 174 ScreenRotationAnimator* | 191 ScreenRotationAnimator* |
| 175 DisplayConfigurationController::GetScreenRotationAnimatorForDisplay( | 192 DisplayConfigurationController::GetScreenRotationAnimatorForDisplay( |
| 176 int64_t display_id) { | 193 int64_t display_id) { |
| 177 auto iter = rotation_animator_map_.find(display_id); | 194 aura::Window* root_window = GetRootWindow(display_id); |
| 178 if (iter != rotation_animator_map_.end()) | 195 ScreenRotationAnimator* animator = |
| 179 return iter->second.get(); | 196 root_window->GetProperty(kScreenRotationAnimatorKey); |
| 180 | 197 if (!animator) { |
| 181 auto animator = base::MakeUnique<ScreenRotationAnimator>(display_id); | 198 animator = new ScreenRotationAnimator(root_window); |
| 182 ScreenRotationAnimator* result = animator.get(); | 199 root_window->SetProperty(kScreenRotationAnimatorKey, animator); |
| 183 rotation_animator_map_.insert( | 200 } |
| 184 std::make_pair(display_id, std::move(animator))); | 201 return animator; |
| 185 return result; | |
| 186 } | 202 } |
| 187 | 203 |
| 188 } // namespace ash | 204 } // namespace ash |
| OLD | NEW |