diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-23 19:06:14 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-23 19:06:14 +0000 |
commit | f52a0729191ddef51bfa54aec61a3cc0083e2570 (patch) | |
tree | 95c40642fc37003097d57b3f70c43c47fb7166a1 /ash | |
parent | cd609cbecfa081ec5aff94eb99022a3433827e1b (diff) | |
download | chromium_src-f52a0729191ddef51bfa54aec61a3cc0083e2570.zip chromium_src-f52a0729191ddef51bfa54aec61a3cc0083e2570.tar.gz chromium_src-f52a0729191ddef51bfa54aec61a3cc0083e2570.tar.bz2 |
ash: Create new containers for PowerButtonController.
This nests ash's existing containers inside of three new
higher-level containers-of-containers. The new higher-level
containers can be animated by PowerButtonController without
messing up transformations that have already been applied to
the lower-level containers.
BUG=114953
TEST=manual: locked and unlocked screen in compact mode with multiple browser windows
Review URL: http://codereview.chromium.org/9428056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123288 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/shell.cc | 122 | ||||
-rw-r--r-- | ash/shell_window_ids.h | 44 | ||||
-rw-r--r-- | ash/wm/power_button_controller.cc | 237 | ||||
-rw-r--r-- | ash/wm/power_button_controller.h | 18 | ||||
-rw-r--r-- | ash/wm/power_button_controller_unittest.cc | 64 | ||||
-rw-r--r-- | ash/wm/root_window_layout_manager.cc | 8 |
6 files changed, 188 insertions, 305 deletions
diff --git a/ash/shell.cc b/ash/shell.cc index 52e6ca3..c2998ae 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -79,37 +79,53 @@ const int kOverlappingWindowModeWidthThreshold = 1366; // window on Chrome OS alex devices with that height. const int kOverlappingWindowModeHeightThreshold = 800; +// Creates a new window for use as a container. +aura::Window* CreateContainer(int window_id, aura::Window* parent) { + aura::Window* container = new aura::Window(NULL); + container->set_id(window_id); + container->Init(ui::Layer::LAYER_NOT_DRAWN); + parent->AddChild(container); + if (window_id != internal::kShellWindowId_UnparentedControlContainer) + container->Show(); + return container; +} + // Creates each of the special window containers that holds windows of various -// types in the shell UI. They are added to |containers| from back to front in -// the z-index. -void CreateSpecialContainers(aura::Window::Windows* containers) { - aura::Window* unparented_control_container = new aura::Window(NULL); - unparented_control_container->set_id( - internal::kShellWindowId_UnparentedControlContainer); - containers->push_back(unparented_control_container); - - aura::Window* background_container = new aura::Window(NULL); - background_container->set_id( - internal::kShellWindowId_DesktopBackgroundContainer); - containers->push_back(background_container); - - aura::Window* default_container = new aura::Window(NULL); +// types in the shell UI. +void CreateSpecialContainers(aura::Window* root_window) { + // These containers are just used by PowerButtonController to animate groups + // of containers simultaneously without messing up the current transformations + // on those containers. These are direct children of the root window; all of + // the other containers are their children. + aura::Window* non_lock_screen_containers = CreateContainer( + internal::kShellWindowId_NonLockScreenContainersContainer, root_window); + aura::Window* lock_screen_containers = CreateContainer( + internal::kShellWindowId_LockScreenContainersContainer, root_window); + aura::Window* lock_screen_related_containers = CreateContainer( + internal::kShellWindowId_LockScreenRelatedContainersContainer, + root_window); + + CreateContainer(internal::kShellWindowId_UnparentedControlContainer, + non_lock_screen_containers); + + CreateContainer(internal::kShellWindowId_DesktopBackgroundContainer, + non_lock_screen_containers); + + aura::Window* default_container = CreateContainer( + internal::kShellWindowId_DefaultContainer, non_lock_screen_containers); default_container->SetEventFilter( new ToplevelWindowEventFilter(default_container)); - default_container->set_id(internal::kShellWindowId_DefaultContainer); SetChildWindowVisibilityChangesAnimated(default_container); - containers->push_back(default_container); - aura::Window* always_on_top_container = new aura::Window(NULL); + aura::Window* always_on_top_container = CreateContainer( + internal::kShellWindowId_AlwaysOnTopContainer, + non_lock_screen_containers); always_on_top_container->SetEventFilter( new ToplevelWindowEventFilter(always_on_top_container)); - always_on_top_container->set_id( - internal::kShellWindowId_AlwaysOnTopContainer); SetChildWindowVisibilityChangesAnimated(always_on_top_container); - containers->push_back(always_on_top_container); - aura::Window* panel_container = new aura::Window(NULL); - panel_container->set_id(internal::kShellWindowId_PanelContainer); + aura::Window* panel_container = CreateContainer( + internal::kShellWindowId_PanelContainer, non_lock_screen_containers); if (CommandLine::ForCurrentProcess()-> HasSwitch(switches::kAuraPanelManager)) { internal::PanelLayoutManager* layout_manager = @@ -118,62 +134,52 @@ void CreateSpecialContainers(aura::Window::Windows* containers) { new internal::PanelWindowEventFilter(panel_container, layout_manager)); panel_container->SetLayoutManager(layout_manager); } - containers->push_back(panel_container); - aura::Window* launcher_container = new aura::Window(NULL); - launcher_container->set_id(internal::kShellWindowId_LauncherContainer); - containers->push_back(launcher_container); + CreateContainer(internal::kShellWindowId_LauncherContainer, + non_lock_screen_containers); - aura::Window* modal_container = new aura::Window(NULL); + aura::Window* modal_container = CreateContainer( + internal::kShellWindowId_SystemModalContainer, + non_lock_screen_containers); modal_container->SetEventFilter( new ToplevelWindowEventFilter(modal_container)); modal_container->SetLayoutManager( new internal::SystemModalContainerLayoutManager(modal_container)); - modal_container->set_id(internal::kShellWindowId_SystemModalContainer); SetChildWindowVisibilityChangesAnimated(modal_container); - containers->push_back(modal_container); // TODO(beng): Figure out if we can make this use // SystemModalContainerEventFilter instead of stops_event_propagation. - aura::Window* lock_container = new aura::Window(NULL); + aura::Window* lock_container = CreateContainer( + internal::kShellWindowId_LockScreenContainer, lock_screen_containers); lock_container->SetLayoutManager(new internal::BaseLayoutManager); lock_container->set_stops_event_propagation(true); - lock_container->set_id(internal::kShellWindowId_LockScreenContainer); - containers->push_back(lock_container); - aura::Window* lock_modal_container = new aura::Window(NULL); + aura::Window* lock_modal_container = CreateContainer( + internal::kShellWindowId_LockSystemModalContainer, + lock_screen_containers); lock_modal_container->SetEventFilter( new ToplevelWindowEventFilter(lock_modal_container)); lock_modal_container->SetLayoutManager( new internal::SystemModalContainerLayoutManager(lock_modal_container)); - lock_modal_container->set_id( - internal::kShellWindowId_LockSystemModalContainer); SetChildWindowVisibilityChangesAnimated(lock_modal_container); - containers->push_back(lock_modal_container); - aura::Window* status_container = new aura::Window(NULL); - status_container->set_id(internal::kShellWindowId_StatusContainer); - containers->push_back(status_container); + CreateContainer(internal::kShellWindowId_StatusContainer, + lock_screen_related_containers); - aura::Window* menu_container = new aura::Window(NULL); - menu_container->set_id(internal::kShellWindowId_MenuContainer); + aura::Window* menu_container = CreateContainer( + internal::kShellWindowId_MenuContainer, lock_screen_related_containers); SetChildWindowVisibilityChangesAnimated(menu_container); - containers->push_back(menu_container); - aura::Window* drag_drop_container = new aura::Window(NULL); - drag_drop_container->set_id( - internal::kShellWindowId_DragImageAndTooltipContainer); + aura::Window* drag_drop_container = CreateContainer( + internal::kShellWindowId_DragImageAndTooltipContainer, + lock_screen_related_containers); SetChildWindowVisibilityChangesAnimated(drag_drop_container); - containers->push_back(drag_drop_container); - aura::Window* setting_bubble_container = new aura::Window(NULL); - setting_bubble_container->set_id( - internal::kShellWindowId_SettingBubbleContainer); - containers->push_back(setting_bubble_container); + CreateContainer(internal::kShellWindowId_SettingBubbleContainer, + lock_screen_related_containers); - aura::Window* overlay_container = new aura::Window(NULL); - overlay_container->set_id(internal::kShellWindowId_OverlayContainer); - containers->push_back(overlay_container); + CreateContainer(internal::kShellWindowId_OverlayContainer, + lock_screen_related_containers); } // Maximizes all the windows in a |container|. @@ -323,15 +329,7 @@ void Shell::Init() { activation_controller_.reset(new internal::ActivationController); - aura::Window::Windows containers; - CreateSpecialContainers(&containers); - aura::Window::Windows::const_iterator i; - for (i = containers.begin(); i != containers.end(); ++i) { - (*i)->Init(ui::Layer::LAYER_NOT_DRAWN); - root_window->AddChild(*i); - if ((*i)->id() != internal::kShellWindowId_UnparentedControlContainer) - (*i)->Show(); - } + CreateSpecialContainers(root_window); stacking_controller_.reset(new internal::StackingController); diff --git a/ash/shell_window_ids.h b/ash/shell_window_ids.h index ff5d441..e6535ed 100644 --- a/ash/shell_window_ids.h +++ b/ash/shell_window_ids.h @@ -12,50 +12,66 @@ namespace ash { namespace internal { +// A higher-level container that holds all of the containers stacked below +// kShellWindowId_LockScreenContainer. Only used by PowerButtonController for +// animating lower-level containers. +const int kShellWindowId_NonLockScreenContainersContainer = 0; + +// A higher-level container that holds containers that hold lock-screen +// windows. Only used by PowerButtonController for animating lower-level +// containers. +const int kShellWindowId_LockScreenContainersContainer = 1; + +// A higher-level container that holds containers that hold lock-screen-related +// windows (which we want to display while the screen is locked; effectively +// containers stacked above kShellWindowId_LockSystemModalContainer). Only used +// by PowerButtonController for animating lower-level containers. +const int kShellWindowId_LockScreenRelatedContainersContainer = 2; + // A container used for windows of WINDOW_TYPE_CONTROL that have no parent. // This container is not visible. -const int kShellWindowId_UnparentedControlContainer = 0; +const int kShellWindowId_UnparentedControlContainer = 3; // The desktop background window. -const int kShellWindowId_DesktopBackgroundContainer = 1; +const int kShellWindowId_DesktopBackgroundContainer = 4; // The container for standard top-level windows. -const int kShellWindowId_DefaultContainer = 2; +const int kShellWindowId_DefaultContainer = 5; // The container for top-level windows with the 'always-on-top' flag set. -const int kShellWindowId_AlwaysOnTopContainer = 3; +const int kShellWindowId_AlwaysOnTopContainer = 6; // The container for panel windows. -const int kShellWindowId_PanelContainer = 4; +const int kShellWindowId_PanelContainer = 7; // The container for the launcher. -const int kShellWindowId_LauncherContainer = 5; +const int kShellWindowId_LauncherContainer = 8; // The container for user-specific modal windows. -const int kShellWindowId_SystemModalContainer = 6; +const int kShellWindowId_SystemModalContainer = 9; // The container for the lock screen. -const int kShellWindowId_LockScreenContainer = 7; +const int kShellWindowId_LockScreenContainer = 10; // The container for the lock screen modal windows. -const int kShellWindowId_LockSystemModalContainer = 8; +const int kShellWindowId_LockSystemModalContainer = 11; // The container for the status area. -const int kShellWindowId_StatusContainer = 9; +const int kShellWindowId_StatusContainer = 12; // The container for menus. -const int kShellWindowId_MenuContainer = 10; +const int kShellWindowId_MenuContainer = 13; // The container for drag/drop images and tooltips. -const int kShellWindowId_DragImageAndTooltipContainer = 11; +const int kShellWindowId_DragImageAndTooltipContainer = 14; // The container for bubbles briefly overlaid onscreen to show settings changes // (volume, brightness, etc.). -const int kShellWindowId_SettingBubbleContainer = 12; +const int kShellWindowId_SettingBubbleContainer = 15; // The container for special components overlaid onscreen, such as the // region selector for partial screenshots. -const int kShellWindowId_OverlayContainer = 13; +const int kShellWindowId_OverlayContainer = 16; } // namespace internal diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc index cb0644f..0ca2b68 100644 --- a/ash/wm/power_button_controller.cc +++ b/ash/wm/power_button_controller.cc @@ -69,57 +69,24 @@ const int kShutdownRequestDelayMs = 50; // pre-shutdown states. const float kSlowCloseSizeRatio = 0.95f; -// Containers holding screen locker windows. -const int kScreenLockerContainerIds[] = { - internal::kShellWindowId_LockScreenContainer, - internal::kShellWindowId_LockSystemModalContainer, -}; - -// Containers holding additional windows that should be shown while the screen -// is locked. -const int kRelatedContainerIds[] = { - internal::kShellWindowId_StatusContainer, - internal::kShellWindowId_MenuContainer, - internal::kShellWindowId_DragImageAndTooltipContainer, - internal::kShellWindowId_SettingBubbleContainer, - internal::kShellWindowId_OverlayContainer, -}; - -// Is |window| a container that holds screen locker windows? -bool IsScreenLockerContainer(aura::Window* window) { - for (size_t i = 0; i < arraysize(kScreenLockerContainerIds); ++i) - if (window->id() == kScreenLockerContainerIds[i]) - return true; - return false; -} - -// Is |window| a container that holds other windows that should be shown while -// the screen is locked? -bool IsRelatedContainer(aura::Window* window) { - for (size_t i = 0; i < arraysize(kRelatedContainerIds); ++i) - if (window->id() == kRelatedContainerIds[i]) - return true; - return false; -} - -// Returns the transform, based on |base_transform|, that should be applied -// to containers for slow-close animation. -ui::Transform GetSlowCloseTransform(const ui::Transform& base_transform) { +// Returns the transform that should be applied to containers for the slow-close +// animation. +ui::Transform GetSlowCloseTransform() { gfx::Size root_size = Shell::GetRootWindow()->bounds().size(); - ui::Transform transform(base_transform); - transform.ConcatScale(kSlowCloseSizeRatio, kSlowCloseSizeRatio); + ui::Transform transform; + transform.SetScale(kSlowCloseSizeRatio, kSlowCloseSizeRatio); transform.ConcatTranslate( floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.width() + 0.5), floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.height() + 0.5)); return transform; } -// Returns the transform, based on |base_transform|, that should be applied -// to containers for fast-close animation. -ui::Transform GetFastCloseTransform(const ui::Transform& base_transform) { +// Returns the transform that should be applied to containers for the fast-close +// animation. +ui::Transform GetFastCloseTransform() { gfx::Size root_size = Shell::GetRootWindow()->bounds().size(); - ui::Transform transform(base_transform); - transform.ConcatScale(0.0, 0.0); + ui::Transform transform; + transform.SetScale(0.0, 0.0); transform.ConcatTranslate(floor(0.5 * root_size.width() + 0.5), floor(0.5 * root_size.height() + 0.5)); return transform; @@ -133,20 +100,19 @@ void StartSlowCloseAnimationForWindow(aura::Window* window) { animator->StartAnimation( new ui::LayerAnimationSequence( ui::LayerAnimationElement::CreateTransformElement( - GetSlowCloseTransform(window->layer()->GetTargetTransform()), + GetSlowCloseTransform(), base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs)))); } // Quickly undoes the effects of the slow-close animation on |window|. -void StartUndoSlowCloseAnimationForWindow(aura::Window* window, - const ui::Transform& orig_transform) { +void StartUndoSlowCloseAnimationForWindow(aura::Window* window) { ui::LayerAnimator* animator = window->layer()->GetAnimator(); animator->set_preemption_strategy( ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); animator->StartAnimation( new ui::LayerAnimationSequence( ui::LayerAnimationElement::CreateTransformElement( - orig_transform, + ui::Transform(), base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs)))); } @@ -159,7 +125,7 @@ void StartFastCloseAnimationForWindow(aura::Window* window) { animator->StartAnimation( new ui::LayerAnimationSequence( ui::LayerAnimationElement::CreateTransformElement( - GetFastCloseTransform(window->layer()->GetTargetTransform()), + GetFastCloseTransform(), base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); animator->StartAnimation( new ui::LayerAnimationSequence( @@ -185,18 +151,86 @@ void HideWindow(aura::Window* window) { // Restores |window| to its original position and scale and full opacity // instantaneously. -void RestoreWindow(aura::Window* window, - const ui::Transform& orig_transform) { - window->layer()->SetTransform(orig_transform); +void RestoreWindow(aura::Window* window) { + window->layer()->SetTransform(ui::Transform()); window->layer()->SetOpacity(1.0); } +// Fills |containers| with the containers described by |group|. +void GetContainers(PowerButtonController::ContainerGroup group, + aura::Window::Windows* containers) { + aura::Window* non_lock_screen_containers = + Shell::GetInstance()->GetContainer( + internal::kShellWindowId_NonLockScreenContainersContainer); + aura::Window* lock_screen_containers = + Shell::GetInstance()->GetContainer( + internal::kShellWindowId_LockScreenContainersContainer); + aura::Window* lock_screen_related_containers = + Shell::GetInstance()->GetContainer( + internal::kShellWindowId_LockScreenRelatedContainersContainer); + + containers->clear(); + switch (group) { + case PowerButtonController::ALL_CONTAINERS: + containers->push_back(non_lock_screen_containers); + containers->push_back(lock_screen_containers); + containers->push_back(lock_screen_related_containers); + break; + case PowerButtonController::SCREEN_LOCKER_CONTAINERS: + containers->push_back(lock_screen_containers); + break; + case PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS: + containers->push_back(lock_screen_containers); + containers->push_back(lock_screen_related_containers); + break; + case PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS: + containers->push_back(non_lock_screen_containers); + break; + default: + NOTREACHED() << "Unhandled container group " << group; + } +} + +// Apply animation |type| to all containers described by |group|. +void StartAnimation(PowerButtonController::ContainerGroup group, + PowerButtonController::AnimationType type) { + aura::Window::Windows containers; + GetContainers(group, &containers); + + for (aura::Window::Windows::const_iterator it = containers.begin(); + it != containers.end(); ++it) { + aura::Window* window = *it; + switch (type) { + case PowerButtonController::ANIMATION_SLOW_CLOSE: + StartSlowCloseAnimationForWindow(window); + break; + case PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE: + StartUndoSlowCloseAnimationForWindow(window); + break; + case PowerButtonController::ANIMATION_FAST_CLOSE: + StartFastCloseAnimationForWindow(window); + break; + case PowerButtonController::ANIMATION_FADE_IN: + FadeInWindow(window); + break; + case PowerButtonController::ANIMATION_HIDE: + HideWindow(window); + break; + case PowerButtonController::ANIMATION_RESTORE: + RestoreWindow(window); + break; + default: + NOTREACHED() << "Unhandled animation type " << type; + } + } +} + } // namespace bool PowerButtonController::TestApi::ContainerGroupIsAnimated( ContainerGroup group, AnimationType type) const { aura::Window::Windows containers; - controller_->GetContainers(group, &containers); + GetContainers(group, &containers); for (aura::Window::Windows::const_iterator it = containers.begin(); it != containers.end(); ++it) { aura::Window* window = *it; @@ -204,19 +238,15 @@ bool PowerButtonController::TestApi::ContainerGroupIsAnimated( switch (type) { case PowerButtonController::ANIMATION_SLOW_CLOSE: - if (layer->GetTargetTransform() != - GetSlowCloseTransform( - controller_->RetrieveOriginalTransform(window))) + if (layer->GetTargetTransform() != GetSlowCloseTransform()) return false; break; case PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE: - if (layer->GetTargetTransform() != - controller_->RetrieveOriginalTransform(window)) - return false; + if (layer->GetTargetTransform() != ui::Transform()) + return false; break; case PowerButtonController::ANIMATION_FAST_CLOSE: - if (layer->GetTargetTransform() != - GetFastCloseTransform(layer->GetTargetTransform()) || + if (layer->GetTargetTransform() != GetFastCloseTransform() || layer->GetTargetOpacity() > 0.0001) return false; break; @@ -229,9 +259,7 @@ bool PowerButtonController::TestApi::ContainerGroupIsAnimated( return false; break; case PowerButtonController::ANIMATION_RESTORE: - if (layer->opacity() < 0.9999 || - layer->transform() != - controller_->RetrieveOriginalTransform(window)) + if (layer->opacity() < 0.9999 || layer->transform() != ui::Transform()) return false; break; default: @@ -409,41 +437,6 @@ void PowerButtonController::RequestShutdown() { StartShutdownAnimationAndRequestShutdown(); } -// Fills |containers| with the containers described by |group|. -void PowerButtonController::GetContainers(ContainerGroup group, - aura::Window::Windows* containers) { - containers->clear(); - - aura::Window* root = Shell::GetRootWindow(); - for (aura::Window::Windows::const_iterator it = root->children().begin(); - it != root->children().end(); ++it) { - aura::Window* window = *it; - - bool matched = true; - if (group != ALL_CONTAINERS) { - bool is_screen_locker = IsScreenLockerContainer(window); - bool is_related = IsRelatedContainer(window); - - switch (group) { - case SCREEN_LOCKER_CONTAINERS: - matched = is_screen_locker; - break; - case SCREEN_LOCKER_AND_RELATED_CONTAINERS: - matched = is_screen_locker || is_related; - break; - case ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS: - matched = !is_screen_locker && !is_related; - break; - default: - NOTREACHED() << "Unhandled container group " << group; - } - } - - if (matched) - containers->push_back(window); - } -} - void PowerButtonController::OnRootWindowResized(const gfx::Size& new_size) { if (background_layer_.get()) background_layer_->SetBounds(gfx::Rect(new_size)); @@ -546,52 +539,4 @@ void PowerButtonController::HideBackgroundLayer() { background_layer_.reset(); } -// Apply animation |type| to all containers described by |group|. -void PowerButtonController::StartAnimation(ContainerGroup group, - AnimationType type) { - aura::Window::Windows containers; - GetContainers(group, &containers); - for (aura::Window::Windows::const_iterator it = containers.begin(); - it != containers.end(); ++it) { - aura::Window* window = *it; - - // Store this away so we can restore. - if (type != ANIMATION_RESTORE && type != ANIMATION_UNDO_SLOW_CLOSE) - container_transforms_[window] = window->layer()->GetTargetTransform(); - - switch (type) { - case ANIMATION_SLOW_CLOSE: - StartSlowCloseAnimationForWindow(window); - break; - case ANIMATION_UNDO_SLOW_CLOSE: - StartUndoSlowCloseAnimationForWindow( - window, - RetrieveOriginalTransform(window)); - break; - case ANIMATION_FAST_CLOSE: - StartFastCloseAnimationForWindow(window); - break; - case ANIMATION_FADE_IN: - FadeInWindow(window); - break; - case ANIMATION_HIDE: - HideWindow(window); - break; - case ANIMATION_RESTORE: - RestoreWindow(window, RetrieveOriginalTransform(window)); - break; - default: - NOTREACHED() << "Unhandled animation type " << type; - } - } -} - -ui::Transform PowerButtonController::RetrieveOriginalTransform( - aura::Window* window) { - WindowTransformsMap::const_iterator it = container_transforms_.find(window); - if (it != container_transforms_.end()) - return it->second; - return ui::Transform(); -} - } // namespace ash diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h index 1fc12c7..2070143 100644 --- a/ash/wm/power_button_controller.h +++ b/ash/wm/power_button_controller.h @@ -6,15 +6,12 @@ #define ASH_WM_POWER_BUTTON_CONTROLLER_H_ #pragma once -#include <map> - #include "ash/ash_export.h" #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/time.h" #include "base/timer.h" #include "ui/aura/root_window_observer.h" -#include "ui/aura/window.h" namespace gfx { class Size; @@ -22,7 +19,6 @@ class Size; namespace ui { class Layer; -class Transform; } namespace ash { @@ -159,10 +155,6 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver { // Displays the shutdown animation and requests shutdown when it's done. void RequestShutdown(); - // Fills |containers| with the containers described by |group|. - void GetContainers(ContainerGroup group, - aura::Window::Windows* containers); - // aura::RootWindowObserver overrides: virtual void OnRootWindowResized(const gfx::Size& new_size) OVERRIDE; @@ -196,12 +188,6 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver { void ShowBackgroundLayer(); void HideBackgroundLayer(); - // Apply animation |type| to all containers described by |group|. - void StartAnimation(ContainerGroup group, AnimationType type); - - // Retrieve original transform for |window| stored before animation started. - ui::Transform RetrieveOriginalTransform(aura::Window* window); - scoped_ptr<PowerButtonControllerDelegate> delegate_; // True if the user is currently logged in. @@ -264,10 +250,6 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver { // screen. base::OneShotTimer<PowerButtonController> hide_background_layer_timer_; - // Map from containers to their original layer transforms before animation. - typedef std::map<aura::Window*, ui::Transform> WindowTransformsMap; - WindowTransformsMap container_transforms_; - DISALLOW_COPY_AND_ASSIGN(PowerButtonController); }; diff --git a/ash/wm/power_button_controller_unittest.cc b/ash/wm/power_button_controller_unittest.cc index 11227d3..ad4c496 100644 --- a/ash/wm/power_button_controller_unittest.cc +++ b/ash/wm/power_button_controller_unittest.cc @@ -9,7 +9,6 @@ #include "base/memory/scoped_ptr.h" #include "base/time.h" #include "ui/aura/root_window.h" -#include "ui/aura/window.h" namespace ash { namespace test { @@ -278,69 +277,6 @@ TEST_F(PowerButtonControllerTest, LockAndUnlock) { EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); } -// Test that we restore transformations that are non empty. -TEST_F(PowerButtonControllerTest, LockAndUnlockTransformed) { - controller_->set_has_legacy_power_button_for_test(false); - controller_->OnLoginStateChange(true /*logged_in*/, false /*is_guest*/); - controller_->OnLockStateChange(false); - - // Get current transformation on the containers. - aura::Window::Windows windows; - controller_->GetContainers( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - &windows); - - // Set a random transform to each container layer. - ui::Transform expected_transform; - expected_transform.ConcatTranslate(180, 180); - for (aura::Window::Windows::iterator it = windows.begin(); - it != windows.end(); - ++it) { - (*it)->layer()->SetTransform(expected_transform); - } - - // Press the power button and check that the lock timer is started and that we - // start scaling the non-screen-locker containers. - controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); - EXPECT_TRUE(test_api_->lock_timer_is_running()); - EXPECT_FALSE(test_api_->shutdown_timer_is_running()); - EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - PowerButtonController::ANIMATION_SLOW_CLOSE)); - - // Check current transformation is different than before. - windows.clear(); - controller_->GetContainers( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - &windows); - for (aura::Window::Windows::iterator it = windows.begin(); - it != windows.end(); - ++it) { - EXPECT_NE(expected_transform, (*it)->layer()->GetTargetTransform()); - } - - // Release the button before the lock timer fires. - controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); - EXPECT_FALSE(test_api_->lock_timer_is_running()); - EXPECT_TRUE( - test_api_->ContainerGroupIsAnimated( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - PowerButtonController::ANIMATION_UNDO_SLOW_CLOSE)); - - // Get current transformation on the containers to compare, - // it shouldn't have changed. - windows.clear(); - controller_->GetContainers( - PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, - &windows); - for (aura::Window::Windows::iterator it = windows.begin(); - it != windows.end(); - ++it) { - EXPECT_EQ(expected_transform, (*it)->layer()->GetTargetTransform()); - } -} - // Hold the power button down from the unlocked state to eventual shutdown. TEST_F(PowerButtonControllerTest, LockToShutdown) { controller_->set_has_legacy_power_button_for_test(false); diff --git a/ash/wm/root_window_layout_manager.cc b/ash/wm/root_window_layout_manager.cc index f320ab8..e237737 100644 --- a/ash/wm/root_window_layout_manager.cc +++ b/ash/wm/root_window_layout_manager.cc @@ -46,9 +46,15 @@ void RootWindowLayoutManager::OnWindowResized() { // resize to fit the new workspace area. Shell::GetInstance()->SetWindowModeForMonitorSize(fullscreen_bounds.size()); + // Resize both our immediate children (the containers-of-containers animated + // by PowerButtonController) and their children (the actual containers). aura::Window::Windows::const_iterator i; - for (i = owner_->children().begin(); i != owner_->children().end(); ++i) + for (i = owner_->children().begin(); i != owner_->children().end(); ++i) { (*i)->SetBounds(fullscreen_bounds); + aura::Window::Windows::const_iterator j; + for (j = (*i)->children().begin(); j != (*i)->children().end(); ++j) + (*j)->SetBounds(fullscreen_bounds); + } if (background_widget_) background_widget_->SetBounds(fullscreen_bounds); |