diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-24 00:44:54 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-24 00:44:54 +0000 |
commit | fb4d9d1d2d0dc061167b93303f5fa50255843bf6 (patch) | |
tree | af1bbc62f9630efff6e1c8bcd56eb432493f3362 /ash | |
parent | 50efccb9963f1524a069dab4ae1ddc2eccf50bca (diff) | |
download | chromium_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
Diffstat (limited to 'ash')
-rw-r--r-- | ash/ash.gyp | 2 | ||||
-rw-r--r-- | ash/shell/content_client/shell_browser_main_parts.cc | 5 | ||||
-rw-r--r-- | ash/shell/window_watcher.cc | 8 | ||||
-rw-r--r-- | ash/wm/property_util.cc | 3 | ||||
-rw-r--r-- | ash/wm/visibility_controller.cc | 24 | ||||
-rw-r--r-- | ash/wm/window_animation_delegate.cc | 32 | ||||
-rw-r--r-- | ash/wm/window_animation_delegate.h | 40 | ||||
-rw-r--r-- | ash/wm/window_util.cc | 10 | ||||
-rw-r--r-- | ash/wm/window_util.h | 15 |
9 files changed, 119 insertions, 20 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); |