summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-24 00:44:54 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-24 00:44:54 +0000
commitfb4d9d1d2d0dc061167b93303f5fa50255843bf6 (patch)
treeaf1bbc62f9630efff6e1c8bcd56eb432493f3362
parent50efccb9963f1524a069dab4ae1ddc2eccf50bca (diff)
downloadchromium_src-fb4d9d1d2d0dc061167b93303f5fa50255843bf6.zip
chromium_src-fb4d9d1d2d0dc061167b93303f5fa50255843bf6.tar.gz
chromium_src-fb4d9d1d2d0dc061167b93303f5fa50255843bf6.tar.bz2
Random set of changes for workspace2 code:
. Makes Layer::GetCombinedOpacity() public so I can use in tests. . Makes some debugging functions in Window public, extends what they output and makes iteration consistant with View. . Adds WindowAnimationDelegate. Its used to decide if a window should be animated. I need this so that workspace code can selectively disable some window animations. . Makes WindowWatcher work with old workspace code. . Installs a default background for ash_shell. BUG=137342 TEST=none R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10872024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153124 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/shell/content_client/shell_browser_main_parts.cc5
-rw-r--r--ash/shell/window_watcher.cc8
-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
-rw-r--r--ui/aura/window.cc41
-rw-r--r--ui/aura/window.h12
-rw-r--r--ui/compositor/layer.cc20
-rw-r--r--ui/compositor/layer.h10
-rw-r--r--ui/gfx/transform.cc1
14 files changed, 161 insertions, 62 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 56b567d..ea1f944 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -312,6 +312,8 @@
'wm/video_detector.h',
'wm/visibility_controller.cc',
'wm/visibility_controller.h',
+ 'wm/window_animation_delegate.cc',
+ 'wm/window_animation_delegate.h',
'wm/window_animations.cc',
'wm/window_animations.h',
'wm/window_cycle_controller.cc',
diff --git a/ash/shell/content_client/shell_browser_main_parts.cc b/ash/shell/content_client/shell_browser_main_parts.cc
index 9f4ad61..06df2ad 100644
--- a/ash/shell/content_client/shell_browser_main_parts.cc
+++ b/ash/shell/content_client/shell_browser_main_parts.cc
@@ -4,6 +4,8 @@
#include "ash/shell/content_client/shell_browser_main_parts.h"
+#include "ash/desktop_background/desktop_background_controller.h"
+#include "ash/shell.h"
#include "ash/shell/shell_delegate_impl.h"
#include "ash/shell/window_watcher.h"
#include "base/bind.h"
@@ -100,6 +102,9 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
ash::shell::InitWindowTypeLauncher();
+ Shell::GetInstance()->desktop_background_controller()->
+ SetDefaultWallpaper(0, false);
+
ash::Shell::GetPrimaryRootWindow()->ShowRootWindow();
}
diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc
index a85d8f6..d37e8c8 100644
--- a/ash/shell/window_watcher.cc
+++ b/ash/shell/window_watcher.cc
@@ -8,6 +8,7 @@
#include "ash/launcher/launcher_model.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
+#include "ash/wm/workspace_controller.h"
#include "ui/aura/window.h"
namespace ash {
@@ -47,11 +48,16 @@ WindowWatcher::WindowWatcher()
panel_container_(ash::Shell::GetContainer(
Shell::GetPrimaryRootWindow(),
internal::kShellWindowId_PanelContainer)) {
- workspace_window_watcher_.reset(new WorkspaceWindowWatcher(this));
+ if (internal::WorkspaceController::IsWorkspace2Enabled())
+ workspace_window_watcher_.reset(new WorkspaceWindowWatcher(this));
+ else
+ window_->AddObserver(this);
panel_container_->AddObserver(this);
}
WindowWatcher::~WindowWatcher() {
+ if (!internal::WorkspaceController::IsWorkspace2Enabled())
+ window_->RemoveObserver(this);
panel_container_->RemoveObserver(this);
}
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);
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index a36a9f1..8df902d 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -613,6 +613,27 @@ void Window::OnDeviceScaleFactorChanged(float device_scale_factor) {
delegate_->OnDeviceScaleFactorChanged(device_scale_factor);
}
+#ifndef NDEBUG
+std::string Window::GetDebugInfo() const {
+ return StringPrintf(
+ "%s<%d> bounds(%d, %d, %d, %d) %s %s opacity=%.1f",
+ name().empty() ? "Unknown" : name().c_str(), id(),
+ bounds().x(), bounds().y(), bounds().width(), bounds().height(),
+ visible_ ? "WindowVisible" : "WindowHidden",
+ layer_->GetTargetVisibility() ? "LayerVisible" : "LayerHidden",
+ layer_->opacity());
+}
+
+void Window::PrintWindowHierarchy(int depth) const {
+ printf("%*s%s\n", depth * 2, "", GetDebugInfo().c_str());
+ for (Windows::const_iterator it = children_.begin();
+ it != children_.end(); ++it) {
+ Window* child = *it;
+ child->PrintWindowHierarchy(depth + 1);
+ }
+}
+#endif
+
///////////////////////////////////////////////////////////////////////////////
// Window, private:
@@ -941,24 +962,4 @@ bool Window::ContainsMouse() {
return contains_mouse;
}
-#ifndef NDEBUG
-std::string Window::GetDebugInfo() const {
- return StringPrintf(
- "%s<%d> bounds(%d, %d, %d, %d) %s",
- name().empty() ? "Unknown" : name().c_str(), id(),
- bounds().x(), bounds().y(), bounds().width(), bounds().height(),
- IsVisible() ? "Visible" : "Hidden");
-}
-
-void Window::PrintWindowHierarchy(int depth) const {
- printf("%*s%s\n", depth * 2, "", GetDebugInfo().c_str());
- for (Windows::const_reverse_iterator it = children_.rbegin(),
- rend = children_.rend();
- it != rend; ++it) {
- Window* child = *it;
- child->PrintWindowHierarchy(depth + 1);
- }
-}
-#endif
-
} // namespace aura
diff --git a/ui/aura/window.h b/ui/aura/window.h
index 8d98ffa..0dc9867 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -351,6 +351,12 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// Overridden from ui::LayerDelegate:
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
+#ifndef NDEBUG
+ // These methods are useful when debugging.
+ std::string GetDebugInfo() const;
+ void PrintWindowHierarchy(int depth) const;
+#endif
+
private:
friend class LayoutManager;
@@ -430,12 +436,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// Returns true if the mouse is currently within our bounds.
bool ContainsMouse();
-#ifndef NDEBUG
- // These methods are useful when debugging.
- std::string GetDebugInfo() const;
- void PrintWindowHierarchy(int depth) const;
-#endif
-
client::WindowType type_;
// True if the Window is owned by its parent - i.e. it will be deleted by its
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index b1e8f8f..be4e7c9 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -239,6 +239,16 @@ void Layer::SetOpacity(float opacity) {
GetAnimator()->SetOpacity(opacity);
}
+float Layer::GetCombinedOpacity() const {
+ float opacity = opacity_;
+ Layer* current = this->parent_;
+ while (current) {
+ opacity *= current->opacity_;
+ current = current->parent_;
+ }
+ return opacity;
+}
+
void Layer::SetBackgroundBlur(int blur_radius) {
background_blur_radius_ = blur_radius;
@@ -607,16 +617,6 @@ void Layer::SetForceRenderSurface(bool force) {
#endif
}
-float Layer::GetCombinedOpacity() const {
- float opacity = opacity_;
- Layer* current = this->parent_;
- while (current) {
- opacity *= current->opacity_;
- current = current->parent_;
- }
- return opacity;
-}
-
void Layer::StackRelativeTo(Layer* child, Layer* other, bool above) {
DCHECK_NE(child, other);
DCHECK_EQ(this, child->parent());
diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h
index a999de8..9035559 100644
--- a/ui/compositor/layer.h
+++ b/ui/compositor/layer.h
@@ -131,6 +131,10 @@ class COMPOSITOR_EXPORT Layer
float opacity() const { return opacity_; }
void SetOpacity(float opacity);
+ // Returns the actual opacity, which the opacity of this layer multipled by
+ // the combined opacity of the parent.
+ float GetCombinedOpacity() const;
+
// Blur pixels by this amount in anything below the layer and visible through
// the layer.
int background_blur() const { return background_blur_radius_; }
@@ -275,12 +279,6 @@ class COMPOSITOR_EXPORT Layer
bool force_render_surface() const { return force_render_surface_; }
private:
- // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than
- // 1.0, we'll render to a separate texture, and then apply the alpha.
- // Currently, we multiply our opacity by all our ancestor's opacities and
- // use the combined result, but this is only temporary.
- float GetCombinedOpacity() const;
-
// Stacks |child| above or below |other|. Helper method for StackAbove() and
// StackBelow().
void StackRelativeTo(Layer* child, Layer* other, bool above);
diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc
index 123ca2b..8ce0b92 100644
--- a/ui/gfx/transform.cc
+++ b/ui/gfx/transform.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "ui/gfx/transform.h"
+
#include "ui/gfx/point3.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_util.h"