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..5de57aa51410185f63fecea69f736f61e97e3831 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() |
@@ -140,14 +149,22 @@ 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(); |
+ 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
|
if (details.animate_opacity) |
window->layer()->SetOpacity(0.0f); |
+ // 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 |
+ ); |
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.
|
+ |
// After the animation completes snap the transform back to the identity, |
// otherwise any one that asks for screen bounds gets a slightly scaled |
// version. |