| Index: ash/wm/workspace/workspace_animations.cc
|
| diff --git a/ash/wm/workspace/workspace_animations.cc b/ash/wm/workspace/workspace_animations.cc
|
| index 2bffbd57503ef29c359f9ecf3522f64f60bf86bc..cd2ae3548ee027b2a7b84dae24620bfa0a15068a 100644
|
| --- a/ash/wm/workspace/workspace_animations.cc
|
| +++ b/ash/wm/workspace/workspace_animations.cc
|
| @@ -5,6 +5,8 @@
|
| #include "ash/wm/workspace/workspace_animations.h"
|
|
|
| #include "ash/ash_switches.h"
|
| +#include "base/bind.h"
|
| +#include "base/callback.h"
|
| #include "base/command_line.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/compositor/layer.h"
|
| @@ -49,6 +51,13 @@ base::TimeDelta DurationForWorkspaceShowOrHide(
|
| details.duration;
|
| }
|
|
|
| +void HideWindow(aura::Window* window) {
|
| + ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
|
| + settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
|
| + settings.SetTransitionDuration(base::TimeDelta());
|
| + window->Hide();
|
| +}
|
| +
|
| } // namespace
|
|
|
| WorkspaceAnimationDetails::WorkspaceAnimationDetails()
|
| @@ -56,6 +65,7 @@ WorkspaceAnimationDetails::WorkspaceAnimationDetails()
|
| animate(false),
|
| animate_opacity(false),
|
| animate_scale(false),
|
| + can_be_cancelled(false),
|
| pause_time_ms(0) {
|
| }
|
|
|
| @@ -140,14 +150,31 @@ void HideWorkspace(aura::Window* window,
|
| window->layer()->SetTransform(gfx::Transform());
|
| }
|
|
|
| - // NOTE: Hide() must be before SetOpacity(), else
|
| - // VisibilityController::UpdateLayerVisibility doesn't pass the false to the
|
| - // layer so that the layer and window end up out of sync and confused.
|
| - window->Hide();
|
| + if (details.can_be_cancelled) {
|
| + // Window should be hidden only upon animation completion, so that focus
|
| + // is not lost if animation is cancelled.
|
| + window->layer()->SetVisible(false);
|
| + } else {
|
| + // NOTE: Hide() must be before SetOpacity(), else
|
| + // VisibilityController::UpdateLayerVisibility doesn't pass the false to the
|
| + // layer so that the layer and window end up out of sync and confused.
|
| + window->Hide();
|
| + }
|
|
|
| if (details.animate_opacity)
|
| window->layer()->SetOpacity(0.0f);
|
|
|
| + if (details.can_be_cancelled) {
|
| + // We need window-Hide() to be called to handle focus loss and other stuff
|
| + // correctly. However, this animation can be aborted in some cases
|
| + // (e.g. during lock), and window should only be hidden if animation
|
| + // completes.
|
| + base::Closure hide_window_callback = base::Bind(&HideWindow, window);
|
| + window->layer()->GetAnimator()->SetCompletionCallbackForProperties(
|
| + hide_window_callback,
|
| + ui::LayerAnimationElement::VISIBILITY,
|
| + -1);
|
| + }
|
| // After the animation completes snap the transform back to the identity,
|
| // otherwise any one that asks for screen bounds gets a slightly scaled
|
| // version.
|
|
|