Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: ash/wm/workspace/workspace_animations.cc

Issue 11280188: Fix focus loss on partial lock. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixes after review Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/compositor/layer_animator.h » ('j') | ui/compositor/layer_animator.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/workspace/workspace_animations.h" 5 #include "ash/wm/workspace/workspace_animations.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "base/bind.h"
9 #include "base/callback.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
10 #include "ui/compositor/layer.h" 12 #include "ui/compositor/layer.h"
11 #include "ui/compositor/scoped_layer_animation_settings.h" 13 #include "ui/compositor/scoped_layer_animation_settings.h"
12 14
13 namespace ash { 15 namespace ash {
14 namespace internal { 16 namespace internal {
15 17
16 const int kWorkspaceSwitchTimeMS = 200; 18 const int kWorkspaceSwitchTimeMS = 200;
17 19
(...skipping 24 matching lines...) Expand all
42 44
43 // If |details.duration| is not-empty it is returned, otherwise 45 // If |details.duration| is not-empty it is returned, otherwise
44 // |kWorkspaceSwitchTimeMS| is returned. 46 // |kWorkspaceSwitchTimeMS| is returned.
45 base::TimeDelta DurationForWorkspaceShowOrHide( 47 base::TimeDelta DurationForWorkspaceShowOrHide(
46 const WorkspaceAnimationDetails& details) { 48 const WorkspaceAnimationDetails& details) {
47 return details.duration == base::TimeDelta() ? 49 return details.duration == base::TimeDelta() ?
48 base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS) : 50 base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS) :
49 details.duration; 51 details.duration;
50 } 52 }
51 53
54 void HideWindow(aura::Window* window) {
55 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
56 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
57 settings.SetTransitionDuration(base::TimeDelta());
58 window->Hide();
59 }
60
52 } // namespace 61 } // namespace
53 62
54 WorkspaceAnimationDetails::WorkspaceAnimationDetails() 63 WorkspaceAnimationDetails::WorkspaceAnimationDetails()
55 : direction(WORKSPACE_ANIMATE_UP), 64 : direction(WORKSPACE_ANIMATE_UP),
56 animate(false), 65 animate(false),
57 animate_opacity(false), 66 animate_opacity(false),
58 animate_scale(false), 67 animate_scale(false),
59 pause_time_ms(0) { 68 pause_time_ms(0) {
60 } 69 }
61 70
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details)); 142 settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details));
134 settings.SetTweenType(kWorkspaceTweenType); 143 settings.SetTweenType(kWorkspaceTweenType);
135 if (details.animate_scale) { 144 if (details.animate_scale) {
136 ApplyWorkspaceScale(window->layer(), 145 ApplyWorkspaceScale(window->layer(),
137 details.direction == WORKSPACE_ANIMATE_UP ? 146 details.direction == WORKSPACE_ANIMATE_UP ?
138 WORKSPACE_SCALE_ABOVE : WORKSPACE_SCALE_BELOW); 147 WORKSPACE_SCALE_ABOVE : WORKSPACE_SCALE_BELOW);
139 } else { 148 } else {
140 window->layer()->SetTransform(gfx::Transform()); 149 window->layer()->SetTransform(gfx::Transform());
141 } 150 }
142 151
143 // NOTE: Hide() must be before SetOpacity(), else 152 window->layer()->SetVisible(false);
Daniel Erat 2012/11/27 19:03:27 does this get balanced out by a call to SetVisible
sky 2012/11/27 21:19:29 I don't like that this leaves the workspace window
Denis Kuznetsov (DE-MUC) 2012/11/28 15:41:46 Animation is aborted only by other animation that
144 // VisibilityController::UpdateLayerVisibility doesn't pass the false to the
145 // layer so that the layer and window end up out of sync and confused.
146 window->Hide();
147 153
148 if (details.animate_opacity) 154 if (details.animate_opacity)
149 window->layer()->SetOpacity(0.0f); 155 window->layer()->SetOpacity(0.0f);
150 156
157 // We need window-Hide() to be called to handle focus loss and other stuff
158 // correctly. However, this animation can be aborted in some cases
159 // (e.g. during lock), and window should only be hidden if animation
160 // completes.
161 base::Closure hide_window_callback = base::Bind(&HideWindow, window);
162 window->layer()->GetAnimator()->SetCompletionCallbackForProperties(
163 hide_window_callback,
164 ui::LayerAnimationElement::VISIBILITY,
165 -1
166 );
Daniel Erat 2012/11/27 19:03:27 nit: move this to the end of the previous line
Denis Kuznetsov (DE-MUC) 2012/11/28 15:41:46 Done.
167
151 // After the animation completes snap the transform back to the identity, 168 // After the animation completes snap the transform back to the identity,
152 // otherwise any one that asks for screen bounds gets a slightly scaled 169 // otherwise any one that asks for screen bounds gets a slightly scaled
153 // version. 170 // version.
154 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); 171 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
155 settings.SetTransitionDuration(base::TimeDelta()); 172 settings.SetTransitionDuration(base::TimeDelta());
156 window->layer()->SetTransform(gfx::Transform()); 173 window->layer()->SetTransform(gfx::Transform());
157 } 174 }
158 175
159 } // namespace internal 176 } // namespace internal
160 } // namespace ash 177 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/layer_animator.h » ('j') | ui/compositor/layer_animator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698