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
3 // found in the LICENSE file.
5 #include "ash/wm/session_state_animator.h"
8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/window_animations.h"
10 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/window_event_dispatcher.h"
12 #include "ui/compositor/layer_animation_observer.h"
13 #include "ui/compositor/layer_animation_sequence.h"
14 #include "ui/compositor/scoped_layer_animation_settings.h"
15 #include "ui/views/widget/widget.h"
19 const int SessionStateAnimator::kAllLockScreenContainersMask
=
20 SessionStateAnimator::LOCK_SCREEN_BACKGROUND
|
21 SessionStateAnimator::LOCK_SCREEN_CONTAINERS
|
22 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS
;
24 const int SessionStateAnimator::kAllNonRootContainersMask
=
25 SessionStateAnimator::kAllLockScreenContainersMask
|
26 SessionStateAnimator::DESKTOP_BACKGROUND
|
27 SessionStateAnimator::LAUNCHER
|
28 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS
;
30 SessionStateAnimator::AnimationSequence::AnimationSequence(
31 base::Closure callback
)
32 : sequence_ended_(false),
33 animation_completed_(false),
34 invoke_callback_(false),
38 SessionStateAnimator::AnimationSequence::~AnimationSequence() {
41 void SessionStateAnimator::AnimationSequence::EndSequence() {
42 sequence_ended_
= true;
43 CleanupIfSequenceCompleted();
46 void SessionStateAnimator::AnimationSequence::OnAnimationCompleted() {
47 animation_completed_
= true;
48 invoke_callback_
= true;
49 CleanupIfSequenceCompleted();
52 void SessionStateAnimator::AnimationSequence::OnAnimationAborted() {
53 animation_completed_
= true;
54 invoke_callback_
= false;
55 CleanupIfSequenceCompleted();
58 void SessionStateAnimator::AnimationSequence::CleanupIfSequenceCompleted() {
59 if (sequence_ended_
&& animation_completed_
) {
66 SessionStateAnimator::SessionStateAnimator() {
69 SessionStateAnimator::~SessionStateAnimator() {
72 base::TimeDelta
SessionStateAnimator::GetDuration(
73 SessionStateAnimator::AnimationSpeed speed
) {
75 case ANIMATION_SPEED_IMMEDIATE
:
76 return base::TimeDelta();
77 case ANIMATION_SPEED_UNDOABLE
:
78 return base::TimeDelta::FromMilliseconds(400);
79 case ANIMATION_SPEED_REVERT
:
80 return base::TimeDelta::FromMilliseconds(150);
81 case ANIMATION_SPEED_FAST
:
82 return base::TimeDelta::FromMilliseconds(150);
83 case ANIMATION_SPEED_SHOW_LOCK_SCREEN
:
84 return base::TimeDelta::FromMilliseconds(200);
85 case ANIMATION_SPEED_MOVE_WINDOWS
:
86 return base::TimeDelta::FromMilliseconds(350);
87 case ANIMATION_SPEED_UNDO_MOVE_WINDOWS
:
88 return base::TimeDelta::FromMilliseconds(350);
89 case ANIMATION_SPEED_SHUTDOWN
:
90 return base::TimeDelta::FromMilliseconds(1000);
91 case ANIMATION_SPEED_REVERT_SHUTDOWN
:
92 return base::TimeDelta::FromMilliseconds(500);
94 // Satisfy compilers that do not understand that we will return from switch
96 DCHECK(false) << "Unhandled animation speed " << speed
;
97 return base::TimeDelta();