summaryrefslogtreecommitdiffstats
path: root/ash/wm
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 16:04:04 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 16:04:04 +0000
commitc96b981c0c43e0cf6e0ef0035706fbea869dd939 (patch)
tree940fd3b0f2fbf08c64ddf3f6e573c2043ac5925a /ash/wm
parent3a6ec768208d2d056aa971e7e4bdc5305343db7b (diff)
downloadchromium_src-c96b981c0c43e0cf6e0ef0035706fbea869dd939.zip
chromium_src-c96b981c0c43e0cf6e0ef0035706fbea869dd939.tar.gz
chromium_src-c96b981c0c43e0cf6e0ef0035706fbea869dd939.tar.bz2
Removes worskpace 1 code. Will rename next.
BUG=none TEST=none R=ben@chromium.org,nkostylev@chromium.org TBR=nkostylev@chromium.org Review URL: https://codereview.chromium.org/11201002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r--ash/wm/activation_controller.cc10
-rw-r--r--ash/wm/always_on_top_controller.cc30
-rw-r--r--ash/wm/always_on_top_controller.h12
-rw-r--r--ash/wm/base_layout_manager.cc35
-rw-r--r--ash/wm/base_layout_manager.h7
-rw-r--r--ash/wm/frame_painter.cc10
-rw-r--r--ash/wm/shelf_layout_manager.cc7
-rw-r--r--ash/wm/stacking_controller.cc3
-rw-r--r--ash/wm/window_animations.cc90
-rw-r--r--ash/wm/window_animations.h3
-rw-r--r--ash/wm/window_animations_unittest.cc103
-rw-r--r--ash/wm/window_cycle_controller.cc6
-rw-r--r--ash/wm/workspace/base_workspace_manager.h48
-rw-r--r--ash/wm/workspace/managed_workspace.cc31
-rw-r--r--ash/wm/workspace/managed_workspace.h35
-rw-r--r--ash/wm/workspace/maximized_workspace.cc52
-rw-r--r--ash/wm/workspace/maximized_workspace.h37
-rw-r--r--ash/wm/workspace/multi_window_resize_controller_unittest.cc1
-rw-r--r--ash/wm/workspace/workspace.cc71
-rw-r--r--ash/wm/workspace/workspace.h96
-rw-r--r--ash/wm/workspace/workspace_event_handler_unittest.cc1
-rw-r--r--ash/wm/workspace/workspace_layout_manager.cc116
-rw-r--r--ash/wm/workspace/workspace_layout_manager.h68
-rw-r--r--ash/wm/workspace/workspace_layout_manager2_unittest.cc2
-rw-r--r--ash/wm/workspace/workspace_manager.cc368
-rw-r--r--ash/wm/workspace/workspace_manager.h145
-rw-r--r--ash/wm/workspace/workspace_manager2.cc4
-rw-r--r--ash/wm/workspace/workspace_manager2.h28
-rw-r--r--ash/wm/workspace/workspace_manager_unittest.cc741
-rw-r--r--ash/wm/workspace_controller.cc33
-rw-r--r--ash/wm/workspace_controller.h20
-rw-r--r--ash/wm/workspace_controller_test_helper.cc9
-rw-r--r--ash/wm/workspace_controller_test_helper.h8
33 files changed, 54 insertions, 2176 deletions
diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc
index 6859dd3..762abc5 100644
--- a/ash/wm/activation_controller.cc
+++ b/ash/wm/activation_controller.cc
@@ -36,7 +36,6 @@ const int kWindowContainerIds[] = {
kShellWindowId_SystemModalContainer,
kShellWindowId_AlwaysOnTopContainer,
kShellWindowId_AppListContainer,
- // TODO(sky): defaultcontainer shouldn't be in the list with workspace2.
kShellWindowId_DefaultContainer,
// Panel, launcher and status are intentionally checked after other
@@ -50,16 +49,12 @@ const int kWindowContainerIds[] = {
// Returns true if children of |window| can be activated.
// These are the only containers in which windows can receive focus.
bool SupportsChildActivation(aura::Window* window) {
- // TODO(sky): straighten this out when workspace2 is the default.
- // kShellWindowId_WorkspaceContainer isn't in |kWindowContainerIds| since it
- // needs to be special cased in GetTopmostWindowToActivate().
if (window->id() == kShellWindowId_WorkspaceContainer)
return true;
for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) {
if (window->id() == kWindowContainerIds[i] &&
- (window->id() != kShellWindowId_DefaultContainer ||
- !WorkspaceController::IsWorkspace2Enabled())) {
+ window->id() != kShellWindowId_DefaultContainer) {
return true;
}
}
@@ -363,8 +358,7 @@ aura::Window* ActivationController::GetTopmostWindowToActivateInContainer(
aura::Window* container,
aura::Window* ignore) const {
// Workspace2 has an extra level of windows that needs to be special cased.
- if (container->id() == kShellWindowId_DefaultContainer &&
- WorkspaceController::IsWorkspace2Enabled()) {
+ if (container->id() == kShellWindowId_DefaultContainer) {
for (aura::Window::Windows::const_reverse_iterator i =
container->children().rbegin();
i != container->children().rend(); ++i) {
diff --git a/ash/wm/always_on_top_controller.cc b/ash/wm/always_on_top_controller.cc
index 8d148db..89783f8 100644
--- a/ash/wm/always_on_top_controller.cc
+++ b/ash/wm/always_on_top_controller.cc
@@ -14,54 +14,38 @@ namespace ash {
namespace internal {
AlwaysOnTopController::AlwaysOnTopController()
- : default_container_(NULL),
- always_on_top_container_(NULL) {
+ : always_on_top_container_(NULL) {
}
AlwaysOnTopController::~AlwaysOnTopController() {
- if (default_container_)
- default_container_->RemoveObserver(this);
if (always_on_top_container_)
always_on_top_container_->RemoveObserver(this);
}
-void AlwaysOnTopController::SetContainers(
- aura::Window* default_container,
+void AlwaysOnTopController::SetAlwaysOnTopContainer(
aura::Window* always_on_top_container) {
- if (WorkspaceController::IsWorkspace2Enabled())
- default_container = NULL;
-
- // Both containers should have no children.
+ // Container should be empty.
DCHECK(always_on_top_container->children().empty());
// We are not handling any containers yet.
- DCHECK(default_container_ == NULL && always_on_top_container_ == NULL);
-
- default_container_ = default_container;
- if (default_container_)
- default_container_->AddObserver(this);
+ DCHECK(always_on_top_container_ == NULL);
always_on_top_container_ = always_on_top_container;
always_on_top_container_->AddObserver(this);
}
aura::Window* AlwaysOnTopController::GetContainer(aura::Window* window) const {
- DCHECK(always_on_top_container_ &&
- (default_container_ || WorkspaceController::IsWorkspace2Enabled()));
+ DCHECK(always_on_top_container_);
if (window->GetProperty(aura::client::kAlwaysOnTopKey))
return always_on_top_container_;
- if (default_container_)
- return default_container_;
return GetRootWindowController(always_on_top_container_->GetRootWindow())->
workspace_controller()->GetParentForNewWindow(window);
}
void AlwaysOnTopController::OnWindowAdded(aura::Window* child) {
// Observe direct child of the containers.
- if ((default_container_ && child->parent() == default_container_) ||
- child->parent() == always_on_top_container_) {
+ if (child->parent() == always_on_top_container_)
child->AddObserver(this);
- }
}
void AlwaysOnTopController::OnWillRemoveWindow(aura::Window* child) {
@@ -81,8 +65,6 @@ void AlwaysOnTopController::OnWindowPropertyChanged(aura::Window* window,
}
void AlwaysOnTopController::OnWindowDestroyed(aura::Window* window) {
- if (window == default_container_)
- default_container_ = NULL;
if (window == always_on_top_container_)
always_on_top_container_ = NULL;
}
diff --git a/ash/wm/always_on_top_controller.h b/ash/wm/always_on_top_controller.h
index 386ce27..57fbf99 100644
--- a/ash/wm/always_on_top_controller.h
+++ b/ash/wm/always_on_top_controller.h
@@ -17,17 +17,16 @@ namespace ash {
namespace internal {
// AlwaysOnTopController puts window into proper containers based on its
-// 'AlwaysOnTop' property. That is, putting a window to |default_container_|
-// if its "AlwaysOnTop" property is false. Otherwise, put it in
+// 'AlwaysOnTop' property. That is, putting a window into the worskpace
+// container if its "AlwaysOnTop" property is false. Otherwise, put it in
// |always_on_top_container_|.
class AlwaysOnTopController : public aura::WindowObserver {
public:
AlwaysOnTopController();
virtual ~AlwaysOnTopController();
- // Sets the two top level window containers.
- void SetContainers(aura::Window* default_container,
- aura::Window* always_on_top_container);
+ // Sets the container for always on top windows.
+ void SetAlwaysOnTopContainer(aura::Window* always_on_top_container);
// Gets container for given |window| based on its "AlwaysOnTop" property.
aura::Window* GetContainer(aura::Window* window) const;
@@ -41,9 +40,6 @@ class AlwaysOnTopController : public aura::WindowObserver {
intptr_t old) OVERRIDE;
virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
- // TODO(sky): remove this after workspace2 is the default.
- // Is NULL if workspace2 is enabled.
- aura::Window* default_container_;
aura::Window* always_on_top_container_;
DISALLOW_COPY_AND_ASSIGN(AlwaysOnTopController);
diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc
index 2f2ffb4..1bf6434a 100644
--- a/ash/wm/base_layout_manager.cc
+++ b/ash/wm/base_layout_manager.cc
@@ -4,16 +4,13 @@
#include "ash/wm/base_layout_manager.h"
-#include "ash/ash_switches.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
-#include "ash/wm/workspace_controller.h"
#include "ash/wm/workspace/workspace_window_resizer.h"
-#include "base/command_line.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -71,7 +68,7 @@ void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
// Only update the bounds if the window has a show state that depends on the
// workspace area.
if (wm::IsWindowMaximized(child) || wm::IsWindowFullscreen(child))
- UpdateBoundsFromShowState(child, false);
+ UpdateBoundsFromShowState(child);
}
void BaseLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
@@ -136,11 +133,7 @@ void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window,
old_state != ui::SHOW_STATE_MAXIMIZED))) {
SetRestoreBoundsInParent(window, window->bounds());
}
- // Minimized state handles its own animations.
- // TODO(sky): get animations to work with Workspace2.
- bool animate = (old_state != ui::SHOW_STATE_MINIMIZED) &&
- !WorkspaceController::IsWorkspace2Enabled();
- UpdateBoundsFromShowState(window, animate);
+ UpdateBoundsFromShowState(window);
ShowStateChanged(window, old_state);
}
}
@@ -177,8 +170,7 @@ void BaseLayoutManager::ShowStateChanged(aura::Window* window,
}
}
-void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window,
- bool animate) {
+void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) {
switch (window->GetProperty(aura::client::kShowStateKey)) {
case ui::SHOW_STATE_DEFAULT:
case ui::SHOW_STATE_NORMAL: {
@@ -186,8 +178,7 @@ void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window,
if (restore) {
gfx::Rect bounds_in_parent =
ScreenAsh::ConvertRectFromScreen(window->parent(), *restore);
- MaybeAnimateToBounds(window,
- animate,
+ SetChildBoundsDirect(window,
BoundsWithScreenEdgeVisible(window,
bounds_in_parent));
}
@@ -196,8 +187,7 @@ void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window,
}
case ui::SHOW_STATE_MAXIMIZED:
- MaybeAnimateToBounds(window,
- animate,
+ SetChildBoundsDirect(window,
ScreenAsh::GetMaximizedWindowBoundsInParent(window));
break;
@@ -213,21 +203,6 @@ void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window,
}
}
-void BaseLayoutManager::MaybeAnimateToBounds(aura::Window* window,
- bool animate,
- const gfx::Rect& new_bounds) {
- // Only animate visible windows.
- if (animate &&
- window->TargetVisibility() &&
- !window->GetProperty(aura::client::kAnimationsDisabledKey) &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- ash::switches::kAshWindowAnimationsDisabled)) {
- CrossFadeToBounds(window, new_bounds);
- return;
- }
- SetChildBoundsDirect(window, new_bounds);
-}
-
void BaseLayoutManager::AdjustWindowSizesForScreenChange() {
// If a user plugs an external display into a laptop running Aura the
// display size will change. Maximized windows need to resize to match.
diff --git a/ash/wm/base_layout_manager.h b/ash/wm/base_layout_manager.h
index 7c059c5..466349c 100644
--- a/ash/wm/base_layout_manager.h
+++ b/ash/wm/base_layout_manager.h
@@ -77,12 +77,7 @@ class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager,
private:
// Update window bounds based on a change in show state.
- void UpdateBoundsFromShowState(aura::Window* window, bool animate);
-
- // Updates window bounds and animates when requested and possible.
- void MaybeAnimateToBounds(aura::Window* window,
- bool animate,
- const gfx::Rect& new_bounds);
+ void UpdateBoundsFromShowState(aura::Window* window);
// Adjusts the window sizes when the screen changes its size or its
// work area insets.
diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc
index 1f77072..e0c74d1 100644
--- a/ash/wm/frame_painter.cc
+++ b/ash/wm/frame_painter.cc
@@ -471,8 +471,7 @@ void FramePainter::PaintTitleBar(views::NonClientFrameView* view,
void FramePainter::LayoutHeader(views::NonClientFrameView* view,
bool shorter_layout) {
// The new assets only make sense if the window is actually maximized.
- if (internal::WorkspaceController::IsWorkspace2Enabled() &&
- shorter_layout && frame_->IsMaximized() &&
+ if (shorter_layout && frame_->IsMaximized() &&
GetTrackedByWorkspace(frame_->GetNativeWindow())) {
SetButtonImages(close_button_,
IDR_AURA_WINDOW_MAXIMIZED_CLOSE2,
@@ -652,9 +651,7 @@ int FramePainter::GetHeaderOpacity(HeaderMode header_mode,
// Maximized windows with workspace2 are totally transparent, except those not
// tracked by workspace code (which are used for tab dragging).
- if (frame_->IsMaximized() &&
- internal::WorkspaceController::IsWorkspace2Enabled() &&
- GetTrackedByWorkspace(frame_->GetNativeWindow()))
+ if (frame_->IsMaximized() && GetTrackedByWorkspace(frame_->GetNativeWindow()))
return 0;
// Single browser window is very transparent.
@@ -731,8 +728,7 @@ FramePainter* FramePainter::GetSoloPainterInRoot(
// the existence of a layout manager gets additionally tested.
if (IsVisibleNormalWindow((*it)->window_) &&
(!(*it)->window_->GetProperty(ash::kConstrainedWindowKey))) {
- if (internal::WorkspaceController::IsWorkspace2Enabled() &&
- wm::IsWindowMaximized((*it)->window_)) {
+ if (wm::IsWindowMaximized((*it)->window_)) {
return NULL;
}
if (painter)
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index 75a53b7..0ec4a13 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -568,14 +568,11 @@ void ShelfLayoutManager::SetState(VisibilityState visibility_state) {
state_ = state;
TargetBounds target_bounds;
CalculateTargetBounds(state_, &target_bounds);
- const int animate_time_ms =
- WorkspaceController::IsWorkspace2Enabled() ? kWorkspaceSwitchTimeMS :
- 130;
if (launcher_widget()) {
ui::ScopedLayerAnimationSettings launcher_animation_setter(
GetLayer(launcher_widget())->GetAnimator());
launcher_animation_setter.SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(animate_time_ms));
+ base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS));
launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT);
GetLayer(launcher_widget())->SetBounds(
target_bounds.launcher_bounds_in_root);
@@ -584,7 +581,7 @@ void ShelfLayoutManager::SetState(VisibilityState visibility_state) {
ui::ScopedLayerAnimationSettings status_animation_setter(
GetLayer(status_)->GetAnimator());
status_animation_setter.SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(animate_time_ms));
+ base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS));
status_animation_setter.SetTweenType(ui::Tween::EASE_OUT);
// Delay updating the background when going from AUTO_HIDE_SHOWN to
diff --git a/ash/wm/stacking_controller.cc b/ash/wm/stacking_controller.cc
index 092042d..26103a8 100644
--- a/ash/wm/stacking_controller.cc
+++ b/ash/wm/stacking_controller.cc
@@ -143,8 +143,7 @@ StackingController::GetAlwaysOnTopController(aura::RootWindow* root_window) {
root_window->GetProperty(internal::kAlwaysOnTopControllerKey);
if (!controller) {
controller = new internal::AlwaysOnTopController;
- controller->SetContainers(
- root_window->GetChildById(internal::kShellWindowId_DefaultContainer),
+ controller->SetAlwaysOnTopContainer(
root_window->GetChildById(
internal::kShellWindowId_AlwaysOnTopContainer));
// RootWindow owns the AlwaysOnTopController object.
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index 66831b2..bd56fa0 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -87,9 +87,6 @@ const float kWindowAnimation_ScaleFactor = .95f;
// TODO(sky): if we end up sticking with 0, nuke the code doing the rotation.
const float kWindowAnimation_MinimizeRotate = 0.f;
-// Amount windows are scaled during workspace animations.
-const float kWorkspaceScale = .95f;
-
// Tween type when cross fading a workspace window.
const ui::Tween::Type kCrossFadeTweenType = ui::Tween::EASE_IN_OUT;
@@ -321,81 +318,6 @@ void AnimateHideWindow_Fade(aura::Window* window) {
AnimateHideWindowCommon(window, gfx::Transform());
}
-// Builds the transform used when switching workspaces for the specified
-// window.
-gfx::Transform BuildWorkspaceSwitchTransform(aura::Window* window,
- float scale) {
- // Animations for transitioning workspaces scale all windows. To give the
- // effect of scaling from the center of the screen the windows are translated.
- gfx::Rect bounds = window->bounds();
- gfx::Rect parent_bounds(window->parent()->bounds());
-
- float mid_x = static_cast<float>(parent_bounds.width()) / 2.0f;
- float initial_x =
- (static_cast<float>(bounds.x()) - mid_x) * scale + mid_x;
- float mid_y = static_cast<float>(parent_bounds.height()) / 2.0f;
- float initial_y =
- (static_cast<float>(bounds.y()) - mid_y) * scale + mid_y;
-
- gfx::Transform transform;
- transform.ConcatTranslate(
- initial_x - static_cast<float>(bounds.x()),
- initial_y - static_cast<float>(bounds.y()));
- transform.ConcatScale(scale, scale);
- return transform;
-}
-
-void AnimateShowWindow_Workspace(aura::Window* window) {
- gfx::Transform transform(
- BuildWorkspaceSwitchTransform(window, kWorkspaceScale));
- // When we call SetOpacity here, if a hide sequence is already running,
- // the default animation preemption strategy fast forwards the hide sequence
- // to completion and notifies the WorkspaceHidingWindowAnimationObserver to
- // set the layer to be invisible. We should call SetVisible after SetOpacity
- // to ensure our layer is visible again.
- window->layer()->SetOpacity(0.0f);
- window->layer()->SetTransform(transform);
- window->layer()->SetVisible(true);
-
- {
- // Property sets within this scope will be implicitly animated.
- ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
-
- window->layer()->SetTransform(gfx::Transform());
- // Opacity animates only during the first half of the animation.
- settings.SetTransitionDuration(settings.GetTransitionDuration() / 2);
- window->layer()->SetOpacity(1.0f);
- }
-}
-
-void AnimateHideWindow_Workspace(aura::Window* window) {
- gfx::Transform transform(
- BuildWorkspaceSwitchTransform(window, kWorkspaceScale));
- window->layer()->SetOpacity(1.0f);
- window->layer()->SetTransform(gfx::Transform());
-
- // Opacity animates from 1 to 0 only over the second half of the animation. To
- // get this functionality two animations are schedule for opacity, the first
- // from 1 to 1 (which effectively does nothing) the second from 1 to 0.
- // Because we're scheduling two animations of the same property we need to
- // change the preemption strategy.
- ui::LayerAnimator* animator = window->layer()->GetAnimator();
- animator->set_preemption_strategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
- {
- // Property sets within this scope will be implicitly animated.
- ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- // Add an observer that sets visibility of the layer to false once animation
- // completes.
- settings.AddObserver(new WorkspaceHidingWindowAnimationObserver(window));
- window->layer()->SetTransform(transform);
- settings.SetTransitionDuration(settings.GetTransitionDuration() / 2);
- window->layer()->SetOpacity(1.0f);
- window->layer()->SetOpacity(0.0f);
- }
- animator->set_preemption_strategy(
- ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET);
-}
-
gfx::Rect GetMinimizeRectForWindow(aura::Window* window) {
gfx::Rect target_bounds = Shell::GetInstance()->launcher()->
GetScreenBoundsOfItemIconForWindow(window);
@@ -583,9 +505,6 @@ bool AnimateShowWindow(aura::Window* window) {
case WINDOW_VISIBILITY_ANIMATION_TYPE_FADE:
AnimateShowWindow_Fade(window);
return true;
- case WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_SHOW:
- AnimateShowWindow_Workspace(window);
- return true;
case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
AnimateShowWindow_Minimize(window);
return true;
@@ -612,9 +531,6 @@ bool AnimateHideWindow(aura::Window* window) {
case WINDOW_VISIBILITY_ANIMATION_TYPE_FADE:
AnimateHideWindow_Fade(window);
return true;
- case WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_HIDE:
- AnimateHideWindow_Workspace(window);
- return true;
case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
AnimateHideWindow_Minimize(window);
return true;
@@ -842,19 +758,17 @@ TimeDelta GetCrossFadeDuration(const gfx::Rect& old_bounds,
ash::switches::kAshWindowAnimationsDisabled))
return base::TimeDelta();
- const int min_time_ms = internal::WorkspaceController::IsWorkspace2Enabled() ?
- internal::kWorkspaceSwitchTimeMS : 0;
int old_area = old_bounds.width() * old_bounds.height();
int new_area = new_bounds.width() * new_bounds.height();
int max_area = std::max(old_area, new_area);
// Avoid divide by zero.
if (max_area == 0)
- return TimeDelta::FromMilliseconds(min_time_ms);
+ return TimeDelta::FromMilliseconds(internal::kWorkspaceSwitchTimeMS);
int delta_area = std::abs(old_area - new_area);
// If the area didn't change, the animation is instantaneous.
if (delta_area == 0)
- return TimeDelta::FromMilliseconds(min_time_ms);
+ return TimeDelta::FromMilliseconds(internal::kWorkspaceSwitchTimeMS);
float factor =
static_cast<float>(delta_area) / static_cast<float>(max_area);
diff --git a/ash/wm/window_animations.h b/ash/wm/window_animations.h
index 90fa179..e0c32d4 100644
--- a/ash/wm/window_animations.h
+++ b/ash/wm/window_animations.h
@@ -31,9 +31,6 @@ enum WindowVisibilityAnimationType {
WINDOW_VISIBILITY_ANIMATION_TYPE_DROP, // Window shrinks in.
WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL, // Vertical Glenimation.
WINDOW_VISIBILITY_ANIMATION_TYPE_FADE, // Fades in/out.
- WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_SHOW, // Windows are scaled and
- // fade in.
- WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_HIDE, // Inverse of SHOW.
WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE, // Window scale/rotates down
// to its launcher icon.
// Fade in/out using brightness and grayscale web filters.
diff --git a/ash/wm/window_animations_unittest.cc b/ash/wm/window_animations_unittest.cc
index ee6a1c9..eebed14 100644
--- a/ash/wm/window_animations_unittest.cc
+++ b/ash/wm/window_animations_unittest.cc
@@ -33,74 +33,6 @@ class WindowAnimationsTest : public ash::test::AshTestBase {
DISALLOW_COPY_AND_ASSIGN(WindowAnimationsTest);
};
-TEST_F(WindowAnimationsTest, HideShow) {
- scoped_ptr<aura::Window> window(
- aura::test::CreateTestWindowWithId(0, NULL));
- window->Show();
- EXPECT_TRUE(window->layer()->visible());
- // Hiding.
- SetWindowVisibilityAnimationType(
- window.get(),
- WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_HIDE);
- ash::internal::AnimateOnChildWindowVisibilityChanged(
- window.get(), false);
- EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity());
- EXPECT_FALSE(window->layer()->GetTargetVisibility());
- EXPECT_FALSE(window->layer()->visible());
- // Showing.
- SetWindowVisibilityAnimationType(
- window.get(),
- WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_SHOW);
- ash::internal::AnimateOnChildWindowVisibilityChanged(
- window.get(), true);
- EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
- EXPECT_TRUE(window->layer()->GetTargetVisibility());
- EXPECT_TRUE(window->layer()->visible());
- // Stays showing.
- ui::AnimationContainerElement* element =
- static_cast<ui::AnimationContainerElement*>(
- window->layer()->GetAnimator());
- element->Step(base::TimeTicks::Now() +
- base::TimeDelta::FromSeconds(5));
- EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
- EXPECT_TRUE(window->layer()->GetTargetVisibility());
- EXPECT_TRUE(window->layer()->visible());
-}
-
-TEST_F(WindowAnimationsTest, ShowHide) {
- scoped_ptr<aura::Window> window(
- aura::test::CreateTestWindowWithId(0, NULL));
- window->Show();
- EXPECT_TRUE(window->layer()->visible());
- // Showing -- should be a no-op.
- SetWindowVisibilityAnimationType(
- window.get(),
- WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_SHOW);
- ash::internal::AnimateOnChildWindowVisibilityChanged(
- window.get(), true);
- EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
- EXPECT_TRUE(window->layer()->GetTargetVisibility());
- EXPECT_TRUE(window->layer()->visible());
- // Hiding.
- SetWindowVisibilityAnimationType(
- window.get(),
- WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_HIDE);
- ash::internal::AnimateOnChildWindowVisibilityChanged(
- window.get(), false);
- EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity());
- EXPECT_FALSE(window->layer()->GetTargetVisibility());
- EXPECT_FALSE(window->layer()->visible());
- // Stays hidden.
- ui::AnimationContainerElement* element =
- static_cast<ui::AnimationContainerElement*>(
- window->layer()->GetAnimator());
- element->Step(base::TimeTicks::Now() +
- base::TimeDelta::FromSeconds(5));
- EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity());
- EXPECT_FALSE(window->layer()->GetTargetVisibility());
- EXPECT_FALSE(window->layer()->visible());
-}
-
TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
scoped_ptr<aura::Window> window(
aura::test::CreateTestWindowWithId(0, NULL));
@@ -205,40 +137,5 @@ TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
}
-TEST_F(WindowAnimationsTest, GetCrossFadeDuration) {
- if (WorkspaceController::IsWorkspace2Enabled())
- return;
-
- gfx::Rect empty;
- gfx::Rect screen(0, 0, 1000, 500);
-
- // No change takes no time.
- EXPECT_EQ(0, GetCrossFadeDuration(empty, empty).InMilliseconds());
- EXPECT_EQ(0, GetCrossFadeDuration(screen, screen).InMilliseconds());
-
- // Small changes are fast.
- const int kMinimum = 100;
- const int kRange = 300;
- gfx::Rect almost_screen(10, 10, 1000, 450); // 90% of screen area
- EXPECT_EQ(kMinimum + kRange / 10,
- GetCrossFadeDuration(almost_screen, screen).InMilliseconds());
- EXPECT_EQ(kMinimum + kRange / 10,
- GetCrossFadeDuration(screen, almost_screen).InMilliseconds());
-
- // Large changes are slow.
- gfx::Rect ten_percent(10, 10, 100, 500); // 10% of screen area
- EXPECT_EQ(kMinimum + kRange * 9 / 10,
- GetCrossFadeDuration(ten_percent, screen).InMilliseconds());
- EXPECT_EQ(kMinimum + kRange * 9 / 10,
- GetCrossFadeDuration(screen, ten_percent).InMilliseconds());
-
- // Medium changes take medium time.
- gfx::Rect half_screen(10, 10, 500, 250);
- EXPECT_EQ(kMinimum + kRange * 3 / 4,
- GetCrossFadeDuration(half_screen, screen).InMilliseconds());
- EXPECT_EQ(kMinimum + kRange * 3 / 4,
- GetCrossFadeDuration(screen, half_screen).InMilliseconds());
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc
index ac171b5..7568f15 100644
--- a/ash/wm/window_cycle_controller.cc
+++ b/ash/wm/window_cycle_controller.cc
@@ -105,12 +105,10 @@ void AddCycleWindows(aura::RootWindow* root,
int container_id,
WindowCycleList::WindowList* windows) {
aura::Window* container = Shell::GetContainer(root, container_id);
- if (container_id == internal::kShellWindowId_DefaultContainer &&
- internal::WorkspaceController::IsWorkspace2Enabled()) {
+ if (container_id == internal::kShellWindowId_DefaultContainer)
AddWorkspace2Children(container, windows);
- } else {
+ else
AddAllChildren(container, windows);
- }
}
} // namespace
diff --git a/ash/wm/workspace/base_workspace_manager.h b/ash/wm/workspace/base_workspace_manager.h
deleted file mode 100644
index 6ac8607..0000000
--- a/ash/wm/workspace/base_workspace_manager.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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_WORKSPACE_BASE_WORKSPACE_MANAGER_H_
-#define ASH_WM_WORKSPACE_BASE_WORKSPACE_MANAGER_H_
-
-#include "ash/ash_export.h"
-#include "ash/wm/workspace/workspace_types.h"
-
-namespace aura {
-class Window;
-}
-
-namespace ash {
-namespace internal {
-
-class ShelfLayoutManager;
-
-// TODO: this is temporary until WorkspaceManager2 is the default.
-class ASH_EXPORT BaseWorkspaceManager {
- public:
- virtual ~BaseWorkspaceManager() {}
-
- // Returns true if in maximized or fullscreen mode.
- virtual bool IsInMaximizedMode() const = 0;
-
- // Returns the current window state.
- virtual WorkspaceWindowState GetWindowState() const = 0;
-
- virtual void SetShelf(ShelfLayoutManager* shelf) = 0;
-
- // Activates the workspace containing |window|. Does nothing if |window| is
- // NULL or not contained in a workspace.
- virtual void SetActiveWorkspaceByWindow(aura::Window* window) = 0;
-
- // Returns the parent for |window|. This is invoked from StackingController
- // when a new Window is being added.
- virtual aura::Window* GetParentForNewWindow(aura::Window* window) = 0;
-
- // Starts the animation that occurs on first login.
- virtual void DoInitialAnimation() = 0;
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_WORKSPACE_BASE_WORKSPACE_MANAGER_H_
diff --git a/ash/wm/workspace/managed_workspace.cc b/ash/wm/workspace/managed_workspace.cc
deleted file mode 100644
index 4c9306e..0000000
--- a/ash/wm/workspace/managed_workspace.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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/workspace/managed_workspace.h"
-
-#include "ash/wm/window_util.h"
-
-namespace ash {
-namespace internal {
-
-ManagedWorkspace::ManagedWorkspace(WorkspaceManager* manager)
- : Workspace(manager, TYPE_MANAGED) {
-}
-
-ManagedWorkspace::~ManagedWorkspace() {
-}
-
-bool ManagedWorkspace::CanAdd(aura::Window* window) const {
- return !wm::IsWindowFullscreen(window) && !wm::IsWindowMaximized(window);
-}
-
-void ManagedWorkspace::OnWindowAddedAfter(aura::Window* window,
- aura::Window* after) {
-}
-
-void ManagedWorkspace::OnWindowRemoved(aura::Window* window) {
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/workspace/managed_workspace.h b/ash/wm/workspace/managed_workspace.h
deleted file mode 100644
index 764d78b..0000000
--- a/ash/wm/workspace/managed_workspace.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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_WORKSPACE_MANAGED_WORKSPACE_H_
-#define ASH_WM_WORKSPACE_MANAGED_WORKSPACE_H_
-
-#include "ash/wm/workspace/workspace.h"
-#include "base/compiler_specific.h"
-
-namespace ash {
-namespace internal {
-
-// ManagedWorkspace allows any non-maximized/fullscreen windows. It imposes
-// constraints on where the windows can be placed and how they can be resized.
-class ASH_EXPORT ManagedWorkspace : public Workspace {
- public:
- explicit ManagedWorkspace(WorkspaceManager* manager);
- virtual ~ManagedWorkspace();
-
- protected:
- // Workspace overrides:
- virtual bool CanAdd(aura::Window* window) const OVERRIDE;
- virtual void OnWindowAddedAfter(aura::Window* window,
- aura::Window* after) OVERRIDE;
- virtual void OnWindowRemoved(aura::Window* window) OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ManagedWorkspace);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_WORKSPACE_MANAGED_WORKSPACE_H_
diff --git a/ash/wm/workspace/maximized_workspace.cc b/ash/wm/workspace/maximized_workspace.cc
deleted file mode 100644
index d741e8e..0000000
--- a/ash/wm/workspace/maximized_workspace.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// 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/workspace/maximized_workspace.h"
-
-#include "ash/screen_ash.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_util.h"
-#include "ash/wm/workspace/workspace_manager.h"
-#include "base/logging.h"
-#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/gfx/screen.h"
-
-namespace ash {
-namespace internal {
-
-MaximizedWorkspace::MaximizedWorkspace(WorkspaceManager* manager)
- : Workspace(manager, TYPE_MAXIMIZED) {
-}
-
-MaximizedWorkspace::~MaximizedWorkspace() {
-}
-
-bool MaximizedWorkspace::CanAdd(aura::Window* window) const {
- return is_empty() && (wm::IsWindowFullscreen(window) ||
- wm::IsWindowMaximized(window));
-}
-
-void MaximizedWorkspace::OnWindowAddedAfter(aura::Window* window,
- aura::Window* after) {
- ResetWindowBounds(window);
-}
-
-void MaximizedWorkspace::OnWindowRemoved(aura::Window* window) {
-}
-
-void MaximizedWorkspace::ResetWindowBounds(aura::Window* window) {
- if (wm::IsWindowFullscreen(window)) {
- SetWindowBounds(window,
- ScreenAsh::GetDisplayBoundsInParent(window));
- } else {
- SetWindowBounds(window,
- ScreenAsh::GetMaximizedWindowBoundsInParent(window));
- }
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/workspace/maximized_workspace.h b/ash/wm/workspace/maximized_workspace.h
deleted file mode 100644
index 9f45756..0000000
--- a/ash/wm/workspace/maximized_workspace.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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_WORKSPACE_MAXIMIZED_WORKSPACE_H_
-#define ASH_WM_WORKSPACE_MAXIMIZED_WORKSPACE_H_
-
-#include "ash/wm/workspace/workspace.h"
-#include "base/compiler_specific.h"
-
-namespace ash {
-namespace internal {
-
-// Workspace implementation that contains a single maximized or fullscreen
-// window.
-class ASH_EXPORT MaximizedWorkspace : public Workspace {
- public:
- explicit MaximizedWorkspace(WorkspaceManager* manager);
- virtual ~MaximizedWorkspace();
-
- protected:
- // Workspace overrides:
- virtual bool CanAdd(aura::Window* window) const OVERRIDE;
- virtual void OnWindowAddedAfter(aura::Window* window,
- aura::Window* after) OVERRIDE;
- virtual void OnWindowRemoved(aura::Window* window) OVERRIDE;
-
- private:
- void ResetWindowBounds(aura::Window* window);
-
- DISALLOW_COPY_AND_ASSIGN(MaximizedWorkspace);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_WORKSPACE_MAXIMIZED_WORKSPACE_H_
diff --git a/ash/wm/workspace/multi_window_resize_controller_unittest.cc b/ash/wm/workspace/multi_window_resize_controller_unittest.cc
index 14b32bf..e528438 100644
--- a/ash/wm/workspace/multi_window_resize_controller_unittest.cc
+++ b/ash/wm/workspace/multi_window_resize_controller_unittest.cc
@@ -10,7 +10,6 @@
#include "ash/wm/workspace_controller.h"
#include "ash/wm/workspace_controller_test_helper.h"
#include "ash/wm/workspace/workspace_event_handler_test_helper.h"
-#include "ash/wm/workspace/workspace_manager.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"
diff --git a/ash/wm/workspace/workspace.cc b/ash/wm/workspace/workspace.cc
deleted file mode 100644
index e153de4..0000000
--- a/ash/wm/workspace/workspace.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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/workspace/workspace.h"
-
-#include <algorithm>
-
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_util.h"
-#include "ash/wm/workspace/workspace_manager.h"
-#include "base/logging.h"
-#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"
-
-namespace ash {
-namespace internal {
-
-Workspace::Workspace(WorkspaceManager* manager, Type type)
- : type_(type),
- workspace_manager_(manager) {
-}
-
-Workspace::~Workspace() {
- workspace_manager_->RemoveWorkspace(this);
-}
-
-// static
-Workspace::Type Workspace::TypeForWindow(aura::Window* window) {
- if (wm::IsWindowMaximized(window) || wm::IsWindowFullscreen(window))
- return TYPE_MAXIMIZED;
- return TYPE_MANAGED;
-}
-
-bool Workspace::AddWindowAfter(aura::Window* window, aura::Window* after) {
- if (!CanAdd(window))
- return false;
- DCHECK(!Contains(window));
-
- aura::Window::Windows::iterator i =
- std::find(windows_.begin(), windows_.end(), after);
- if (!after || i == windows_.end())
- windows_.push_back(window);
- else
- windows_.insert(++i, window);
- OnWindowAddedAfter(window, after);
- return true;
-}
-
-void Workspace::RemoveWindow(aura::Window* window) {
- DCHECK(Contains(window));
- windows_.erase(std::find(windows_.begin(), windows_.end(), window));
- OnWindowRemoved(window);
-}
-
-bool Workspace::Contains(aura::Window* window) const {
- return std::find(windows_.begin(), windows_.end(), window) != windows_.end();
-}
-
-void Workspace::Activate() {
- workspace_manager_->SetActiveWorkspace(this);
-}
-
-void Workspace::SetWindowBounds(aura::Window* window, const gfx::Rect& bounds) {
- workspace_manager_->SetWindowBounds(window, bounds);
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/workspace/workspace.h b/ash/wm/workspace/workspace.h
deleted file mode 100644
index e212e55..0000000
--- a/ash/wm/workspace/workspace.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// 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_WORKSPACE_H_
-#define ASH_WM_WORKSPACE_H_
-
-#include <vector>
-
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "ui/gfx/rect.h"
-
-namespace aura {
-class Window;
-}
-
-namespace ash {
-namespace internal {
-
-class WorkspaceManager;
-
-// A workspace contains a number of windows. The number of windows a Workspace
-// may contain is dictated by the type. Typically only one workspace is visible
-// at a time. The exception to that is when overview mode is active.
-class ASH_EXPORT Workspace {
- public:
- // Type of workspace. The type of workspace dictates the types of windows the
- // workspace can contain.
- enum Type {
- // The workspace holds a single maximized or full screen window.
- TYPE_MAXIMIZED,
-
- // Workspace contains non-maximized windows.
- TYPE_MANAGED,
- };
-
- Workspace(WorkspaceManager* manager, Type type);
- virtual ~Workspace();
-
- // Returns the type of workspace that can contain |window|.
- static Type TypeForWindow(aura::Window* window);
-
- Type type() const { return type_; }
-
- // Returns true if this workspace has no windows.
- bool is_empty() const { return windows_.empty(); }
- size_t num_windows() const { return windows_.size(); }
- const std::vector<aura::Window*>& windows() const { return windows_; }
-
- // Adds the |window| at the position after the window |after|. It
- // inserts at the end if |after| is NULL. Return true if the
- // |window| was successfully added to this workspace, or false if it
- // failed.
- bool AddWindowAfter(aura::Window* window, aura::Window* after);
-
- // Removes |window| from this workspace.
- void RemoveWindow(aura::Window* window);
-
- // Return true if this workspace has |window|.
- bool Contains(aura::Window* window) const;
-
- // Activates this workspace.
- void Activate();
-
- protected:
- // Sets the bounds of the specified window.
- void SetWindowBounds(aura::Window* window, const gfx::Rect& bounds);
-
- // Returns true if the given |window| can be added to this workspace.
- virtual bool CanAdd(aura::Window* window) const = 0;
-
- // Invoked from AddWindowAfter().
- virtual void OnWindowAddedAfter(aura::Window* window,
- aura::Window* after) = 0;
-
- // Invoked from RemoveWindow().
- virtual void OnWindowRemoved(aura::Window* window) = 0;
-
- private:
- const Type type_;
-
- WorkspaceManager* workspace_manager_;
-
- // Windows in the workspace in layout order.
- std::vector<aura::Window*> windows_;
-
- DISALLOW_COPY_AND_ASSIGN(Workspace);
-};
-
-typedef std::vector<Workspace*> Workspaces;
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_WORKSPACE_H_
diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc
index f6ea15f..2a352f9 100644
--- a/ash/wm/workspace/workspace_event_handler_unittest.cc
+++ b/ash/wm/workspace/workspace_event_handler_unittest.cc
@@ -9,7 +9,6 @@
#include "ash/wm/property_util.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller_test_helper.h"
-#include "ash/wm/workspace/workspace_manager.h"
#include "ash/wm/workspace_controller.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_window_delegate.h"
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
deleted file mode 100644
index 2cf5e6e..0000000
--- a/ash/wm/workspace/workspace_layout_manager.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// 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/workspace/workspace_layout_manager.h"
-
-#include "ash/screen_ash.h"
-#include "ash/wm/window_properties.h"
-#include "ash/wm/window_util.h"
-#include "ash/wm/workspace/workspace.h"
-#include "ash/wm/workspace/workspace_manager.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_observer.h"
-#include "ui/base/events/event.h"
-#include "ui/base/ui_base_types.h"
-#include "ui/gfx/rect.h"
-
-namespace ash {
-namespace internal {
-
-WorkspaceLayoutManager::WorkspaceLayoutManager(
- aura::RootWindow* root_window,
- WorkspaceManager* workspace_manager)
- : BaseLayoutManager(root_window),
- workspace_manager_(workspace_manager) {
-}
-
-WorkspaceLayoutManager::~WorkspaceLayoutManager() {
-}
-
-void WorkspaceLayoutManager::OnWindowResized() {
- // Workspace is updated via OnRootWindowResized.
-}
-
-void WorkspaceLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
- BaseLayoutManager::OnWindowAddedToLayout(child);
- if (!workspace_manager_->ShouldManageWindow(child)) {
- if (child->IsVisible())
- workspace_manager_->UpdateShelfVisibility();
- return;
- }
-
- if (child->IsVisible())
- workspace_manager_->AddWindow(child);
-}
-
-void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
- workspace_manager_->RemoveWindow(child);
- BaseLayoutManager::OnWillRemoveWindowFromLayout(child);
-}
-
-void WorkspaceLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
- workspace_manager_->UpdateShelfVisibility();
- BaseLayoutManager::OnWindowRemovedFromLayout(child);
-}
-
-void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(
- aura::Window* child,
- bool visible) {
- BaseLayoutManager::OnChildWindowVisibilityChanged(child, visible);
- if (!workspace_manager_->ShouldManageWindow(child)) {
- workspace_manager_->UpdateShelfVisibility();
- return;
- }
-
- if (visible)
- workspace_manager_->AddWindow(child);
- else
- workspace_manager_->RemoveWindow(child);
-}
-
-void WorkspaceLayoutManager::SetChildBounds(
- aura::Window* child,
- const gfx::Rect& requested_bounds) {
- if (GetTrackedByWorkspace(child))
- BaseLayoutManager::SetChildBounds(child, requested_bounds);
- else
- SetChildBoundsDirect(child, requested_bounds);
- workspace_manager_->UpdateShelfVisibility();
-}
-
-void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window,
- const void* key,
- intptr_t old) {
- BaseLayoutManager::OnWindowPropertyChanged(window, key, old);
- if (key == ash::internal::kWindowTrackedByWorkspaceKey &&
- ash::GetTrackedByWorkspace(window)) {
- // We currently don't need to support transitioning from true to false, so
- // we ignore it.
- workspace_manager_->AddWindow(window);
- }
-}
-
-void WorkspaceLayoutManager::ShowStateChanged(
- aura::Window* window,
- ui::WindowShowState last_show_state) {
- if (workspace_manager_->ShouldManageWindow(window)) {
- if (wm::IsWindowMinimized(window)) {
- workspace_manager_->RemoveWindow(window);
- } else if ((window->TargetVisibility() ||
- last_show_state == ui::SHOW_STATE_MINIMIZED) &&
- !workspace_manager_->Contains(window)) {
- workspace_manager_->AddWindow(window);
- }
- }
- BaseLayoutManager::ShowStateChanged(window, last_show_state);
- workspace_manager_->ShowStateChanged(window);
- // As BaseLayoutManager::ShowStateChanged() may change the visibility of the
- // window we need to invoke UpdateShelfVisibility() after ShowStateChanged().
- workspace_manager_->UpdateShelfVisibility();
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/workspace/workspace_layout_manager.h b/ash/wm/workspace/workspace_layout_manager.h
deleted file mode 100644
index 6d1d461..0000000
--- a/ash/wm/workspace/workspace_layout_manager.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// 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_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
-#define ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
-
-#include "ash/wm/base_layout_manager.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ui/aura/layout_manager.h"
-#include "ui/aura/window_observer.h"
-
-namespace aura {
-class RootWindow;
-class Window;
-}
-
-namespace gfx {
-class Rect;
-}
-
-namespace ash {
-namespace internal {
-
-class WorkspaceManager;
-
-// LayoutManager for top level windows when WorkspaceManager is enabled.
-class ASH_EXPORT WorkspaceLayoutManager : public BaseLayoutManager {
- public:
- WorkspaceLayoutManager(aura::RootWindow* root_window,
- WorkspaceManager* workspace_manager);
- virtual ~WorkspaceLayoutManager();
-
- // Returns the workspace manager for this container.
- WorkspaceManager* workspace_manager() {
- return workspace_manager_;
- }
-
- // Overridden from BaseLayoutManager:
- virtual void OnWindowResized() OVERRIDE;
- virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
- virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
- virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
- virtual void OnChildWindowVisibilityChanged(aura::Window* child,
- bool visibile) OVERRIDE;
- virtual void SetChildBounds(aura::Window* child,
- const gfx::Rect& requested_bounds) OVERRIDE;
-
- // Overriden from aura::WindowObserver:
- virtual void OnWindowPropertyChanged(aura::Window* window,
- const void* key,
- intptr_t old) OVERRIDE;
- protected:
- virtual void ShowStateChanged(aura::Window* window,
- ui::WindowShowState last_show_state) OVERRIDE;
-
- private:
- // Owned by WorkspaceController.
- WorkspaceManager* workspace_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
diff --git a/ash/wm/workspace/workspace_layout_manager2_unittest.cc b/ash/wm/workspace/workspace_layout_manager2_unittest.cc
index 59cab50..b5b8abd 100644
--- a/ash/wm/workspace/workspace_layout_manager2_unittest.cc
+++ b/ash/wm/workspace/workspace_layout_manager2_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/wm/workspace/workspace_layout_manager.h"
+#include "ash/wm/workspace/workspace_layout_manager2.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc
deleted file mode 100644
index ca87dc7..0000000
--- a/ash/wm/workspace/workspace_manager.cc
+++ /dev/null
@@ -1,368 +0,0 @@
-// 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/workspace/workspace_manager.h"
-
-#include <algorithm>
-
-#include "ash/screen_ash.h"
-#include "ash/shell.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/shelf_layout_manager.h"
-#include "ash/wm/window_animations.h"
-#include "ash/wm/window_util.h"
-#include "ash/wm/workspace/managed_workspace.h"
-#include "ash/wm/workspace/maximized_workspace.h"
-#include "base/auto_reset.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/env.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/compositor/layer_animator.h"
-#include "ui/compositor/scoped_layer_animation_settings.h"
-#include "ui/gfx/screen.h"
-#include "ui/gfx/transform.h"
-
-namespace {
-
-// Returns a list of all the windows with layers in |result|. Optionally
-// ignores the window |ignore_window|.
-void BuildWindowList(const std::vector<aura::Window*>& windows,
- aura::Window* ignore_window,
- std::vector<aura::Window*>* result) {
- for (size_t i = 0; i < windows.size(); ++i) {
- if (windows[i] == ignore_window)
- continue;
- if (windows[i]->layer())
- result->push_back(windows[i]);
- BuildWindowList(windows[i]->transient_children(), ignore_window, result);
- }
-}
-
-}
-
-namespace ash {
-namespace internal {
-
-////////////////////////////////////////////////////////////////////////////////
-// WindowManager, public:
-
-WorkspaceManager::WorkspaceManager(aura::Window* contents_view)
- : contents_view_(contents_view),
- active_workspace_(NULL),
- maximize_restore_window_(NULL),
- grid_size_(0),
- shelf_(NULL) {
- DCHECK(contents_view);
-}
-
-WorkspaceManager::~WorkspaceManager() {
- std::vector<Workspace*> copy_to_delete(workspaces_);
- STLDeleteElements(&copy_to_delete);
-}
-
-// static
-bool WorkspaceManager::ShouldManageWindow(aura::Window* window) {
- return window->type() == aura::client::WINDOW_TYPE_NORMAL &&
- !window->transient_parent() &&
- ash::GetTrackedByWorkspace(window) &&
- (!ash::GetPersistsAcrossAllWorkspaces(window) ||
- wm::IsWindowMaximized(window));
-}
-
-bool WorkspaceManager::Contains(aura::Window* window) const {
- return FindBy(window) != NULL;
-}
-
-void WorkspaceManager::AddWindow(aura::Window* window) {
- DCHECK(ShouldManageWindow(window));
-
- Workspace* current_workspace = FindBy(window);
- if (current_workspace) {
- // Already know about this window. Make sure the workspace is active.
- if (active_workspace_ != current_workspace) {
- if (active_workspace_)
- window->layer()->GetAnimator()->StopAnimating();
- current_workspace->Activate();
- }
- window->Show();
- UpdateShelfVisibility();
- return;
- }
-
- Workspace* workspace = NULL;
- Workspace::Type type_for_window = Workspace::TypeForWindow(window);
- switch (type_for_window) {
- case Workspace::TYPE_MANAGED:
- // All normal windows go in the same workspace.
- workspace = GetManagedWorkspace();
- break;
-
- case Workspace::TYPE_MAXIMIZED:
- // All maximized windows go in their own workspace.
- break;
- }
-
- if (!workspace)
- workspace = CreateWorkspace(type_for_window);
- workspace->AddWindowAfter(window, NULL);
- workspace->Activate();
- UpdateShelfVisibility();
-}
-
-void WorkspaceManager::RemoveWindow(aura::Window* window) {
- Workspace* workspace = FindBy(window);
- if (!workspace)
- return;
- workspace->RemoveWindow(window);
- CleanupWorkspace(workspace);
-}
-
-void WorkspaceManager::UpdateShelfVisibility() {
- if (shelf_)
- shelf_->UpdateVisibilityState();
-}
-
-void WorkspaceManager::ShowStateChanged(aura::Window* window) {
- Workspace* workspace = FindBy(window);
- if (!workspace)
- return;
- if (!ShouldManageWindow(window)) {
- RemoveWindow(window);
- } else {
- Workspace::Type old_type = workspace->type();
- Workspace::Type new_type = Workspace::TypeForWindow(window);
- if (new_type != old_type)
- OnTypeOfWorkspacedNeededChanged(window);
- }
- UpdateShelfVisibility();
-}
-
-bool WorkspaceManager::IsInMaximizedMode() const {
- return active_workspace_ &&
- active_workspace_->type() == Workspace::TYPE_MAXIMIZED;
-}
-
-WorkspaceWindowState WorkspaceManager::GetWindowState() const {
- if (!shelf_ || !active_workspace_)
- return WORKSPACE_WINDOW_STATE_DEFAULT;
-
- // TODO: this code needs to be made multi-display aware.
- gfx::Rect shelf_bounds(shelf_->GetIdealBounds());
- const aura::Window::Windows& windows(contents_view_->children());
- bool window_overlaps_launcher = false;
- bool has_maximized_window = false;
- for (aura::Window::Windows::const_iterator i = windows.begin();
- i != windows.end(); ++i) {
- gfx::Rect b = (*i)->bounds();
- if (GetIgnoredByShelf(*i))
- continue;
- ui::Layer* layer = (*i)->layer();
- if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f)
- continue;
- if (wm::IsWindowMaximized(*i)) {
- // An untracked window may still be fullscreen so we keep iterating when
- // we hit a maximized window.
- has_maximized_window = true;
- } else if (wm::IsWindowFullscreen(*i)) {
- return WORKSPACE_WINDOW_STATE_FULL_SCREEN;
- }
- if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds))
- window_overlaps_launcher = true;
- }
- if (has_maximized_window)
- return WORKSPACE_WINDOW_STATE_MAXIMIZED;
-
- return window_overlaps_launcher ?
- WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF :
- WORKSPACE_WINDOW_STATE_DEFAULT;
-}
-
-void WorkspaceManager::SetShelf(ShelfLayoutManager* shelf) {
- shelf_ = shelf;
-}
-
-void WorkspaceManager::SetActiveWorkspaceByWindow(aura::Window* window) {
- Workspace* workspace = FindBy(window);
- if (workspace)
- workspace->Activate();
-}
-
-aura::Window* WorkspaceManager::GetParentForNewWindow(aura::Window* window) {
- return contents_view_;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// WorkspaceManager, private:
-
-void WorkspaceManager::AddWorkspace(Workspace* workspace) {
- DCHECK(std::find(workspaces_.begin(), workspaces_.end(),
- workspace) == workspaces_.end());
- if (active_workspace_) {
- // New workspaces go right after current workspace.
- Workspaces::iterator i = std::find(workspaces_.begin(), workspaces_.end(),
- active_workspace_);
- workspaces_.insert(++i, workspace);
- } else {
- workspaces_.push_back(workspace);
- }
-}
-
-void WorkspaceManager::RemoveWorkspace(Workspace* workspace) {
- Workspaces::iterator i = std::find(workspaces_.begin(),
- workspaces_.end(),
- workspace);
- DCHECK(i != workspaces_.end());
- i = workspaces_.erase(i);
- if (active_workspace_ == workspace) {
- // TODO: need mru order.
- if (i != workspaces_.end())
- SetActiveWorkspace(*i);
- else if (!workspaces_.empty())
- SetActiveWorkspace(workspaces_.back());
- else
- active_workspace_ = NULL;
- }
-}
-
-void WorkspaceManager::SetVisibilityOfWorkspaceWindows(
- ash::internal::Workspace* workspace,
- AnimateChangeType change_type,
- bool value) {
- std::vector<aura::Window*> children;
- BuildWindowList(workspace->windows(), maximize_restore_window_, &children);
- SetWindowLayerVisibility(children, change_type, value);
-}
-
-void WorkspaceManager::SetWindowLayerVisibility(
- const std::vector<aura::Window*>& windows,
- AnimateChangeType change_type,
- bool value) {
- for (size_t i = 0; i < windows.size(); ++i) {
- ui::Layer* layer = windows[i]->layer();
- // Only show the layer for windows that want to be visible.
- if (layer && (!value || windows[i]->TargetVisibility())) {
- bool animation_disabled =
- windows[i]->GetProperty(aura::client::kAnimationsDisabledKey);
- WindowVisibilityAnimationType animation_type =
- GetWindowVisibilityAnimationType(windows[i]);
- windows[i]->SetProperty(aura::client::kAnimationsDisabledKey,
- change_type == DONT_ANIMATE);
- bool update_layer = true;
- if (change_type == ANIMATE) {
- ash::SetWindowVisibilityAnimationType(
- windows[i],
- value ? ash::WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_SHOW :
- ash::WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_HIDE);
- if (ash::internal::AnimateOnChildWindowVisibilityChanged(
- windows[i], value))
- update_layer = false;
- }
- if (update_layer)
- layer->SetVisible(value);
- // Reset the animation type so it isn't used in a future hide/show.
- ash::SetWindowVisibilityAnimationType(
- windows[i], animation_type);
- windows[i]->SetProperty(aura::client::kAnimationsDisabledKey,
- animation_disabled);
- }
- }
-}
-
-Workspace* WorkspaceManager::GetActiveWorkspace() const {
- return active_workspace_;
-}
-
-Workspace* WorkspaceManager::FindBy(aura::Window* window) const {
- int index = GetWorkspaceIndexContaining(window);
- return index < 0 ? NULL : workspaces_[index];
-}
-
-void WorkspaceManager::SetActiveWorkspace(Workspace* workspace) {
- if (active_workspace_ == workspace)
- return;
- DCHECK(std::find(workspaces_.begin(), workspaces_.end(),
- workspace) != workspaces_.end());
- if (active_workspace_)
- SetVisibilityOfWorkspaceWindows(active_workspace_, ANIMATE, false);
- Workspace* last_active = active_workspace_;
- active_workspace_ = workspace;
- if (active_workspace_) {
- SetVisibilityOfWorkspaceWindows(active_workspace_,
- last_active ? ANIMATE : DONT_ANIMATE, true);
- UpdateShelfVisibility();
- }
-}
-
-// Returns the index of the workspace that contains the |window|.
-int WorkspaceManager::GetWorkspaceIndexContaining(aura::Window* window) const {
- for (Workspaces::const_iterator i = workspaces_.begin();
- i != workspaces_.end();
- ++i) {
- if ((*i)->Contains(window))
- return i - workspaces_.begin();
- }
- return -1;
-}
-
-void WorkspaceManager::SetWindowBounds(aura::Window* window,
- const gfx::Rect& bounds) {
- window->SetBounds(bounds);
-}
-
-void WorkspaceManager::OnTypeOfWorkspacedNeededChanged(aura::Window* window) {
- DCHECK(ShouldManageWindow(window));
- Workspace* current_workspace = FindBy(window);
- DCHECK(current_workspace);
- Workspace* new_workspace = NULL;
- if (Workspace::TypeForWindow(window) == Workspace::TYPE_MAXIMIZED) {
- // Unmaximized -> maximized; create a new workspace.
- current_workspace->RemoveWindow(window);
- new_workspace = CreateWorkspace(Workspace::TYPE_MAXIMIZED);
- new_workspace->AddWindowAfter(window, NULL);
- } else {
- // Maximized -> unmaximized; move window to unmaximized workspace.
- new_workspace = GetManagedWorkspace();
- current_workspace->RemoveWindow(window);
- if (!new_workspace)
- new_workspace = CreateWorkspace(Workspace::TYPE_MANAGED);
- new_workspace->AddWindowAfter(window, NULL);
- }
- maximize_restore_window_ = window;
- SetActiveWorkspace(new_workspace);
- maximize_restore_window_ = NULL;
- // Delete at the end so that we don't attempt to switch to another
- // workspace in RemoveWorkspace().
- CleanupWorkspace(current_workspace);
-}
-
-Workspace* WorkspaceManager::GetManagedWorkspace() {
- for (size_t i = 0; i < workspaces_.size(); ++i) {
- if (workspaces_[i]->type() == Workspace::TYPE_MANAGED)
- return workspaces_[i];
- }
- return NULL;
-}
-
-Workspace* WorkspaceManager::CreateWorkspace(Workspace::Type type) {
- Workspace* workspace = NULL;
- if (type == Workspace::TYPE_MAXIMIZED)
- workspace = new MaximizedWorkspace(this);
- else
- workspace = new ManagedWorkspace(this);
- AddWorkspace(workspace);
- return workspace;
-}
-
-void WorkspaceManager::CleanupWorkspace(Workspace* workspace) {
- if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty())
- delete workspace;
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h
deleted file mode 100644
index 533a055..0000000
--- a/ash/wm/workspace/workspace_manager.h
+++ /dev/null
@@ -1,145 +0,0 @@
-// 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_WORKSPACE_WORKSPACE_MANAGER_H_
-#define ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_
-
-#include <vector>
-
-#include "ash/ash_export.h"
-#include "ash/wm/workspace/base_workspace_manager.h"
-#include "ash/wm/workspace/workspace.h"
-#include "ash/wm/workspace/workspace_types.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ui/gfx/insets.h"
-#include "ui/gfx/size.h"
-
-namespace aura {
-class Window;
-}
-
-namespace gfx {
-class Point;
-class Rect;
-}
-
-namespace ash {
-namespace internal {
-
-class ShelfLayoutManager;
-class WorkspaceManagerTest;
-
-// WorkspaceManager manages multiple workspaces in the desktop.
-class ASH_EXPORT WorkspaceManager : public BaseWorkspaceManager {
- public:
- explicit WorkspaceManager(aura::Window* viewport);
- virtual ~WorkspaceManager();
-
- // Returns true if |window| should be managed by the WorkspaceManager. Use
- // Contains() to test if the Window is currently managed by WorkspaceManager.
- static bool ShouldManageWindow(aura::Window* window);
-
- // Returns true if |window| has been added to this WorkspaceManager.
- bool Contains(aura::Window* window) const;
-
- // Adds/removes a window creating/destroying workspace as necessary.
- void AddWindow(aura::Window* window);
- void RemoveWindow(aura::Window* window);
-
- // Returns the Window this WorkspaceManager controls.
- aura::Window* contents_view() { return contents_view_; }
-
- // Updates the visibility and whether any windows overlap the shelf.
- void UpdateShelfVisibility();
-
- // Invoked when the show state of the specified window changes.
- void ShowStateChanged(aura::Window* window);
-
- // BaseWorkspaceManager overrides:
- virtual bool IsInMaximizedMode() const OVERRIDE;
- virtual WorkspaceWindowState GetWindowState() const OVERRIDE;
- virtual void SetShelf(ShelfLayoutManager* shelf) OVERRIDE;
- virtual void SetActiveWorkspaceByWindow(aura::Window* window) OVERRIDE;
- virtual aura::Window* GetParentForNewWindow(aura::Window* window) OVERRIDE;
- virtual void DoInitialAnimation() OVERRIDE {}
-
- private:
- // Enumeration of whether windows should animate or not.
- enum AnimateChangeType {
- ANIMATE,
- DONT_ANIMATE
- };
-
- friend class Workspace;
- friend class WorkspaceManagerTest;
-
- void AddWorkspace(Workspace* workspace);
- void RemoveWorkspace(Workspace* workspace);
-
- // Sets the visibility of the windows in |workspace|.
- void SetVisibilityOfWorkspaceWindows(Workspace* workspace,
- AnimateChangeType change_type,
- bool value);
-
- // Implementation of SetVisibilityOfWorkspaceWindows().
- void SetWindowLayerVisibility(const std::vector<aura::Window*>& windows,
- AnimateChangeType change_type,
- bool value);
-
- // Returns the active workspace.
- Workspace* GetActiveWorkspace() const;
-
- // Returns the workspace that contanis the |window|.
- Workspace* FindBy(aura::Window* window) const;
-
- // Sets the active workspace.
- void SetActiveWorkspace(Workspace* workspace);
-
- // Returns the bounds of the work area.
- gfx::Rect GetWorkAreaBounds() const;
-
- // Returns the index of the workspace that contains the |window|.
- int GetWorkspaceIndexContaining(aura::Window* window) const;
-
- // Sets the bounds of |window|. This sets |ignored_window_| to |window| so
- // that the bounds change is allowed through.
- void SetWindowBounds(aura::Window* window, const gfx::Rect& bounds);
-
- // Invoked when the type of workspace needed for |window| changes.
- void OnTypeOfWorkspacedNeededChanged(aura::Window* window);
-
- // Returns the Workspace whose type is TYPE_MANAGED, or NULL if there isn't
- // one.
- Workspace* GetManagedWorkspace();
-
- // Creates a new workspace of the specified type.
- Workspace* CreateWorkspace(Workspace::Type type);
-
- // Deletes workspaces of TYPE_MAXIMIZED when they become empty.
- void CleanupWorkspace(Workspace* workspace);
-
- aura::Window* contents_view_;
-
- Workspace* active_workspace_;
-
- std::vector<Workspace*> workspaces_;
-
- // Window being maximized or restored during a workspace type change.
- // It has its own animation and is ignored by workspace show/hide animations.
- aura::Window* maximize_restore_window_;
-
- // See description above setter.
- int grid_size_;
-
- // Owned by the Shell container window LauncherContainer. May be NULL.
- ShelfLayoutManager* shelf_;
-
- DISALLOW_COPY_AND_ASSIGN(WorkspaceManager);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_
diff --git a/ash/wm/workspace/workspace_manager2.cc b/ash/wm/workspace/workspace_manager2.cc
index 148ca71..68250c3 100644
--- a/ash/wm/workspace/workspace_manager2.cc
+++ b/ash/wm/workspace/workspace_manager2.cc
@@ -154,10 +154,6 @@ bool WorkspaceManager2::WillRestoreMaximized(Window* window) {
IsMaximizedState(window->GetProperty(internal::kRestoreShowStateKey));
}
-bool WorkspaceManager2::IsInMaximizedMode() const {
- return active_workspace_ && active_workspace_->is_maximized();
-}
-
WorkspaceWindowState WorkspaceManager2::GetWindowState() const {
if (!shelf_)
return WORKSPACE_WINDOW_STATE_DEFAULT;
diff --git a/ash/wm/workspace/workspace_manager2.h b/ash/wm/workspace/workspace_manager2.h
index a280e98..fae98f7 100644
--- a/ash/wm/workspace/workspace_manager2.h
+++ b/ash/wm/workspace/workspace_manager2.h
@@ -11,7 +11,7 @@
#include "ash/ash_export.h"
#include "ash/shell_observer.h"
-#include "ash/wm/workspace/base_workspace_manager.h"
+#include "ash/wm/workspace/workspace_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
@@ -51,9 +51,7 @@ class Workspace2;
// workspace for the desktop.
// Internally WorkspaceManager2 creates a Window for each Workspace. As windows
// are maximized and restored they are reparented to the right Window.
-class ASH_EXPORT WorkspaceManager2
- : public BaseWorkspaceManager,
- public ash::ShellObserver {
+class ASH_EXPORT WorkspaceManager2 : public ash::ShellObserver {
public:
explicit WorkspaceManager2(aura::Window* viewport);
virtual ~WorkspaceManager2();
@@ -67,13 +65,21 @@ class ASH_EXPORT WorkspaceManager2
// window.
static bool WillRestoreMaximized(aura::Window* window);
- // BaseWorkspaceManager overrides:
- virtual bool IsInMaximizedMode() const OVERRIDE;
- virtual WorkspaceWindowState GetWindowState() const OVERRIDE;
- virtual void SetShelf(ShelfLayoutManager* shelf) OVERRIDE;
- virtual void SetActiveWorkspaceByWindow(aura::Window* window) OVERRIDE;
- virtual aura::Window* GetParentForNewWindow(aura::Window* window) OVERRIDE;
- virtual void DoInitialAnimation() OVERRIDE;
+ // Returns the current window state.
+ WorkspaceWindowState GetWindowState() const;
+
+ void SetShelf(ShelfLayoutManager* shelf);
+
+ // Activates the workspace containing |window|. Does nothing if |window| is
+ // NULL or not contained in a workspace.
+ void SetActiveWorkspaceByWindow(aura::Window* window);
+
+ // Returns the parent for |window|. This is invoked from StackingController
+ // when a new Window is being added.
+ aura::Window* GetParentForNewWindow(aura::Window* window);
+
+ // Starts the animation that occurs on first login.
+ void DoInitialAnimation();
// ShellObserver overrides:
virtual void OnAppTerminating() OVERRIDE;
diff --git a/ash/wm/workspace/workspace_manager_unittest.cc b/ash/wm/workspace/workspace_manager_unittest.cc
deleted file mode 100644
index 2b4f08a..0000000
--- a/ash/wm/workspace/workspace_manager_unittest.cc
+++ /dev/null
@@ -1,741 +0,0 @@
-// 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/workspace/workspace_manager.h"
-
-#include "ash/ash_switches.h"
-#include "ash/screen_ash.h"
-#include "ash/shell.h"
-#include "ash/shell_window_ids.h"
-#include "ash/test/ash_test_base.h"
-#include "ash/wm/activation_controller.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/shelf_layout_manager.h"
-#include "ash/wm/window_util.h"
-#include "ash/wm/workspace/workspace.h"
-#include "ash/wm/workspace/workspace_layout_manager.h"
-#include "ash/wm/workspace_controller_test_helper.h"
-#include "base/command_line.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/test/event_generator.h"
-#include "ui/aura/window.h"
-#include "ui/base/ui_base_types.h"
-#include "ui/compositor/layer.h"
-#include "ui/gfx/screen.h"
-
-using aura::Window;
-
-namespace ash {
-namespace internal {
-
-namespace {
-
-bool GetWindowOverlapsShelf() {
- return Shell::GetInstance()->shelf()->window_overlaps_shelf();
-}
-
-} // namespace
-
-class WorkspaceManagerTest : public test::AshTestBase {
- public:
- WorkspaceManagerTest() : manager_(NULL) {}
- virtual ~WorkspaceManagerTest() {}
-
- aura::Window* CreateTestWindowUnparented() {
- aura::Window* window = new aura::Window(NULL);
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- window->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window->Init(ui::LAYER_TEXTURED);
- return window;
- }
-
- aura::Window* CreateTestWindow() {
- aura::Window* window = new aura::Window(NULL);
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- window->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window->Init(ui::LAYER_TEXTURED);
- window->SetParent(GetViewport());
- return window;
- }
-
- aura::Window* GetViewport() {
- return Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- kShellWindowId_DefaultContainer);
- }
-
- const std::vector<Workspace*>& workspaces() const {
- return manager_->workspaces_;
- }
-
- gfx::Rect GetFullscreenBounds(aura::Window* window) {
- return Shell::GetScreen()->GetDisplayNearestWindow(window).bounds();
- }
-
- Workspace* active_workspace() {
- return manager_->active_workspace_;
- }
-
- Workspace* FindBy(aura::Window* window) const {
- return manager_->FindBy(window);
- }
-
- // Overridden from AshTestBase:
- virtual void SetUp() OVERRIDE {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kAshDisableWorkspace2);
- test::AshTestBase::SetUp();
- WorkspaceControllerTestHelper workspace_helper(
- Shell::TestApi(Shell::GetInstance()).workspace_controller());
- manager_ = workspace_helper.workspace_manager();
- }
- virtual void TearDown() OVERRIDE {
- manager_ = NULL;
- test::AshTestBase::TearDown();
- }
-
- protected:
- WorkspaceManager* manager_;
-
- private:
- scoped_ptr<ActivationController> activation_controller_;
-
- DISALLOW_COPY_AND_ASSIGN(WorkspaceManagerTest);
-};
-
-// Assertions around adding a normal window.
-TEST_F(WorkspaceManagerTest, AddNormalWindowWhenEmpty) {
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->SetBounds(gfx::Rect(0, 0, 250, 251));
-
- ASSERT_TRUE(manager_->ShouldManageWindow(w1.get()));
- EXPECT_FALSE(FindBy(w1.get()));
-
- EXPECT_TRUE(GetRestoreBoundsInScreen(w1.get()) == NULL);
-
- w1->Show();
-
- EXPECT_TRUE(GetRestoreBoundsInScreen(w1.get()) == NULL);
-
- ASSERT_TRUE(w1->layer() != NULL);
- EXPECT_TRUE(w1->layer()->visible());
-
- EXPECT_EQ(250, w1->bounds().width());
- EXPECT_EQ(251, w1->bounds().height());
-
- // Should be 1 workspace, TYPE_NORNMAL with w1.
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- ASSERT_EQ(1u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
-}
-
-// Assertions around maximizing/unmaximizing.
-TEST_F(WorkspaceManagerTest, SingleMaximizeWindow) {
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->SetBounds(gfx::Rect(0, 0, 250, 251));
-
- ASSERT_TRUE(manager_->ShouldManageWindow(w1.get()));
-
- w1->Show();
-
- ASSERT_TRUE(w1->layer() != NULL);
- EXPECT_TRUE(w1->layer()->visible());
-
- EXPECT_EQ(250, w1->bounds().width());
- EXPECT_EQ(251, w1->bounds().height());
-
- // Maximize the window.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
-
- // Should be 2 workspaces, the second TYPE_MAXIMIZED with w1.
- ASSERT_EQ(2u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
- ASSERT_EQ(1u, workspaces()[1]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[1]->windows()[0]);
- EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).width(),
- w1->bounds().width());
- EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).height(),
- w1->bounds().height());
-
- // Restore the window.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
-
- // Should be 1 workspace, TYPE_MANAGED with w1.
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- ASSERT_EQ(1u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
- EXPECT_EQ(250, w1->bounds().width());
- EXPECT_EQ(251, w1->bounds().height());
-}
-
-// Assertions around closing the last window in a workspace.
-TEST_F(WorkspaceManagerTest, CloseLastWindowInWorkspace) {
- scoped_ptr<Window> w1(CreateTestWindow());
- scoped_ptr<Window> w2(CreateTestWindow());
- w1->SetBounds(gfx::Rect(0, 0, 250, 251));
- w1->Show();
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w2->Show();
-
- // Should be 2 workspaces, TYPE_NORMAL with w1, and TYPE_MAXIMIZED with w2.
- ASSERT_EQ(2u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- ASSERT_EQ(1u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
- ASSERT_EQ(1u, workspaces()[1]->windows().size());
- EXPECT_EQ(w2.get(), workspaces()[1]->windows()[0]);
- EXPECT_FALSE(w1->layer()->visible());
- EXPECT_TRUE(w2->layer()->visible());
- // TYPE_MAXIMIZED workspace should be active.
- EXPECT_EQ(workspaces()[1], active_workspace());
-
- // Close w2.
- w2.reset();
-
- // Should have one workspace, TYPE_NORMAL with w1.
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- ASSERT_EQ(1u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
- EXPECT_TRUE(w1->layer()->visible());
- EXPECT_EQ(workspaces()[0], active_workspace());
-}
-
-// Assertions around adding a maximized window when empty.
-TEST_F(WorkspaceManagerTest, AddMaximizedWindowWhenEmpty) {
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->SetBounds(gfx::Rect(0, 0, 250, 251));
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w1->Show();
-
- ASSERT_TRUE(w1->layer() != NULL);
- EXPECT_TRUE(w1->layer()->visible());
- gfx::Rect work_area(
- ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()));
- EXPECT_EQ(work_area.width(), w1->bounds().width());
- EXPECT_EQ(work_area.height(), w1->bounds().height());
-
- // Should be 1 workspace, TYPE_NORNMAL with w1.
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[0]->type());
- ASSERT_EQ(1u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
-}
-
-// Assertions around two windows and toggling one to be maximized.
-TEST_F(WorkspaceManagerTest, MaximizeWithNormalWindow) {
- scoped_ptr<Window> w1(CreateTestWindow());
- scoped_ptr<Window> w2(CreateTestWindow());
- w1->SetBounds(gfx::Rect(0, 0, 250, 251));
- w1->Show();
-
- ASSERT_TRUE(w1->layer() != NULL);
- EXPECT_TRUE(w1->layer()->visible());
-
- w2->SetBounds(gfx::Rect(0, 0, 50, 51));
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w2->Show();
-
- // Should now be two workspaces.
- ASSERT_EQ(2u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- ASSERT_EQ(1u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
- ASSERT_EQ(1u, workspaces()[1]->windows().size());
- EXPECT_EQ(w2.get(), workspaces()[1]->windows()[0]);
- ASSERT_TRUE(w1->layer() != NULL);
- EXPECT_FALSE(w1->layer()->visible());
- ASSERT_TRUE(w2->layer() != NULL);
- EXPECT_TRUE(w2->layer()->visible());
-
- gfx::Rect work_area(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()));
- EXPECT_EQ(work_area.width(), w2->bounds().width());
- EXPECT_EQ(work_area.height(), w2->bounds().height());
-
- // Restore w2, which should then go back to one workspace.
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- ASSERT_EQ(2u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
- EXPECT_EQ(w2.get(), workspaces()[0]->windows()[1]);
- EXPECT_EQ(50, w2->bounds().width());
- EXPECT_EQ(51, w2->bounds().height());
- ASSERT_TRUE(w1->layer() != NULL);
- EXPECT_TRUE(w1->layer()->visible());
- ASSERT_TRUE(w2->layer() != NULL);
- EXPECT_TRUE(w2->layer()->visible());
-}
-
-// Assertions around two maximized windows.
-TEST_F(WorkspaceManagerTest, TwoMaximized) {
- scoped_ptr<Window> w1(CreateTestWindow());
- scoped_ptr<Window> w2(CreateTestWindow());
- w1->SetBounds(gfx::Rect(0, 0, 250, 251));
- w1->Show();
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
-
- w2->SetBounds(gfx::Rect(0, 0, 50, 51));
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w2->Show();
-
- // Should now be three workspaces.
- ASSERT_EQ(3u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
- ASSERT_EQ(1u, workspaces()[1]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[1]->windows()[0]);
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[2]->type());
- ASSERT_EQ(1u, workspaces()[2]->windows().size());
- EXPECT_EQ(w2.get(), workspaces()[2]->windows()[0]);
- ASSERT_TRUE(w1->layer() != NULL);
- EXPECT_FALSE(w1->layer()->visible());
- ASSERT_TRUE(w2->layer() != NULL);
- EXPECT_TRUE(w2->layer()->visible());
-}
-
-// Makes sure requests to change the bounds of a normal window go through.
-TEST_F(WorkspaceManagerTest, ChangeBoundsOfNormalWindow) {
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->Show();
-
- EXPECT_TRUE(manager_->ShouldManageWindow(w1.get()));
- // Setting the bounds should go through since the window is in the normal
- // workspace.
- w1->SetBounds(gfx::Rect(0, 0, 200, 500));
- EXPECT_EQ(200, w1->bounds().width());
- EXPECT_EQ(500, w1->bounds().height());
-}
-
-// Assertions around grid size.
-TEST_F(WorkspaceManagerTest, SnapToGrid) {
- // Verify snap to grid when bounds are set before parented.
- scoped_ptr<Window> w1(CreateTestWindowUnparented());
- w1->SetBounds(gfx::Rect(1, 6, 25, 30));
- w1->SetParent(GetViewport());
- // We are not aligning this anymore this way. When the window gets shown
- // the window is expected to be handled differently, but this cannot be
- // tested with this test. So the result of this test should be that the
- // bounds are exactly as passed in.
- EXPECT_EQ(gfx::Rect(1, 6, 25, 30), w1->bounds());
-}
-
-// Assertions around a fullscreen window.
-TEST_F(WorkspaceManagerTest, SingleFullscreenWindow) {
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->SetBounds(gfx::Rect(0, 0, 250, 251));
- // Make the window fullscreen.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
- w1->Show();
-
- // Should be 1 workspace, TYPE_MAXIMIZED with w1.
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[0]->type());
- ASSERT_EQ(1u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
- EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width());
- EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height());
-
- // Restore the window. Use SHOW_STATE_DEFAULT as that is what we'll end up
- // with when using views::Widget.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT);
- EXPECT_EQ("0,0 250x251", w1->bounds().ToString());
-
- // Should be 1 workspace, TYPE_MANAGED with w1.
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- ASSERT_EQ(1u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
- EXPECT_EQ(250, w1->bounds().width());
- EXPECT_EQ(251, w1->bounds().height());
-
- // Back to fullscreen.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
- ASSERT_EQ(2u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
- ASSERT_EQ(1u, workspaces()[1]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[1]->windows()[0]);
- EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width());
- EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height());
- ASSERT_TRUE(GetRestoreBoundsInScreen(w1.get()));
- EXPECT_EQ(gfx::Rect(0, 0, 250, 251), *GetRestoreBoundsInScreen(w1.get()));
-}
-
-// Makes sure switching workspaces doesn't show transient windows.
-TEST_F(WorkspaceManagerTest, DontShowTransientsOnSwitch) {
- scoped_ptr<Window> w1(CreateTestWindow());
- scoped_ptr<Window> w2(CreateTestWindow());
-
- w1->SetBounds(gfx::Rect(0, 0, 250, 251));
- w2->SetBounds(gfx::Rect(0, 0, 250, 251));
- w1->AddTransientChild(w2.get());
-
- w1->Show();
-
- scoped_ptr<Window> w3(CreateTestWindow());
- w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w3->Show();
-
- EXPECT_FALSE(w1->layer()->IsDrawn());
- EXPECT_FALSE(w2->layer()->IsDrawn());
- EXPECT_TRUE(w3->layer()->IsDrawn());
-
- w1->Show();
- EXPECT_TRUE(w1->layer()->IsDrawn());
- EXPECT_FALSE(w2->layer()->IsDrawn());
- EXPECT_FALSE(w3->layer()->IsDrawn());
-}
-
-// Assertions around minimizing a single window.
-TEST_F(WorkspaceManagerTest, MinimizeSingleWindow) {
- scoped_ptr<Window> w1(CreateTestWindow());
-
- w1->Show();
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
-
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_FALSE(w1->layer()->IsDrawn());
-
- // Show the window.
- w1->Show();
- EXPECT_TRUE(wm::IsWindowNormal(w1.get()));
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- EXPECT_TRUE(w1->layer()->IsDrawn());
-}
-
-// Assertions around minimizing a maximized window.
-TEST_F(WorkspaceManagerTest, MinimizeMaximizedWindow) {
- // Two windows, w1 normal, w2 maximized.
- scoped_ptr<Window> w1(CreateTestWindow());
- scoped_ptr<Window> w2(CreateTestWindow());
- w1->Show();
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w2->Show();
- ASSERT_EQ(2u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
-
- // Minimize w2.
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- EXPECT_TRUE(w1->layer()->IsDrawn());
- EXPECT_FALSE(w2->layer()->IsDrawn());
-
- // Show the window, which should trigger unminimizing.
- w2->Show();
- EXPECT_TRUE(wm::IsWindowMaximized(w2.get()));
- ASSERT_EQ(2u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
- EXPECT_FALSE(w1->layer()->IsDrawn());
- EXPECT_TRUE(w2->layer()->IsDrawn());
-
- // Make it active and minimize the window, which should hide the window and
- // activate another.
- wm::ActivateWindow(w2.get());
- EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
- EXPECT_FALSE(w2->layer()->IsDrawn());
- EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
-
- // Make the window normal.
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- ASSERT_EQ(1u, workspaces().size());
- EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
- ASSERT_EQ(2u, workspaces()[0]->windows().size());
- EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
- EXPECT_EQ(w2.get(), workspaces()[0]->windows()[1]);
- EXPECT_TRUE(w2->layer()->IsDrawn());
-}
-
-// Verifies ShelfLayoutManager's visibility/auto-hide state is correctly
-// updated.
-TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
- // Since ShelfLayoutManager queries for mouse location, move the mouse so
- // it isn't over the shelf.
- aura::test::EventGenerator generator(
- Shell::GetPrimaryRootWindow(), gfx::Point());
- generator.MoveMouseTo(0, 0);
-
- // Two windows, w1 normal, w2 maximized.
- scoped_ptr<Window> w1(CreateTestWindow());
- const gfx::Rect w1_bounds(0, 1, 101, 102);
- ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
- shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- const gfx::Rect touches_shelf_bounds(
- 0, shelf->GetIdealBounds().y() - 10, 101, 102);
- // Move |w1| to overlap the shelf.
- w1->SetBounds(touches_shelf_bounds);
- EXPECT_FALSE(GetWindowOverlapsShelf());
-
- // A visible ignored window should not trigger the overlap.
- scoped_ptr<Window> w_ignored(CreateTestWindow());
- w_ignored->SetBounds(touches_shelf_bounds);
- SetIgnoredByShelf(&(*w_ignored), true);
- w_ignored->Show();
- EXPECT_FALSE(GetWindowOverlapsShelf());
-
- // Make it visible, since visible shelf overlaps should be true.
- w1->Show();
- EXPECT_TRUE(GetWindowOverlapsShelf());
-
- wm::ActivateWindow(w1.get());
- w1->SetBounds(w1_bounds);
- w1->Show();
- wm::ActivateWindow(w1.get());
-
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
-
- // Maximize the window.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
-
- // Restore.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
-
- // Fullscreen.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
- EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
-
- // Normal.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
-
- // Maximize again.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
-
- // Minimize.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
-
- // Restore.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
-
- // Create another window, maximized.
- scoped_ptr<Window> w2(CreateTestWindow());
- w2->SetBounds(gfx::Rect(10, 11, 250, 251));
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w2->Show();
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
-
- // Switch to w1.
- w1->Show();
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
- EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(),
- w2->bounds().ToString());
-
- // Switch to w2.
- w2->Show();
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
- EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(),
- w2->bounds().ToString());
-}
-
-// Verifies persist across all workspaces.
-TEST_F(WorkspaceManagerTest, PersistAcrossAllWorkspaces) {
- // Create a maximized window.
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->Show();
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_TRUE(w1->layer()->IsDrawn());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, active_workspace()->type());
-
- // Create a window that persists across all workspaces, it should be visible
- // even while in a maximized workspace.
- scoped_ptr<Window> w2(CreateTestWindow());
- SetPersistsAcrossAllWorkspaces(
- w2.get(),
- WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
- w2->Show();
- wm::ActivateWindow(w2.get());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, active_workspace()->type());
- EXPECT_TRUE(std::find(active_workspace()->windows().begin(),
- active_workspace()->windows().end(), w2.get()) ==
- active_workspace()->windows().end());
- EXPECT_TRUE(w1->layer()->IsDrawn());
- EXPECT_TRUE(w2->layer()->IsDrawn());
-
- // Activate the maximized window, w1, ensure w2 is still visible.
- wm::ActivateWindow(w1.get());
- EXPECT_EQ(Workspace::TYPE_MAXIMIZED, active_workspace()->type());
- EXPECT_TRUE(w1->layer()->IsDrawn());
- EXPECT_TRUE(w2->layer()->IsDrawn());
-
- // Create another window (normal) and show/activate it. w1 (maximized window)
- // should hide, but w2 should still be visible since it persists across all
- // windows.
- scoped_ptr<Window> w3(CreateTestWindow());
- w3->Show();
- wm::ActivateWindow(w3.get());
- EXPECT_EQ(Workspace::TYPE_MANAGED, active_workspace()->type());
- EXPECT_FALSE(w1->layer()->IsDrawn());
- EXPECT_TRUE(w2->layer()->IsDrawn());
- EXPECT_TRUE(w3->layer()->IsDrawn());
-
- // Activate w2 again, shouldn't switch workspaces.
- wm::ActivateWindow(w2.get());
- EXPECT_EQ(Workspace::TYPE_MANAGED, active_workspace()->type());
- EXPECT_FALSE(w1->layer()->IsDrawn());
- EXPECT_TRUE(w2->layer()->IsDrawn());
- EXPECT_TRUE(w3->layer()->IsDrawn());
-}
-
-// Verifies Show()ing a minimized window that persists across all workspaces
-// unminimizes the window.
-TEST_F(WorkspaceManagerTest, ShowMinimizedPersistWindow) {
- // Create a window that persists across all workspaces.
- scoped_ptr<Window> w1(CreateTestWindow());
- SetPersistsAcrossAllWorkspaces(
- w1.get(),
- WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
- w1->Show();
- wm::ActivateWindow(w1.get());
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- EXPECT_FALSE(w1->IsVisible());
- w1->Show();
- EXPECT_TRUE(w1->IsVisible());
-}
-
-// Test that we report we're in the fullscreen state even if the fullscreen
-// window isn't being managed by us (http://crbug.com/123931).
-TEST_F(WorkspaceManagerTest, GetWindowStateWithUnmanagedFullscreenWindow) {
- ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
-
- // We need to create a regular window first so there's an active workspace.
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->Show();
-
- scoped_ptr<Window> w2(CreateTestWindow());
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
- SetPersistsAcrossAllWorkspaces(
- w2.get(),
- WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
- w2->Show();
-
- EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
- ASSERT_FALSE(manager_->ShouldManageWindow(w2.get()));
- EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN,
- manager_->GetWindowState());
-
- w2->Hide();
- EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
-
- w2->Show();
- EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
-
- w2.reset();
- EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
-}
-
-// Variant of GetWindowStateWithUnmanagedFullscreenWindow that uses a maximized
-// window rather than a normal window.
-TEST_F(WorkspaceManagerTest,
- GetWindowStateWithUnmanagedFullscreenWindowWithMaximized) {
- ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
-
- // Make the first window maximized.
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w1->Show();
-
- scoped_ptr<Window> w2(CreateTestWindow());
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
- SetPersistsAcrossAllWorkspaces(
- w2.get(),
- WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
- w2->Show();
-
- // Even though auto-hide behavior is NEVER full-screen windows cause the shelf
- // to hide.
- EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
- ASSERT_FALSE(manager_->ShouldManageWindow(w2.get()));
- EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN,
- manager_->GetWindowState());
-
- w2->Hide();
- EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
-
- w2->Show();
- EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
- EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN,
- manager_->GetWindowState());
-
- w2.reset();
- EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
-}
-
-// Makes sure that if animations are disabled on a window they don't get reset
-// when switching workspaces.
-TEST_F(WorkspaceManagerTest, DontResetAnimation) {
- scoped_ptr<Window> w1(CreateTestWindow());
- scoped_ptr<Window> w2(CreateTestWindow());
-
- w1->Show();
- w1->SetProperty(aura::client::kAnimationsDisabledKey, true);
-
- w2->Show();
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_TRUE(w1->GetProperty(aura::client::kAnimationsDisabledKey));
-}
-
-// Verifies a window marked as persisting across all workspaces ends up in its
-// own workspace when maximized.
-TEST_F(WorkspaceManagerTest, MaximizeDontPersistEndsUpInOwnWorkspace) {
- scoped_ptr<Window> w1(CreateTestWindow());
-
- SetPersistsAcrossAllWorkspaces(
- w1.get(),
- WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
- w1->Show();
-
- // Shouldn't contain the window initially.
- EXPECT_FALSE(manager_->Contains(w1.get()));
-
- // Maximize should trigger containing the window.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_TRUE(manager_->Contains(w1.get()));
-
- // And resetting to normal should remove it.
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- EXPECT_FALSE(manager_->Contains(w1.get()));
-}
-
-// Verifies going from maximized to minimized sets the right state for painting
-// the background of the launcher.
-TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) {
- scoped_ptr<Window> w1(CreateTestWindow());
- w1->Show();
- wm::ActivateWindow(w1.get());
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- EXPECT_EQ(ShelfLayoutManager::VISIBLE,
- Shell::GetInstance()->shelf()->visibility_state());
- EXPECT_FALSE(Shell::GetInstance()->launcher()->paints_background());
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc
index 1a915ca..97caf1b 100644
--- a/ash/wm/workspace_controller.cc
+++ b/ash/wm/workspace_controller.cc
@@ -6,9 +6,6 @@
#include "ash/ash_switches.h"
#include "ash/wm/window_util.h"
-#include "ash/wm/workspace/workspace_event_handler.h"
-#include "ash/wm/workspace/workspace_layout_manager.h"
-#include "ash/wm/workspace/workspace_manager.h"
#include "ash/wm/workspace/workspace_manager2.h"
#include "base/command_line.h"
#include "ui/aura/client/activation_client.h"
@@ -20,41 +17,15 @@ namespace ash {
namespace internal {
WorkspaceController::WorkspaceController(aura::Window* viewport)
- : viewport_(viewport),
- layout_manager_(NULL),
- event_handler_(NULL) {
+ : viewport_(viewport) {
aura::RootWindow* root_window = viewport->GetRootWindow();
- if (IsWorkspace2Enabled()) {
- WorkspaceManager2* workspace_manager = new WorkspaceManager2(viewport);
- workspace_manager_.reset(workspace_manager);
- } else {
- WorkspaceManager* workspace_manager = new WorkspaceManager(viewport);
- workspace_manager_.reset(workspace_manager);
- layout_manager_ = new WorkspaceLayoutManager(
- root_window, workspace_manager);
- viewport->SetLayoutManager(layout_manager_);
- event_handler_ = new WorkspaceEventHandler(viewport);
- viewport->AddPreTargetHandler(event_handler_);
- }
+ workspace_manager_.reset(new WorkspaceManager2(viewport));
aura::client::GetActivationClient(root_window)->AddObserver(this);
}
WorkspaceController::~WorkspaceController() {
aura::client::GetActivationClient(viewport_->GetRootWindow())->
RemoveObserver(this);
- // WorkspaceLayoutManager may attempt to access state from us. Destroy it now.
- if (layout_manager_ && viewport_->layout_manager() == layout_manager_)
- viewport_->SetLayoutManager(NULL);
-}
-
-// static
-bool WorkspaceController::IsWorkspace2Enabled() {
- return !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshDisableWorkspace2);
-}
-
-bool WorkspaceController::IsInMaximizedMode() const {
- return workspace_manager_->IsInMaximizedMode();
}
WorkspaceWindowState WorkspaceController::GetWindowState() const {
diff --git a/ash/wm/workspace_controller.h b/ash/wm/workspace_controller.h
index f1d5994..44e0704 100644
--- a/ash/wm/workspace_controller.h
+++ b/ash/wm/workspace_controller.h
@@ -18,11 +18,10 @@ class Window;
namespace ash {
namespace internal {
-class BaseWorkspaceManager;
class ShelfLayoutManager;
class WorkspaceControllerTestHelper;
class WorkspaceEventHandler;
-class WorkspaceLayoutManager;
+class WorkspaceManager2;
// WorkspaceController acts as a central place that ties together all the
// various workspace pieces.
@@ -32,12 +31,6 @@ class ASH_EXPORT WorkspaceController
explicit WorkspaceController(aura::Window* viewport);
virtual ~WorkspaceController();
- // Returns true if Workspace2 is enabled.
- static bool IsWorkspace2Enabled();
-
- // Returns true if in maximized or fullscreen mode.
- bool IsInMaximizedMode() const;
-
// Returns the current window state.
WorkspaceWindowState GetWindowState() const;
@@ -61,16 +54,7 @@ class ASH_EXPORT WorkspaceController
aura::Window* viewport_;
- scoped_ptr<BaseWorkspaceManager> workspace_manager_;
-
- // TODO(sky): remove |layout_manager_| and |event_handler_| when Workspace2
- // is the default.
-
- // Owned by the window its attached to.
- WorkspaceLayoutManager* layout_manager_;
-
- // Owned by |viewport_|.
- WorkspaceEventHandler* event_handler_;
+ scoped_ptr<WorkspaceManager2> workspace_manager_;
DISALLOW_COPY_AND_ASSIGN(WorkspaceController);
};
diff --git a/ash/wm/workspace_controller_test_helper.cc b/ash/wm/workspace_controller_test_helper.cc
index 4e0d203..929b53a 100644
--- a/ash/wm/workspace_controller_test_helper.cc
+++ b/ash/wm/workspace_controller_test_helper.cc
@@ -20,12 +20,9 @@ WorkspaceControllerTestHelper::~WorkspaceControllerTestHelper() {
}
WorkspaceEventHandler* WorkspaceControllerTestHelper::GetEventHandler() {
- if (WorkspaceController::IsWorkspace2Enabled()) {
- ui::EventTarget::TestApi test_api(controller_->viewport_->children()[0]);
- return static_cast<WorkspaceEventHandler*>(
- test_api.pre_target_handlers().front());
- }
- return controller_->event_handler_;
+ ui::EventTarget::TestApi test_api(controller_->viewport_->children()[0]);
+ return static_cast<WorkspaceEventHandler*>(
+ test_api.pre_target_handlers().front());
}
MultiWindowResizeController*
diff --git a/ash/wm/workspace_controller_test_helper.h b/ash/wm/workspace_controller_test_helper.h
index ea5be9b..3a0ebe1 100644
--- a/ash/wm/workspace_controller_test_helper.h
+++ b/ash/wm/workspace_controller_test_helper.h
@@ -6,7 +6,6 @@
#define ASH_WM_WORKSPACE_CONTROLLER_TEST_HELPER_H_
#include "ash/wm/workspace_controller.h"
-#include "ash/wm/workspace/workspace_manager.h"
#include "ash/wm/workspace/workspace_manager2.h"
namespace ash {
@@ -22,13 +21,8 @@ class WorkspaceControllerTestHelper {
WorkspaceEventHandler* GetEventHandler();
MultiWindowResizeController* GetMultiWindowResizeController();
- WorkspaceManager* workspace_manager() {
- return static_cast<WorkspaceManager*>(
- controller_->workspace_manager_.get());
- }
WorkspaceManager2* workspace_manager2() {
- return static_cast<WorkspaceManager2*>(
- controller_->workspace_manager_.get());
+ return controller_->workspace_manager_.get();
}
private: