summaryrefslogtreecommitdiffstats
path: root/ash/wm
diff options
context:
space:
mode:
Diffstat (limited to 'ash/wm')
-rw-r--r--ash/wm/property_util.cc3
-rw-r--r--ash/wm/visibility_controller.cc24
-rw-r--r--ash/wm/window_animation_delegate.cc32
-rw-r--r--ash/wm/window_animation_delegate.h40
-rw-r--r--ash/wm/window_util.cc10
-rw-r--r--ash/wm/window_util.h15
6 files changed, 105 insertions, 19 deletions
diff --git a/ash/wm/property_util.cc b/ash/wm/property_util.cc
index 733d1b1..0163b2d 100644
--- a/ash/wm/property_util.cc
+++ b/ash/wm/property_util.cc
@@ -78,7 +78,8 @@ void SetDefaultPersistsAcrossAllWorkspaces(bool value) {
internal::RootWindowController* GetRootWindowController(
aura::RootWindow* root_window) {
- return root_window->GetProperty(internal::kRootWindowControllerKey);
+ return root_window ?
+ root_window->GetProperty(internal::kRootWindowControllerKey) : NULL;
}
void SetRootWindowController(aura::RootWindow* root_window,
diff --git a/ash/wm/visibility_controller.cc b/ash/wm/visibility_controller.cc
index 17fa942..7d845c9 100644
--- a/ash/wm/visibility_controller.cc
+++ b/ash/wm/visibility_controller.cc
@@ -5,22 +5,28 @@
#include "ash/wm/visibility_controller.h"
#include "ash/shell.h"
+#include "ash/wm/window_animation_delegate.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
namespace ash {
+namespace internal {
+
namespace {
-bool GetChildWindowVisibilityChangesAnimated(aura::Window* window) {
- if (!window)
+
+bool ShouldAnimateWindow(aura::Window* window) {
+ if (!window->parent() || !window->parent()->GetProperty(
+ internal::kChildWindowVisibilityChangesAnimatedKey))
return false;
- return window->GetProperty(
- internal::kChildWindowVisibilityChangesAnimatedKey);
+
+ WindowAnimationDelegate* delegate =
+ WindowAnimationDelegate::GetDelegate(window->parent());
+ return !delegate || delegate->ShouldAnimateWindow(window);
}
-} // namespace
-namespace internal {
+} // namespace
VisibilityController::VisibilityController() {
}
@@ -30,9 +36,9 @@ VisibilityController::~VisibilityController() {
void VisibilityController::UpdateLayerVisibility(aura::Window* window,
bool visible) {
- bool animated = GetChildWindowVisibilityChangesAnimated(window->parent()) &&
- window->type() != aura::client::WINDOW_TYPE_CONTROL &&
- window->type() != aura::client::WINDOW_TYPE_UNKNOWN;
+ bool animated = window->type() != aura::client::WINDOW_TYPE_CONTROL &&
+ window->type() != aura::client::WINDOW_TYPE_UNKNOWN &&
+ ShouldAnimateWindow(window);
animated = animated && AnimateOnChildWindowVisibilityChanged(window, visible);
if (!visible) {
diff --git a/ash/wm/window_animation_delegate.cc b/ash/wm/window_animation_delegate.cc
new file mode 100644
index 0000000..db2ba89
--- /dev/null
+++ b/ash/wm/window_animation_delegate.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/window_animation_delegate.h"
+
+#include "ui/aura/window.h"
+#include "ui/aura/window_property.h"
+
+DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::WindowAnimationDelegate*);
+
+namespace ash {
+namespace internal {
+
+DEFINE_WINDOW_PROPERTY_KEY(WindowAnimationDelegate*,
+ kWindowAnimationDelegateKey, NULL);
+
+// static
+void WindowAnimationDelegate::SetDelegate(aura::Window* window,
+ WindowAnimationDelegate* delegate) {
+ window->SetProperty(kWindowAnimationDelegateKey, delegate);
+}
+
+// static
+WindowAnimationDelegate* WindowAnimationDelegate::GetDelegate(
+ aura::Window* window) {
+ return window->GetProperty(kWindowAnimationDelegateKey);
+}
+
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/wm/window_animation_delegate.h b/ash/wm/window_animation_delegate.h
new file mode 100644
index 0000000..d68f165
--- /dev/null
+++ b/ash/wm/window_animation_delegate.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_WM_WINDOW_ANIMATION_DELEGATE_H_
+#define ASH_WM_WINDOW_ANIMATION_DELEGATE_H_
+
+#include "ash/ash_export.h"
+#include "base/compiler_specific.h"
+
+namespace aura {
+class Window;
+}
+
+namespace ash {
+namespace internal {
+
+// WindowAnimationDelegate is used to determine if a window should be animated.
+// It is only queried if kChildWindowVisibilityChangesAnimatedKey is true.
+// The delegate of the parent window is queried. If no delegate is installed
+// it is treated as though animations are enabled.
+class ASH_EXPORT WindowAnimationDelegate {
+ public:
+ WindowAnimationDelegate() {}
+
+ static void SetDelegate(aura::Window* window,
+ WindowAnimationDelegate* delegate);
+ static WindowAnimationDelegate* GetDelegate(aura::Window* window);
+
+ // Returns true if |window| should be animated.
+ virtual bool ShouldAnimateWindow(aura::Window* window) = 0;
+
+ protected:
+ virtual ~WindowAnimationDelegate() {}
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_WM_WINDOW_ANIMATION_DELEGATE_H_
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index 0700151..b3a8b36 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -13,7 +13,6 @@
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
-#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
@@ -63,10 +62,11 @@ bool CanActivateWindow(aura::Window* window) {
}
bool IsWindowNormal(aura::Window* window) {
- return window->GetProperty(aura::client::kShowStateKey) ==
- ui::SHOW_STATE_NORMAL ||
- window->GetProperty(aura::client::kShowStateKey) ==
- ui::SHOW_STATE_DEFAULT;
+ return IsWindowStateNormal(window->GetProperty(aura::client::kShowStateKey));
+}
+
+bool IsWindowStateNormal(ui::WindowShowState state) {
+ return state == ui::SHOW_STATE_NORMAL || state == ui::SHOW_STATE_DEFAULT;
}
bool IsWindowMaximized(aura::Window* window) {
diff --git a/ash/wm/window_util.h b/ash/wm/window_util.h
index 756e212..c27caaa 100644
--- a/ash/wm/window_util.h
+++ b/ash/wm/window_util.h
@@ -6,6 +6,8 @@
#define ASH_WM_WINDOW_UTIL_H_
#include "ash/ash_export.h"
+#include "base/compiler_specific.h"
+#include "ui/base/ui_base_types.h"
namespace aura {
class RootWindow;
@@ -36,6 +38,9 @@ ASH_EXPORT aura::Window* GetActivatableWindow(aura::Window* window);
// Returns true if |window| is normal or default.
ASH_EXPORT bool IsWindowNormal(aura::Window* window);
+// Returns true if |state| is normal or default.
+ASH_EXPORT bool IsWindowStateNormal(ui::WindowShowState state);
+
// Returns true if |window| is in the maximized state.
ASH_EXPORT bool IsWindowMaximized(aura::Window* window);
@@ -57,10 +62,12 @@ ASH_EXPORT void RestoreWindow(aura::Window* window);
// Moves the window to the center of the display.
ASH_EXPORT void CenterWindow(aura::Window* window);
-// Recreates a fresh layer for |window| and all its child windows. Does not
-// recreate shadows or other non-window layers. Returns the old layer and its
-// children, maintaining the hierarchy.
-ASH_EXPORT ui::Layer* RecreateWindowLayers(aura::Window* window);
+// Returns the existing Layer for |window| (and all its descendants) and creates
+// a new layer for |window| and all its descendants. This is intended for
+// animations that want to animate between the existing visuals and a new window
+// state. The caller owns the return value.
+ASH_EXPORT ui::Layer* RecreateWindowLayers(
+ aura::Window* window) WARN_UNUSED_RESULT;
// Deletes |layer| and all its child layers.
ASH_EXPORT void DeepDeleteLayers(ui::Layer* layer);