Chromium Code Reviews| 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/wm/power_button_controller.h" | 5 #include "ash/wm/power_button_controller.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/root_window_event_filter.h" | 10 #include "ash/wm/root_window_event_filter.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 | 62 |
| 63 // Additional time (beyond kFastCloseAnimMs) to wait after starting the | 63 // Additional time (beyond kFastCloseAnimMs) to wait after starting the |
| 64 // fast-close shutdown animation before actually requesting shutdown, to give | 64 // fast-close shutdown animation before actually requesting shutdown, to give |
| 65 // the animation time to finish. | 65 // the animation time to finish. |
| 66 const int kShutdownRequestDelayMs = 50; | 66 const int kShutdownRequestDelayMs = 50; |
| 67 | 67 |
| 68 // Slightly-smaller size that we scale the screen down to for the pre-lock and | 68 // Slightly-smaller size that we scale the screen down to for the pre-lock and |
| 69 // pre-shutdown states. | 69 // pre-shutdown states. |
| 70 const float kSlowCloseSizeRatio = 0.95f; | 70 const float kSlowCloseSizeRatio = 0.95f; |
| 71 | 71 |
| 72 // Containers holding screen locker windows. | 72 // Returns the transform that should be applied to containers for the slow-close |
| 73 const int kScreenLockerContainerIds[] = { | 73 // animation. |
| 74 internal::kShellWindowId_LockScreenContainer, | 74 ui::Transform GetSlowCloseTransform() { |
| 75 internal::kShellWindowId_LockSystemModalContainer, | |
| 76 }; | |
| 77 | |
| 78 // Containers holding additional windows that should be shown while the screen | |
| 79 // is locked. | |
| 80 const int kRelatedContainerIds[] = { | |
| 81 internal::kShellWindowId_StatusContainer, | |
| 82 internal::kShellWindowId_MenuContainer, | |
| 83 internal::kShellWindowId_DragImageAndTooltipContainer, | |
| 84 internal::kShellWindowId_SettingBubbleContainer, | |
| 85 internal::kShellWindowId_OverlayContainer, | |
| 86 }; | |
| 87 | |
| 88 // Is |window| a container that holds screen locker windows? | |
| 89 bool IsScreenLockerContainer(aura::Window* window) { | |
| 90 for (size_t i = 0; i < arraysize(kScreenLockerContainerIds); ++i) | |
| 91 if (window->id() == kScreenLockerContainerIds[i]) | |
| 92 return true; | |
| 93 return false; | |
| 94 } | |
| 95 | |
| 96 // Is |window| a container that holds other windows that should be shown while | |
| 97 // the screen is locked? | |
| 98 bool IsRelatedContainer(aura::Window* window) { | |
| 99 for (size_t i = 0; i < arraysize(kRelatedContainerIds); ++i) | |
| 100 if (window->id() == kRelatedContainerIds[i]) | |
| 101 return true; | |
| 102 return false; | |
| 103 } | |
| 104 | |
| 105 // Returns the transform, based on |base_transform|, that should be applied | |
| 106 // to containers for slow-close animation. | |
| 107 ui::Transform GetSlowCloseTransform(const ui::Transform& base_transform) { | |
| 108 gfx::Size root_size = Shell::GetRootWindow()->bounds().size(); | 75 gfx::Size root_size = Shell::GetRootWindow()->bounds().size(); |
| 109 ui::Transform transform(base_transform); | 76 ui::Transform transform; |
| 110 transform.ConcatScale(kSlowCloseSizeRatio, kSlowCloseSizeRatio); | 77 transform.SetScale(kSlowCloseSizeRatio, kSlowCloseSizeRatio); |
| 111 transform.ConcatTranslate( | 78 transform.ConcatTranslate( |
| 112 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.width() + 0.5), | 79 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.width() + 0.5), |
| 113 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.height() + 0.5)); | 80 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.height() + 0.5)); |
| 114 return transform; | 81 return transform; |
| 115 } | 82 } |
| 116 | 83 |
| 117 // Returns the transform, based on |base_transform|, that should be applied | 84 // Returns the transform that should be applied to containers for the fast-close |
| 118 // to containers for fast-close animation. | 85 // animation. |
| 119 ui::Transform GetFastCloseTransform(const ui::Transform& base_transform) { | 86 ui::Transform GetFastCloseTransform() { |
| 120 gfx::Size root_size = Shell::GetRootWindow()->bounds().size(); | 87 gfx::Size root_size = Shell::GetRootWindow()->bounds().size(); |
| 121 ui::Transform transform(base_transform); | 88 ui::Transform transform; |
| 122 transform.ConcatScale(0.0, 0.0); | 89 transform.SetScale(0.0, 0.0); |
| 123 transform.ConcatTranslate(floor(0.5 * root_size.width() + 0.5), | 90 transform.ConcatTranslate(floor(0.5 * root_size.width() + 0.5), |
| 124 floor(0.5 * root_size.height() + 0.5)); | 91 floor(0.5 * root_size.height() + 0.5)); |
| 125 return transform; | 92 return transform; |
| 126 } | 93 } |
| 127 | 94 |
| 128 // Slowly shrinks |window| to a slightly-smaller size. | 95 // Slowly shrinks |window| to a slightly-smaller size. |
| 129 void StartSlowCloseAnimationForWindow(aura::Window* window) { | 96 void StartSlowCloseAnimationForWindow(aura::Window* window) { |
| 130 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 97 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 131 animator->set_preemption_strategy( | 98 animator->set_preemption_strategy( |
| 132 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 99 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 133 animator->StartAnimation( | 100 animator->StartAnimation( |
| 134 new ui::LayerAnimationSequence( | 101 new ui::LayerAnimationSequence( |
| 135 ui::LayerAnimationElement::CreateTransformElement( | 102 ui::LayerAnimationElement::CreateTransformElement( |
| 136 GetSlowCloseTransform(window->layer()->GetTargetTransform()), | 103 GetSlowCloseTransform(), |
| 137 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs)))); | 104 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs)))); |
| 138 } | 105 } |
| 139 | 106 |
| 140 // Quickly undoes the effects of the slow-close animation on |window|. | 107 // Quickly undoes the effects of the slow-close animation on |window|. |
| 141 void StartUndoSlowCloseAnimationForWindow(aura::Window* window, | 108 void StartUndoSlowCloseAnimationForWindow(aura::Window* window) { |
| 142 const ui::Transform& orig_transform) { | |
| 143 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 109 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 144 animator->set_preemption_strategy( | 110 animator->set_preemption_strategy( |
| 145 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 111 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 146 animator->StartAnimation( | 112 animator->StartAnimation( |
| 147 new ui::LayerAnimationSequence( | 113 new ui::LayerAnimationSequence( |
| 148 ui::LayerAnimationElement::CreateTransformElement( | 114 ui::LayerAnimationElement::CreateTransformElement( |
| 149 orig_transform, | 115 ui::Transform(), |
| 150 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs)))); | 116 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs)))); |
| 151 } | 117 } |
| 152 | 118 |
| 153 // Quickly shrinks |window| down to a point in the center of the screen and | 119 // Quickly shrinks |window| down to a point in the center of the screen and |
| 154 // fades it out to 0 opacity. | 120 // fades it out to 0 opacity. |
| 155 void StartFastCloseAnimationForWindow(aura::Window* window) { | 121 void StartFastCloseAnimationForWindow(aura::Window* window) { |
| 156 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 122 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 157 animator->set_preemption_strategy( | 123 animator->set_preemption_strategy( |
| 158 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 124 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 159 animator->StartAnimation( | 125 animator->StartAnimation( |
| 160 new ui::LayerAnimationSequence( | 126 new ui::LayerAnimationSequence( |
| 161 ui::LayerAnimationElement::CreateTransformElement( | 127 ui::LayerAnimationElement::CreateTransformElement( |
| 162 GetFastCloseTransform(window->layer()->GetTargetTransform()), | 128 GetFastCloseTransform(), |
| 163 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); | 129 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); |
| 164 animator->StartAnimation( | 130 animator->StartAnimation( |
| 165 new ui::LayerAnimationSequence( | 131 new ui::LayerAnimationSequence( |
| 166 ui::LayerAnimationElement::CreateOpacityElement( | 132 ui::LayerAnimationElement::CreateOpacityElement( |
| 167 0.0, base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); | 133 0.0, base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); |
| 168 } | 134 } |
| 169 | 135 |
| 170 // Fades |window| in to full opacity. | 136 // Fades |window| in to full opacity. |
| 171 void FadeInWindow(aura::Window* window) { | 137 void FadeInWindow(aura::Window* window) { |
| 172 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 138 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 173 animator->set_preemption_strategy( | 139 animator->set_preemption_strategy( |
| 174 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 140 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 175 animator->StartAnimation( | 141 animator->StartAnimation( |
| 176 new ui::LayerAnimationSequence( | 142 new ui::LayerAnimationSequence( |
| 177 ui::LayerAnimationElement::CreateOpacityElement( | 143 ui::LayerAnimationElement::CreateOpacityElement( |
| 178 1.0, base::TimeDelta::FromMilliseconds(kLockFadeInAnimMs)))); | 144 1.0, base::TimeDelta::FromMilliseconds(kLockFadeInAnimMs)))); |
| 179 } | 145 } |
| 180 | 146 |
| 181 // Makes |window| fully transparent instantaneously. | 147 // Makes |window| fully transparent instantaneously. |
| 182 void HideWindow(aura::Window* window) { | 148 void HideWindow(aura::Window* window) { |
| 183 window->layer()->SetOpacity(0.0); | 149 window->layer()->SetOpacity(0.0); |
| 184 } | 150 } |
| 185 | 151 |
| 186 // Restores |window| to its original position and scale and full opacity | 152 // Restores |window| to its original position and scale and full opacity |
| 187 // instantaneously. | 153 // instantaneously. |
| 188 void RestoreWindow(aura::Window* window, | 154 void RestoreWindow(aura::Window* window) { |
| 189 const ui::Transform& orig_transform) { | 155 window->layer()->SetTransform(ui::Transform()); |
| 190 window->layer()->SetTransform(orig_transform); | |
| 191 window->layer()->SetOpacity(1.0); | 156 window->layer()->SetOpacity(1.0); |
| 192 } | 157 } |
| 193 | 158 |
| 159 // Fills |containers| with the containers described by |group|. | |
| 160 void GetContainers(PowerButtonController::ContainerGroup group, | |
|
Daniel Erat
2012/02/23 02:13:16
Most of the changes to this file are just a revert
| |
| 161 aura::Window::Windows* containers) { | |
| 162 aura::Window* non_lock_screen_containers = | |
| 163 Shell::GetInstance()->GetContainer( | |
| 164 internal::kShellWindowId_NonLockScreenContainersContainer); | |
| 165 aura::Window* lock_screen_containers = | |
| 166 Shell::GetInstance()->GetContainer( | |
| 167 internal::kShellWindowId_LockScreenContainersContainer); | |
| 168 aura::Window* lock_screen_related_containers = | |
| 169 Shell::GetInstance()->GetContainer( | |
| 170 internal::kShellWindowId_LockScreenRelatedContainersContainer); | |
| 171 | |
| 172 containers->clear(); | |
| 173 switch (group) { | |
| 174 case PowerButtonController::ALL_CONTAINERS: | |
| 175 containers->push_back(non_lock_screen_containers); | |
| 176 containers->push_back(lock_screen_containers); | |
| 177 containers->push_back(lock_screen_related_containers); | |
| 178 break; | |
| 179 case PowerButtonController::SCREEN_LOCKER_CONTAINERS: | |
| 180 containers->push_back(lock_screen_containers); | |
| 181 break; | |
| 182 case PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS: | |
| 183 containers->push_back(lock_screen_containers); | |
| 184 containers->push_back(lock_screen_related_containers); | |
| 185 break; | |
| 186 case PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS: | |
| 187 containers->push_back(non_lock_screen_containers); | |
| 188 break; | |
| 189 default: | |
| 190 NOTREACHED() << "Unhandled container group " << group; | |
| 191 } | |
| 192 } | |
| 193 | |
| 194 // Apply animation |type| to all containers described by |group|. | |
| 195 void StartAnimation(PowerButtonController::ContainerGroup group, | |
| 196 PowerButtonController::AnimationType type) { | |
| 197 aura::Window::Windows containers; | |
| 198 GetContainers(group, &containers); | |
| 199 | |
| 200 for (aura::Window::Windows::const_iterator it = containers.begin(); | |
| 201 it != containers.end(); ++it) { | |
| 202 aura::Window* window = *it; | |
| 203 switch (type) { | |
| 204 case PowerButtonController::ANIMATION_SLOW_CLOSE: | |
| 205 StartSlowCloseAnimationForWindow(window); | |
| 206 break; | |
| 207 case PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE: | |
| 208 StartUndoSlowCloseAnimationForWindow(window); | |
| 209 break; | |
| 210 case PowerButtonController::ANIMATION_FAST_CLOSE: | |
| 211 StartFastCloseAnimationForWindow(window); | |
| 212 break; | |
| 213 case PowerButtonController::ANIMATION_FADE_IN: | |
| 214 FadeInWindow(window); | |
| 215 break; | |
| 216 case PowerButtonController::ANIMATION_HIDE: | |
| 217 HideWindow(window); | |
| 218 break; | |
| 219 case PowerButtonController::ANIMATION_RESTORE: | |
| 220 RestoreWindow(window); | |
| 221 break; | |
| 222 default: | |
| 223 NOTREACHED() << "Unhandled animation type " << type; | |
| 224 } | |
| 225 } | |
| 226 } | |
| 227 | |
| 194 } // namespace | 228 } // namespace |
| 195 | 229 |
| 196 bool PowerButtonController::TestApi::ContainerGroupIsAnimated( | 230 bool PowerButtonController::TestApi::ContainerGroupIsAnimated( |
| 197 ContainerGroup group, AnimationType type) const { | 231 ContainerGroup group, AnimationType type) const { |
| 198 aura::Window::Windows containers; | 232 aura::Window::Windows containers; |
| 199 controller_->GetContainers(group, &containers); | 233 GetContainers(group, &containers); |
| 200 for (aura::Window::Windows::const_iterator it = containers.begin(); | 234 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 201 it != containers.end(); ++it) { | 235 it != containers.end(); ++it) { |
| 202 aura::Window* window = *it; | 236 aura::Window* window = *it; |
| 203 ui::Layer* layer = window->layer(); | 237 ui::Layer* layer = window->layer(); |
| 204 | 238 |
| 205 switch (type) { | 239 switch (type) { |
| 206 case PowerButtonController::ANIMATION_SLOW_CLOSE: | 240 case PowerButtonController::ANIMATION_SLOW_CLOSE: |
| 207 if (layer->GetTargetTransform() != | 241 if (layer->GetTargetTransform() != GetSlowCloseTransform()) |
| 208 GetSlowCloseTransform( | |
| 209 controller_->RetrieveOriginalTransform(window))) | |
| 210 return false; | 242 return false; |
| 211 break; | 243 break; |
| 212 case PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE: | 244 case PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE: |
| 213 if (layer->GetTargetTransform() != | 245 if (layer->GetTargetTransform() != ui::Transform()) |
| 214 controller_->RetrieveOriginalTransform(window)) | 246 return false; |
| 215 return false; | |
| 216 break; | 247 break; |
| 217 case PowerButtonController::ANIMATION_FAST_CLOSE: | 248 case PowerButtonController::ANIMATION_FAST_CLOSE: |
| 218 if (layer->GetTargetTransform() != | 249 if (layer->GetTargetTransform() != GetFastCloseTransform() || |
| 219 GetFastCloseTransform(layer->GetTargetTransform()) || | |
| 220 layer->GetTargetOpacity() > 0.0001) | 250 layer->GetTargetOpacity() > 0.0001) |
| 221 return false; | 251 return false; |
| 222 break; | 252 break; |
| 223 case PowerButtonController::ANIMATION_FADE_IN: | 253 case PowerButtonController::ANIMATION_FADE_IN: |
| 224 if (layer->GetTargetOpacity() < 0.9999) | 254 if (layer->GetTargetOpacity() < 0.9999) |
| 225 return false; | 255 return false; |
| 226 break; | 256 break; |
| 227 case PowerButtonController::ANIMATION_HIDE: | 257 case PowerButtonController::ANIMATION_HIDE: |
| 228 if (layer->GetTargetOpacity() > 0.0001) | 258 if (layer->GetTargetOpacity() > 0.0001) |
| 229 return false; | 259 return false; |
| 230 break; | 260 break; |
| 231 case PowerButtonController::ANIMATION_RESTORE: | 261 case PowerButtonController::ANIMATION_RESTORE: |
| 232 if (layer->opacity() < 0.9999 || | 262 if (layer->opacity() < 0.9999 || layer->transform() != ui::Transform()) |
| 233 layer->transform() != | |
| 234 controller_->RetrieveOriginalTransform(window)) | |
| 235 return false; | 263 return false; |
| 236 break; | 264 break; |
| 237 default: | 265 default: |
| 238 NOTREACHED() << "Unhandled animation type " << type; | 266 NOTREACHED() << "Unhandled animation type " << type; |
| 239 return false; | 267 return false; |
| 240 } | 268 } |
| 241 } | 269 } |
| 242 return true; | 270 return true; |
| 243 } | 271 } |
| 244 | 272 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 lock_timer_.Stop(); | 430 lock_timer_.Stop(); |
| 403 } | 431 } |
| 404 } | 432 } |
| 405 } | 433 } |
| 406 | 434 |
| 407 void PowerButtonController::RequestShutdown() { | 435 void PowerButtonController::RequestShutdown() { |
| 408 if (!shutting_down_) | 436 if (!shutting_down_) |
| 409 StartShutdownAnimationAndRequestShutdown(); | 437 StartShutdownAnimationAndRequestShutdown(); |
| 410 } | 438 } |
| 411 | 439 |
| 412 // Fills |containers| with the containers described by |group|. | |
| 413 void PowerButtonController::GetContainers(ContainerGroup group, | |
| 414 aura::Window::Windows* containers) { | |
| 415 containers->clear(); | |
| 416 | |
| 417 aura::Window* root = Shell::GetRootWindow(); | |
| 418 for (aura::Window::Windows::const_iterator it = root->children().begin(); | |
| 419 it != root->children().end(); ++it) { | |
| 420 aura::Window* window = *it; | |
| 421 | |
| 422 bool matched = true; | |
| 423 if (group != ALL_CONTAINERS) { | |
| 424 bool is_screen_locker = IsScreenLockerContainer(window); | |
| 425 bool is_related = IsRelatedContainer(window); | |
| 426 | |
| 427 switch (group) { | |
| 428 case SCREEN_LOCKER_CONTAINERS: | |
| 429 matched = is_screen_locker; | |
| 430 break; | |
| 431 case SCREEN_LOCKER_AND_RELATED_CONTAINERS: | |
| 432 matched = is_screen_locker || is_related; | |
| 433 break; | |
| 434 case ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS: | |
| 435 matched = !is_screen_locker && !is_related; | |
| 436 break; | |
| 437 default: | |
| 438 NOTREACHED() << "Unhandled container group " << group; | |
| 439 } | |
| 440 } | |
| 441 | |
| 442 if (matched) | |
| 443 containers->push_back(window); | |
| 444 } | |
| 445 } | |
| 446 | |
| 447 void PowerButtonController::OnRootWindowResized(const gfx::Size& new_size) { | 440 void PowerButtonController::OnRootWindowResized(const gfx::Size& new_size) { |
| 448 if (background_layer_.get()) | 441 if (background_layer_.get()) |
| 449 background_layer_->SetBounds(gfx::Rect(new_size)); | 442 background_layer_->SetBounds(gfx::Rect(new_size)); |
| 450 } | 443 } |
| 451 | 444 |
| 452 void PowerButtonController::OnLockTimeout() { | 445 void PowerButtonController::OnLockTimeout() { |
| 453 delegate_->RequestLockScreen(); | 446 delegate_->RequestLockScreen(); |
| 454 lock_fail_timer_.Start( | 447 lock_fail_timer_.Start( |
| 455 FROM_HERE, | 448 FROM_HERE, |
| 456 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs), | 449 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs), |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 root_layer->Add(background_layer_.get()); | 532 root_layer->Add(background_layer_.get()); |
| 540 root_layer->StackAtBottom(background_layer_.get()); | 533 root_layer->StackAtBottom(background_layer_.get()); |
| 541 } | 534 } |
| 542 background_layer_->SetVisible(true); | 535 background_layer_->SetVisible(true); |
| 543 } | 536 } |
| 544 | 537 |
| 545 void PowerButtonController::HideBackgroundLayer() { | 538 void PowerButtonController::HideBackgroundLayer() { |
| 546 background_layer_.reset(); | 539 background_layer_.reset(); |
| 547 } | 540 } |
| 548 | 541 |
| 549 // Apply animation |type| to all containers described by |group|. | |
| 550 void PowerButtonController::StartAnimation(ContainerGroup group, | |
| 551 AnimationType type) { | |
| 552 aura::Window::Windows containers; | |
| 553 GetContainers(group, &containers); | |
| 554 for (aura::Window::Windows::const_iterator it = containers.begin(); | |
| 555 it != containers.end(); ++it) { | |
| 556 aura::Window* window = *it; | |
| 557 | |
| 558 // Store this away so we can restore. | |
| 559 if (type != ANIMATION_RESTORE && type != ANIMATION_UNDO_SLOW_CLOSE) | |
| 560 container_transforms_[window] = window->layer()->GetTargetTransform(); | |
| 561 | |
| 562 switch (type) { | |
| 563 case ANIMATION_SLOW_CLOSE: | |
| 564 StartSlowCloseAnimationForWindow(window); | |
| 565 break; | |
| 566 case ANIMATION_UNDO_SLOW_CLOSE: | |
| 567 StartUndoSlowCloseAnimationForWindow( | |
| 568 window, | |
| 569 RetrieveOriginalTransform(window)); | |
| 570 break; | |
| 571 case ANIMATION_FAST_CLOSE: | |
| 572 StartFastCloseAnimationForWindow(window); | |
| 573 break; | |
| 574 case ANIMATION_FADE_IN: | |
| 575 FadeInWindow(window); | |
| 576 break; | |
| 577 case ANIMATION_HIDE: | |
| 578 HideWindow(window); | |
| 579 break; | |
| 580 case ANIMATION_RESTORE: | |
| 581 RestoreWindow(window, RetrieveOriginalTransform(window)); | |
| 582 break; | |
| 583 default: | |
| 584 NOTREACHED() << "Unhandled animation type " << type; | |
| 585 } | |
| 586 } | |
| 587 } | |
| 588 | |
| 589 ui::Transform PowerButtonController::RetrieveOriginalTransform( | |
| 590 aura::Window* window) { | |
| 591 WindowTransformsMap::const_iterator it = container_transforms_.find(window); | |
| 592 if (it != container_transforms_.end()) | |
| 593 return it->second; | |
| 594 return ui::Transform(); | |
| 595 } | |
| 596 | |
| 597 } // namespace ash | 542 } // namespace ash |
| OLD | NEW |