summaryrefslogtreecommitdiffstats
path: root/ash/wm
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-20 04:36:34 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-20 04:36:34 +0000
commita41b4e1e294a336a0e9589b432bb02d76121daca (patch)
tree5295194b4966e4a0e046ebfc32f0fba6da9504b7 /ash/wm
parent67ca0eb3295d44f3e347557152ac58b88c4efdc2 (diff)
downloadchromium_src-a41b4e1e294a336a0e9589b432bb02d76121daca.zip
chromium_src-a41b4e1e294a336a0e9589b432bb02d76121daca.tar.gz
chromium_src-a41b4e1e294a336a0e9589b432bb02d76121daca.tar.bz2
Rename WindowSettings to WindowState
Move window control methods from window_util.h to WindowState Removed property_util which is no longer necessary. BUG=272460 Review URL: https://chromiumcodereview.appspot.com/24108003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224288 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r--ash/wm/always_on_top_controller.cc1
-rw-r--r--ash/wm/ash_focus_rules.cc9
-rw-r--r--ash/wm/base_layout_manager.cc102
-rw-r--r--ash/wm/base_layout_manager.h17
-rw-r--r--ash/wm/base_layout_manager_unittest.cc28
-rw-r--r--ash/wm/caption_buttons/frame_caption_button_container_view.cc4
-rw-r--r--ash/wm/caption_buttons/frame_maximize_button.cc36
-rw-r--r--ash/wm/caption_buttons/frame_maximize_button_unittest.cc126
-rw-r--r--ash/wm/default_window_resizer.cc7
-rw-r--r--ash/wm/dock/docked_window_layout_manager.cc24
-rw-r--r--ash/wm/dock/docked_window_layout_manager.h5
-rw-r--r--ash/wm/dock/docked_window_layout_manager_unittest.cc16
-rw-r--r--ash/wm/dock/docked_window_resizer.cc35
-rw-r--r--ash/wm/dock/docked_window_resizer_unittest.cc11
-rw-r--r--ash/wm/drag_window_resizer.cc1
-rw-r--r--ash/wm/frame_painter.cc23
-rw-r--r--ash/wm/frame_painter.h4
-rw-r--r--ash/wm/frame_painter_unittest.cc10
-rw-r--r--ash/wm/gestures/system_pinch_handler.cc31
-rw-r--r--ash/wm/gestures/two_finger_drag_handler.cc19
-rw-r--r--ash/wm/overview/window_selector.cc4
-rw-r--r--ash/wm/panels/panel_layout_manager.cc5
-rw-r--r--ash/wm/panels/panel_window_resizer.cc13
-rw-r--r--ash/wm/panels/panel_window_resizer_unittest.cc29
-rw-r--r--ash/wm/property_util.cc48
-rw-r--r--ash/wm/property_util.h51
-rw-r--r--ash/wm/stacking_controller.cc4
-rw-r--r--ash/wm/stacking_controller_unittest.cc1
-rw-r--r--ash/wm/system_gesture_event_filter_unittest.cc20
-rw-r--r--ash/wm/toplevel_window_event_handler.cc33
-rw-r--r--ash/wm/toplevel_window_event_handler_unittest.cc39
-rw-r--r--ash/wm/user_activity_detector.cc1
-rw-r--r--ash/wm/video_detector.cc5
-rw-r--r--ash/wm/window_cycle_controller_unittest.cc27
-rw-r--r--ash/wm/window_properties.cc11
-rw-r--r--ash/wm/window_properties.h24
-rw-r--r--ash/wm/window_resizer.cc10
-rw-r--r--ash/wm/window_resizer.h8
-rw-r--r--ash/wm/window_settings.cc63
-rw-r--r--ash/wm/window_settings.h107
-rw-r--r--ash/wm/window_state.cc223
-rw-r--r--ash/wm/window_state.h216
-rw-r--r--ash/wm/window_util.cc84
-rw-r--r--ash/wm/window_util.h52
-rw-r--r--ash/wm/workspace/auto_window_management.cc46
-rw-r--r--ash/wm/workspace/colored_window_controller.cc4
-rw-r--r--ash/wm/workspace/snap_sizer.cc26
-rw-r--r--ash/wm/workspace/snap_sizer_unittest.cc33
-rw-r--r--ash/wm/workspace/workspace_event_handler.cc74
-rw-r--r--ash/wm/workspace/workspace_event_handler.h6
-rw-r--r--ash/wm/workspace/workspace_event_handler_unittest.cc34
-rw-r--r--ash/wm/workspace/workspace_layout_manager.cc137
-rw-r--r--ash/wm/workspace/workspace_layout_manager.h14
-rw-r--r--ash/wm/workspace/workspace_layout_manager_unittest.cc78
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc59
-rw-r--r--ash/wm/workspace/workspace_window_resizer.h6
-rw-r--r--ash/wm/workspace/workspace_window_resizer_unittest.cc34
-rw-r--r--ash/wm/workspace_controller.cc10
-rw-r--r--ash/wm/workspace_controller_unittest.cc167
59 files changed, 1228 insertions, 1087 deletions
diff --git a/ash/wm/always_on_top_controller.cc b/ash/wm/always_on_top_controller.cc
index f937e88..44776fe 100644
--- a/ash/wm/always_on_top_controller.cc
+++ b/ash/wm/always_on_top_controller.cc
@@ -6,7 +6,6 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
-#include "ash/wm/property_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
diff --git a/ash/wm/ash_focus_rules.cc b/ash/wm/ash_focus_rules.cc
index 851dbba..e6688d7 100644
--- a/ash/wm/ash_focus_rules.cc
+++ b/ash/wm/ash_focus_rules.cc
@@ -6,7 +6,7 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
-#include "ash/wm/window_util.h"
+#include "ash/wm/window_state.h"
#include "ui/aura/window.h"
namespace ash {
@@ -74,7 +74,7 @@ bool AshFocusRules::IsWindowConsideredVisibleForActivation(
// Minimized windows are hidden in their minimized state, but they can always
// be activated.
- if (wm::IsWindowMinimized(window))
+ if (wm::GetWindowState(window)->IsMinimized())
return true;
return window->TargetVisibility() && (window->parent()->id() ==
@@ -154,7 +154,10 @@ aura::Window* AshFocusRules::GetTopmostWindowToActivateInContainer(
container->children().rbegin();
i != container->children().rend();
++i) {
- if (*i != ignore && CanActivateWindow(*i) && !wm::IsWindowMinimized(*i))
+ WindowState* window_state = GetWindowState(*i);
+ if (*i != ignore &&
+ window_state->CanActivate() &&
+ !window_state->IsMinimized())
return *i;
}
return NULL;
diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc
index 236fb00..7685674 100644
--- a/ash/wm/base_layout_manager.cc
+++ b/ash/wm/base_layout_manager.cc
@@ -10,7 +10,7 @@
#include "ash/shell.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_window_resizer.h"
#include "ui/aura/client/activation_client.h"
@@ -69,17 +69,19 @@ void BaseLayoutManager::OnWindowResized() {
void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
windows_.insert(child);
child->AddObserver(this);
- wm::GetWindowSettings(child)->AddObserver(this);
+ wm::WindowState* window_state = wm::GetWindowState(child);
+ window_state->AddObserver(this);
+
// 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);
+ if (window_state->IsMaximizedOrFullscreen())
+ UpdateBoundsFromShowState(window_state);
}
void BaseLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
windows_.erase(child);
child->RemoveObserver(this);
- wm::GetWindowSettings(child)->RemoveObserver(this);
+ wm::GetWindowState(child)->RemoveObserver(this);
}
void BaseLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
@@ -87,21 +89,20 @@ void BaseLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
void BaseLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
bool visible) {
- if (visible && wm::IsWindowMinimized(child)) {
- // Attempting to show a minimized window. Unminimize it.
- child->SetProperty(aura::client::kShowStateKey,
- child->GetProperty(aura::client::kRestoreShowStateKey));
- child->ClearProperty(aura::client::kRestoreShowStateKey);
- }
+ wm::WindowState* window_state = wm::GetWindowState(child);
+ // Attempting to show a minimized window. Unminimize it.
+ if (visible && window_state->IsMinimized())
+ window_state->Unminimize();
}
void BaseLayoutManager::SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) {
gfx::Rect child_bounds(requested_bounds);
+ wm::WindowState* window_state = wm::GetWindowState(child);
// Some windows rely on this to set their initial bounds.
- if (wm::IsWindowMaximized(child))
+ if (window_state->IsMaximized())
child_bounds = ScreenAsh::GetMaximizedWindowBoundsInParent(child);
- else if (wm::IsWindowFullscreen(child))
+ else if (window_state->IsFullscreen())
child_bounds = ScreenAsh::GetDisplayBoundsInParent(child);
SetChildBoundsDirect(child, child_bounds);
}
@@ -116,17 +117,19 @@ void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window,
ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old);
ui::WindowShowState new_state =
window->GetProperty(aura::client::kShowStateKey);
+ wm::WindowState* window_state = wm::GetWindowState(window);
+
if (old_state != new_state && old_state != ui::SHOW_STATE_MINIMIZED &&
- !GetRestoreBoundsInScreen(window) &&
+ !window_state->HasRestoreBounds() &&
((new_state == ui::SHOW_STATE_MAXIMIZED &&
old_state != ui::SHOW_STATE_FULLSCREEN) ||
(new_state == ui::SHOW_STATE_FULLSCREEN &&
old_state != ui::SHOW_STATE_MAXIMIZED))) {
- SetRestoreBoundsInParent(window, window->bounds());
+ window_state->SetRestoreBoundsInParent(window->bounds());
}
- UpdateBoundsFromShowState(window);
- ShowStateChanged(window, old_state);
+ UpdateBoundsFromShowState(window_state);
+ ShowStateChanged(window_state, old_state);
}
}
@@ -149,10 +152,11 @@ void BaseLayoutManager::OnWindowBoundsChanged(aura::Window* window,
void BaseLayoutManager::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
- if (gained_active && wm::IsWindowMinimized(gained_active) &&
+ wm::WindowState* window_state = wm::GetWindowState(gained_active);
+ if (window_state && window_state->IsMinimized() &&
!gained_active->IsVisible()) {
gained_active->Show();
- DCHECK(!wm::IsWindowMinimized(gained_active));
+ DCHECK(!window_state->IsMinimized());
}
}
@@ -167,29 +171,30 @@ void BaseLayoutManager::OnDisplayWorkAreaInsetsChanged() {
//////////////////////////////////////////////////////////////////////////////
// BaseLayoutManager, protected:
-void BaseLayoutManager::ShowStateChanged(aura::Window* window,
- ui::WindowShowState last_show_state) {
- if (wm::IsWindowMinimized(window)) {
+void BaseLayoutManager::ShowStateChanged(
+ wm::WindowState* window_state,
+ ui::WindowShowState last_show_state) {
+ if (window_state->IsMinimized()) {
// Save the previous show state so that we can correctly restore it.
- window->SetProperty(aura::client::kRestoreShowStateKey, last_show_state);
+ window_state->window()->SetProperty(aura::client::kRestoreShowStateKey,
+ last_show_state);
views::corewm::SetWindowVisibilityAnimationType(
- window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
+ window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
// Hide the window.
- window->Hide();
+ window_state->window()->Hide();
// Activate another window.
- if (wm::IsActiveWindow(window))
- wm::DeactivateWindow(window);
- } else if ((window->TargetVisibility() ||
+ if (window_state->IsActive())
+ window_state->Deactivate();
+ } else if ((window_state->window()->TargetVisibility() ||
last_show_state == ui::SHOW_STATE_MINIMIZED) &&
- !window->layer()->visible()) {
+ !window_state->window()->layer()->visible()) {
// The layer may be hidden if the window was previously minimized. Make
// sure it's visible.
- window->Show();
+ window_state->window()->Show();
if (last_show_state == ui::SHOW_STATE_MINIMIZED &&
- !wm::IsWindowMaximized(window) &&
- !wm::IsWindowFullscreen(window)) {
- window->ClearProperty(internal::kWindowRestoresToRestoreBounds);
+ !window_state->IsMaximizedOrFullscreen()) {
+ window_state->set_always_restores_to_restore_bounds(false);
}
}
}
@@ -211,17 +216,18 @@ void BaseLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange(
for (WindowSet::const_iterator it = windows_.begin();
it != windows_.end();
++it) {
- AdjustWindowBoundsForWorkAreaChange(*it, reason);
+ AdjustWindowBoundsForWorkAreaChange(wm::GetWindowState(*it), reason);
}
}
void BaseLayoutManager::AdjustWindowBoundsForWorkAreaChange(
- aura::Window* window,
+ wm::WindowState* window_state,
AdjustWindowReason reason) {
- if (wm::IsWindowMaximized(window)) {
+ aura::Window* window = window_state->window();
+ if (window_state->IsMaximized()) {
SetChildBoundsDirect(
window, ScreenAsh::GetMaximizedWindowBoundsInParent(window));
- } else if (wm::IsWindowFullscreen(window)) {
+ } else if (window_state->IsFullscreen()) {
SetChildBoundsDirect(
window, ScreenAsh::GetDisplayBoundsInParent(window));
} else {
@@ -238,32 +244,32 @@ void BaseLayoutManager::AdjustWindowBoundsForWorkAreaChange(
//////////////////////////////////////////////////////////////////////////////
// BaseLayoutManager, private:
-void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) {
- switch (window->GetProperty(aura::client::kShowStateKey)) {
+void BaseLayoutManager::UpdateBoundsFromShowState(
+ wm::WindowState* window_state) {
+ aura::Window* window = window_state->window();
+ switch (window_state->GetShowState()) {
case ui::SHOW_STATE_DEFAULT:
case ui::SHOW_STATE_NORMAL: {
- const gfx::Rect* restore = GetRestoreBoundsInScreen(window);
- if (restore) {
- gfx::Rect bounds_in_parent =
- ScreenAsh::ConvertRectFromScreen(window->parent(), *restore);
+ if (window_state->HasRestoreBounds()) {
+ gfx::Rect bounds_in_parent = window_state->GetRestoreBoundsInParent();
SetChildBoundsDirect(window,
BoundsWithScreenEdgeVisible(window,
bounds_in_parent));
}
- ClearRestoreBounds(window);
+ window_state->ClearRestoreBounds();
break;
}
case ui::SHOW_STATE_MAXIMIZED:
- SetChildBoundsDirect(window,
- ScreenAsh::GetMaximizedWindowBoundsInParent(window));
+ SetChildBoundsDirect(
+ window, ScreenAsh::GetMaximizedWindowBoundsInParent(window));
break;
case ui::SHOW_STATE_FULLSCREEN:
// Don't animate the full-screen window transition.
// TODO(jamescook): Use animation here. Be sure the lock screen works.
- SetChildBoundsDirect(
- window, ScreenAsh::GetDisplayBoundsInParent(window));
+ SetChildBoundsDirect(window,
+ ScreenAsh::GetDisplayBoundsInParent(window));
break;
default:
diff --git a/ash/wm/base_layout_manager.h b/ash/wm/base_layout_manager.h
index 3156f14..f0deec6 100644
--- a/ash/wm/base_layout_manager.h
+++ b/ash/wm/base_layout_manager.h
@@ -9,7 +9,7 @@
#include "ash/ash_export.h"
#include "ash/shell_observer.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/aura/client/activation_change_observer.h"
@@ -24,6 +24,10 @@ class Window;
}
namespace ash {
+namespace wm {
+class WindowState;
+}
+
namespace internal {
// BaseLayoutManager is the simplest possible implementation for a window
@@ -36,7 +40,7 @@ class ASH_EXPORT BaseLayoutManager
public aura::WindowObserver,
public aura::client::ActivationChangeObserver,
public ShellObserver,
- public wm::WindowSettings::Observer {
+ public wm::WindowState::Observer {
public:
typedef std::set<aura::Window*> WindowSet;
@@ -84,7 +88,7 @@ class ASH_EXPORT BaseLayoutManager
};
// Invoked from OnWindowPropertyChanged() if |kShowStateKey| changes.
- virtual void ShowStateChanged(aura::Window* window,
+ virtual void ShowStateChanged(wm::WindowState* window_state,
ui::WindowShowState last_show_state);
// Adjusts the window's bounds when the display area changes for given
@@ -100,14 +104,15 @@ class ASH_EXPORT BaseLayoutManager
// Adjusts the sizes of the specific window in respond to a screen change or
// display-area size change.
- virtual void AdjustWindowBoundsForWorkAreaChange(aura::Window* window,
- AdjustWindowReason reason);
+ virtual void AdjustWindowBoundsForWorkAreaChange(
+ wm::WindowState* window_state,
+ AdjustWindowReason reason);
aura::RootWindow* root_window() { return root_window_; }
private:
// Update window bounds based on a change in show state.
- void UpdateBoundsFromShowState(aura::Window* window);
+ void UpdateBoundsFromShowState(wm::WindowState* controller);
// Set of windows we're listening to.
WindowSet windows_;
diff --git a/ash/wm/base_layout_manager_unittest.cc b/ash/wm/base_layout_manager_unittest.cc
index ea0f630..9f4b9ed 100644
--- a/ash/wm/base_layout_manager_unittest.cc
+++ b/ash/wm/base_layout_manager_unittest.cc
@@ -10,7 +10,7 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
-#include "ash/wm/property_util.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_window_resizer.h"
#include "base/basictypes.h"
@@ -227,25 +227,28 @@ TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) {
// restores the bounds.
TEST_F(BaseLayoutManagerTest, MaximizeSetsRestoreBounds) {
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
// Maximize it, which will keep the previous restore bounds.
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_EQ("1,2 3x4", GetRestoreBoundsInParent(window.get()).ToString());
+ EXPECT_EQ("1,2 3x4", window_state->GetRestoreBoundsInParent().ToString());
// Restore it, which should restore bounds and reset restore bounds.
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
EXPECT_EQ("1,2 3x4", window->bounds().ToString());
- EXPECT_TRUE(GetRestoreBoundsInScreen(window.get()) == NULL);
+ EXPECT_FALSE(window_state->HasRestoreBounds());
}
// Verifies maximizing keeps the restore bounds if set.
TEST_F(BaseLayoutManagerTest, MaximizeResetsRestoreBounds) {
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
- SetRestoreBoundsInParent(window.get(), gfx::Rect(10, 11, 12, 13));
+
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->SetRestoreBoundsInParent(gfx::Rect(10, 11, 12, 13));
// Maximize it, which will keep the previous restore bounds.
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_EQ("10,11 12x13", GetRestoreBoundsInParent(window.get()).ToString());
+ EXPECT_EQ("10,11 12x13", window_state->GetRestoreBoundsInParent().ToString());
}
// Verifies that the restore bounds do not get reset when restoring to a
@@ -255,24 +258,25 @@ TEST_F(BaseLayoutManagerTest, BoundsAfterRestoringToMaximizeFromMinimize) {
gfx::Rect bounds(10, 15, 25, 35);
window->SetBounds(bounds);
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
// Maximize it, which should reset restore bounds.
- wm::MaximizeWindow(window.get());
+ window_state->Maximize();
EXPECT_EQ(bounds.ToString(),
- GetRestoreBoundsInParent(window.get()).ToString());
+ window_state->GetRestoreBoundsInParent().ToString());
// Minimize the window. The restore bounds should not change.
- wm::MinimizeWindow(window.get());
+ window_state->Minimize();
EXPECT_EQ(bounds.ToString(),
- GetRestoreBoundsInParent(window.get()).ToString());
+ window_state->GetRestoreBoundsInParent().ToString());
// Show the window again. The window should be maximized, and the restore
// bounds should not change.
window->Show();
EXPECT_EQ(bounds.ToString(),
- GetRestoreBoundsInParent(window.get()).ToString());
- EXPECT_TRUE(wm::IsWindowMaximized(window.get()));
+ window_state->GetRestoreBoundsInParent().ToString());
+ EXPECT_TRUE(window_state->IsMaximized());
- wm::RestoreWindow(window.get());
+ window_state->Restore();
EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
}
diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view.cc b/ash/wm/caption_buttons/frame_caption_button_container_view.cc
index 3425afa4..5c024a0 100644
--- a/ash/wm/caption_buttons/frame_caption_button_container_view.cc
+++ b/ash/wm/caption_buttons/frame_caption_button_container_view.cc
@@ -9,7 +9,7 @@
#include "ash/shell_delegate.h"
#include "ash/wm/caption_buttons/alternate_frame_caption_button.h"
#include "ash/wm/caption_buttons/frame_maximize_button.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "grit/ash_resources.h"
#include "grit/ui_strings.h" // Accessibility names
#include "ui/base/hit_test.h"
@@ -190,7 +190,7 @@ void FrameCaptionButtonContainerView::Layout() {
// The new assets only make sense if the window is maximized or fullscreen
// because we usually use a black header in this case.
if ((frame_->IsMaximized() || frame_->IsFullscreen()) &&
- wm::GetWindowSettings(
+ wm::GetWindowState(
frame_->GetNativeWindow())->tracked_by_workspace()) {
SetButtonImages(size_button_,
IDR_AURA_WINDOW_MAXIMIZED_RESTORE2,
diff --git a/ash/wm/caption_buttons/frame_maximize_button.cc b/ash/wm/caption_buttons/frame_maximize_button.cc
index db5712f..9b35281 100644
--- a/ash/wm/caption_buttons/frame_maximize_button.cc
+++ b/ash/wm/caption_buttons/frame_maximize_button.cc
@@ -11,9 +11,8 @@
#include "ash/shell_delegate.h"
#include "ash/touch/touch_uma.h"
#include "ash/wm/caption_buttons/maximize_bubble_controller.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/window_animations.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/workspace/phantom_window_controller.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "grit/ash_strings.h"
@@ -94,7 +93,7 @@ FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener,
// TODO(sky): nuke this. It's temporary while we don't have good images.
SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
- if (ash::Shell::IsForcedMaximizeMode())
+ if (Shell::IsForcedMaximizeMode())
views::View::SetVisible(false);
}
@@ -316,7 +315,7 @@ void FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) {
void FrameMaximizeButton::SetVisible(bool visible) {
// In the enforced maximized mode we do not allow to be made visible.
- if (ash::Shell::IsForcedMaximizeMode())
+ if (Shell::IsForcedMaximizeMode())
return;
views::View::SetVisible(visible);
@@ -499,8 +498,10 @@ gfx::Rect FrameMaximizeButton::ScreenBoundsForType(
return rect;
}
case SNAP_RESTORE: {
- const gfx::Rect* restore = GetRestoreBoundsInScreen(window);
- return restore ? *restore : frame_->GetWindowBoundsInScreen();
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ return window_state->HasRestoreBounds() ?
+ window_state->GetRestoreBoundsInScreen() :
+ frame_->GetWindowBoundsInScreen();
}
case SNAP_NONE:
NOTREACHED();
@@ -516,7 +517,8 @@ gfx::Point FrameMaximizeButton::LocationForSnapSizer(
}
void FrameMaximizeButton::Snap(SnapSizer* snap_sizer) {
- ash::Shell* shell = ash::Shell::GetInstance();
+ Shell* shell = Shell::GetInstance();
+ wm::WindowState* window_state = wm::GetWindowState(frame_->GetNativeWindow());
switch (snap_type_) {
case SNAP_LEFT:
case SNAP_RIGHT: {
@@ -524,30 +526,28 @@ void FrameMaximizeButton::Snap(SnapSizer* snap_sizer) {
// should not overwrite the restore rectangle.
gfx::Rect current_bounds_in_screen = frame_->GetWindowBoundsInScreen();
snap_sizer->SnapWindowToTargetBounds();
- if (GetRestoreBoundsInScreen(frame_->GetNativeWindow()) == NULL) {
- ash::SetRestoreBoundsInScreen(frame_->GetNativeWindow(),
- current_bounds_in_screen);
- }
+ if (!window_state->HasRestoreBounds())
+ window_state->SetRestoreBoundsInScreen(current_bounds_in_screen);
shell->delegate()->RecordUserMetricsAction(
snap_type_ == SNAP_LEFT ?
- ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT :
- ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT);
+ UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT :
+ UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT);
break;
}
case SNAP_MAXIMIZE:
frame_->Maximize();
shell->delegate()->RecordUserMetricsAction(
- ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE);
+ UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE);
break;
case SNAP_MINIMIZE:
frame_->Minimize();
shell->delegate()->RecordUserMetricsAction(
- ash::UMA_WINDOW_MAXIMIZE_BUTTON_MINIMIZE);
+ UMA_WINDOW_MAXIMIZE_BUTTON_MINIMIZE);
break;
case SNAP_RESTORE:
frame_->Restore();
shell->delegate()->RecordUserMetricsAction(
- ash::UMA_WINDOW_MAXIMIZE_BUTTON_RESTORE);
+ UMA_WINDOW_MAXIMIZE_BUTTON_RESTORE);
break;
case SNAP_NONE:
NOTREACHED();
@@ -556,8 +556,10 @@ void FrameMaximizeButton::Snap(SnapSizer* snap_sizer) {
MaximizeBubbleFrameState
FrameMaximizeButton::GetMaximizeBubbleFrameState() const {
+ wm::WindowState* window_state =
+ wm::GetWindowState(frame_->GetNativeWindow());
// When there are no restore bounds, we are in normal mode.
- if (!ash::GetRestoreBoundsInScreen(frame_->GetNativeWindow()))
+ if (!window_state->HasRestoreBounds())
return FRAME_STATE_NONE;
// The normal maximized test can be used.
if (frame_->IsMaximized())
diff --git a/ash/wm/caption_buttons/frame_maximize_button_unittest.cc b/ash/wm/caption_buttons/frame_maximize_button_unittest.cc
index d0b43b2..e1af265 100644
--- a/ash/wm/caption_buttons/frame_maximize_button_unittest.cc
+++ b/ash/wm/caption_buttons/frame_maximize_button_unittest.cc
@@ -9,7 +9,7 @@
#include "ash/test/ash_test_base.h"
#include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
#include "ash/wm/caption_buttons/maximize_bubble_controller.h"
-#include "ash/wm/property_util.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "base/command_line.h"
@@ -166,35 +166,37 @@ class FrameMaximizeButtonTest : public ash::test::AshTestBase {
// Tests that clicking on the resize-button toggles between maximize and normal
// state.
TEST_F(FrameMaximizeButtonTest, ResizeButtonToggleMaximize) {
- aura::Window* window = widget()->GetNativeWindow();
+ wm::WindowState* window_state =
+ wm::GetWindowState(widget()->GetNativeWindow());
views::View* view = maximize_button();
gfx::Point center = view->GetBoundsInScreen().CenterPoint();
- aura::test::EventGenerator generator(window->GetRootWindow(), center);
+ aura::test::EventGenerator generator(
+ window_state->window()->GetRootWindow(), center);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
generator.ClickLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(window_state->IsMaximized());
center = view->GetBoundsInScreen().CenterPoint();
generator.MoveMouseTo(center);
generator.ClickLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint());
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(window_state->IsMaximized());
generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint());
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint());
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(window_state->IsMaximized());
generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint());
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
}
#if defined(OS_WIN)
@@ -212,7 +214,8 @@ TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
aura::test::EventGenerator generator(window->GetRootWindow(), center);
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_TRUE(window_state->IsNormalShowState());
// Snap right.
{
@@ -221,8 +224,8 @@ TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
internal::SnapSizer sizer(window, center,
internal::SnapSizer::RIGHT_EDGE,
internal::SnapSizer::OTHER_INPUT);
@@ -238,8 +241,8 @@ TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
internal::SnapSizer sizer(window, center,
internal::SnapSizer::LEFT_EDGE,
internal::SnapSizer::OTHER_INPUT);
@@ -255,10 +258,10 @@ TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
}
- ash::wm::RestoreWindow(window);
+ window_state->Restore();
// Now test the same behaviour for gesture events.
@@ -272,8 +275,8 @@ TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
3);
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
// This is a short resizing distance and different touch behavior
// applies which leads in half of the screen being used.
EXPECT_EQ("400,0 400x553", window->bounds().ToString());
@@ -289,8 +292,8 @@ TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
3);
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
internal::SnapSizer sizer(window, center,
internal::SnapSizer::LEFT_EDGE,
internal::SnapSizer::OTHER_INPUT);
@@ -307,7 +310,7 @@ TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
3);
RunAllPendingInMessageLoop();
- EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
}
// Test with gesture events.
@@ -339,8 +342,9 @@ TEST_F(FrameMaximizeButtonTest,
gfx::Point end_point = gfx::Point(work_area.width(), start_point.y());
aura::test::EventGenerator generator(window->GetRootWindow(), start_point);
+ wm::WindowState* window_state = wm::GetWindowState(window);
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(window_state->IsNormalShowState());
// Snap right with a touch drag.
generator.GestureScrollSequence(start_point,
@@ -349,8 +353,8 @@ TEST_F(FrameMaximizeButtonTest,
10);
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
gfx::Rect touch_result = window->bounds();
EXPECT_NE(bounds.ToString(), touch_result.ToString());
@@ -363,8 +367,8 @@ TEST_F(FrameMaximizeButtonTest,
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
gfx::Rect mouse_result = window->bounds();
// The difference between the two operations should be that the mouse
@@ -387,7 +391,7 @@ TEST_F(FrameMaximizeButtonTest, MaximizeButtonExternalShutDown) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState());
// Move the mouse cursor over the button to bring up the maximizer bubble.
generator.MoveMouseTo(button_pos);
@@ -410,13 +414,13 @@ TEST_F(FrameMaximizeButtonTest, MaximizeOnHoverThenClick) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState());
// Move the mouse cursor over the button to bring up the maximizer bubble.
generator.MoveMouseTo(button_pos);
EXPECT_TRUE(maximize_button->maximizer());
generator.ClickLeftButton();
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsMaximized());
}
// Test that hovering over a button in the balloon dialog will show the phantom
@@ -433,7 +437,7 @@ TEST_F(FrameMaximizeButtonTest, MaximizeLeftButtonDragOut) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState());
EXPECT_FALSE(maximize_button->phantom_window_open());
// Move the mouse cursor over the button to bring up the maximizer bubble.
@@ -478,7 +482,7 @@ TEST_F(FrameMaximizeButtonTest, MaximizeLeftByButton) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState());
EXPECT_FALSE(maximize_button->phantom_window_open());
// Move the mouse cursor over the button to bring up the maximizer bubble.
@@ -495,8 +499,9 @@ TEST_F(FrameMaximizeButtonTest, MaximizeLeftByButton) {
EXPECT_FALSE(maximize_button->maximizer());
EXPECT_FALSE(maximize_button->phantom_window_open());
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
internal::SnapSizer sizer(window, button_pos,
internal::SnapSizer::LEFT_EDGE,
internal::SnapSizer::OTHER_INPUT);
@@ -515,7 +520,7 @@ TEST_F(FrameMaximizeButtonTest, MaximizeKeepFocus) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState());
aura::Window* active =
aura::client::GetFocusClient(window)->GetFocusedWindow();
@@ -568,8 +573,9 @@ TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_TRUE(window_state->IsNormalShowState());
+ EXPECT_FALSE(window_state->IsMaximized());
// Move the mouse cursor over the button.
generator.MoveMouseTo(button_pos);
@@ -580,7 +586,7 @@ TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) {
generator.PressLeftButton();
RunAllPendingInMessageLoop();
EXPECT_TRUE(maximize_button->is_snap_enabled());
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
// Pressing the right button then should cancel the operation.
generator.PressRightButton();
@@ -591,7 +597,7 @@ TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) {
generator.ReleaseRightButton();
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
// Second experiment: Starting with right should also not trigger.
generator.MoveMouseTo(off_pos);
@@ -609,7 +615,7 @@ TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) {
EXPECT_FALSE(maximize_button->is_snap_enabled());
generator.ReleaseRightButton();
generator.ReleaseLeftButton();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
}
// Click a button of window maximize functionality.
@@ -654,8 +660,9 @@ TEST_F(FrameMaximizeButtonTest, MaximizeLeftRestore) {
maximize_button->set_bubble_appearance_delay_ms(0);
ClickMaxButton(maximize_button, window, SNAP_LEFT);
+ wm::WindowState* window_state = wm::GetWindowState(window);
// The window should not be maximized.
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
// But the bounds should be different.
gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
EXPECT_EQ(0, new_bounds.x());
@@ -670,7 +677,7 @@ TEST_F(FrameMaximizeButtonTest, MaximizeLeftRestore) {
EXPECT_EQ(new_bounds.width(), initial_bounds.width());
EXPECT_EQ(new_bounds.height(), initial_bounds.height());
// Make sure that there is no restore rectangle left.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window));
+ EXPECT_FALSE(window_state->HasRestoreBounds());
}
// Maximize, left/right maximize and then restore should works.
@@ -682,10 +689,12 @@ TEST_F(FrameMaximizeButtonTest, MaximizeMaximizeLeftRestore) {
maximize_button->set_bubble_appearance_delay_ms(0);
ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_TRUE(window_state->IsMaximized());
ClickMaxButton(maximize_button, window, SNAP_LEFT);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
EXPECT_EQ(0, new_bounds.x());
EXPECT_EQ(0, new_bounds.y());
@@ -700,7 +709,7 @@ TEST_F(FrameMaximizeButtonTest, MaximizeMaximizeLeftRestore) {
EXPECT_EQ(new_bounds.width(), initial_bounds.width());
EXPECT_EQ(new_bounds.height(), initial_bounds.height());
// Make sure that there is no restore rectangle left.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window));
+ EXPECT_FALSE(window_state->HasRestoreBounds());
}
// Left/right maximize, maximize and then restore should work.
@@ -712,21 +721,24 @@ TEST_F(FrameMaximizeButtonTest, MaximizeLeftMaximizeRestore) {
maximize_button->set_bubble_appearance_delay_ms(0);
ClickMaxButton(maximize_button, window, SNAP_LEFT);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_FALSE(window_state->IsMaximized());
ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(window_state->IsMaximized());
ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
EXPECT_EQ(new_bounds.x(), initial_bounds.x());
EXPECT_EQ(new_bounds.y(), initial_bounds.x());
EXPECT_EQ(new_bounds.width(), initial_bounds.width());
EXPECT_EQ(new_bounds.height(), initial_bounds.height());
// Make sure that there is no restore rectangle left.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window));
+ EXPECT_FALSE(window_state->HasRestoreBounds());
}
+
// Test that minimizing the window per keyboard closes the maximize bubble.
TEST_F(FrameMaximizeButtonTest, MinimizePerKeyClosesBubble) {
aura::Window* window = widget()->GetNativeWindow();
@@ -745,9 +757,10 @@ TEST_F(FrameMaximizeButtonTest, MinimizePerKeyClosesBubble) {
EXPECT_TRUE(maximize_button->maximizer());
// We simulate the keystroke by calling minimizeWindow directly.
- wm::MinimizeWindow(window);
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ window_state->Minimize();
- EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
EXPECT_FALSE(maximize_button->maximizer());
}
@@ -757,9 +770,10 @@ TEST_F(FrameMaximizeButtonTest, MaximizeButtonDragDownMinimizes) {
ash::FrameMaximizeButton* maximize_button =
FrameMaximizeButtonTest::maximize_button();
+ wm::WindowState* window_state = wm::GetWindowState(window);
// Drag down on a maximized window.
- wm::MaximizeWindow(window);
- EXPECT_TRUE(wm::IsWindowMaximized(window));
+ window_state->Maximize();
+ EXPECT_TRUE(window_state->IsMaximized());
gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
gfx::Point off_pos(button_pos.x(), button_pos.y() + 100);
@@ -767,17 +781,17 @@ TEST_F(FrameMaximizeButtonTest, MaximizeButtonDragDownMinimizes) {
generator.GestureScrollSequence(button_pos, off_pos,
base::TimeDelta::FromMilliseconds(0), 1);
- EXPECT_TRUE(wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
EXPECT_FALSE(maximize_button->maximizer());
// Drag down on a restored window.
- wm::RestoreWindow(window);
+ window_state->Restore();
button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
off_pos = gfx::Point(button_pos.x(), button_pos.y() + 200);
generator.GestureScrollSequence(button_pos, off_pos,
base::TimeDelta::FromMilliseconds(10), 1);
- EXPECT_TRUE(wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
EXPECT_FALSE(maximize_button->maximizer());
}
diff --git a/ash/wm/default_window_resizer.cc b/ash/wm/default_window_resizer.cc
index a7b54e5..41bc1fd 100644
--- a/ash/wm/default_window_resizer.cc
+++ b/ash/wm/default_window_resizer.cc
@@ -5,7 +5,7 @@
#include "ash/wm/default_window_resizer.h"
#include "ash/shell.h"
-#include "ash/wm/property_util.h"
+#include "ash/wm/window_state.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
@@ -34,7 +34,7 @@ void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) {
gfx::Rect bounds(CalculateBoundsForDrag(details_, location));
if (bounds != details_.window->bounds()) {
if (!did_move_or_resize_ && !details_.restore_bounds.IsEmpty())
- ClearRestoreBounds(details_.window);
+ wm::GetWindowState(details_.window)->ClearRestoreBounds();
did_move_or_resize_ = true;
details_.window->SetBounds(bounds);
}
@@ -50,7 +50,8 @@ void DefaultWindowResizer::RevertDrag() {
details_.window->SetBounds(details_.initial_bounds_in_parent);
if (!details_.restore_bounds.IsEmpty())
- SetRestoreBoundsInScreen(details_.window, details_.restore_bounds);
+ wm::GetWindowState(details_.window)->SetRestoreBoundsInScreen(
+ details_.restore_bounds);
}
aura::Window* DefaultWindowResizer::GetTarget() {
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
index 30701a9..1601af2 100644
--- a/ash/wm/dock/docked_window_layout_manager.cc
+++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -15,6 +15,7 @@
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/auto_reset.h"
#include "base/command_line.h"
@@ -84,7 +85,7 @@ DockedWindowLayoutManager* GetDockLayoutManager(aura::Window* window,
// Certain windows (minimized, hidden or popups) do not matter to docking.
bool IsUsedByLayout(aura::Window* window) {
return (window->IsVisible() &&
- !wm::IsWindowMinimized(window) &&
+ !wm::GetWindowState(window)->IsMinimized() &&
window->type() != aura::client::WINDOW_TYPE_POPUP);
}
@@ -411,10 +412,10 @@ void DockedWindowLayoutManager::OnWindowPropertyChanged(aura::Window* window,
// until WillChangeVisibilityState is called when the shelf is visible again
if (shelf_hidden_)
return;
- if (wm::IsWindowMinimized(window))
- MinimizeWindow(window);
+ if (wm::GetWindowState(window)->IsMinimized())
+ MinimizeDockedWindow(window);
else
- RestoreWindow(window);
+ RestoreDockedWindow(window);
}
void DockedWindowLayoutManager::OnWindowBoundsChanged(
@@ -479,10 +480,10 @@ void DockedWindowLayoutManager::WillChangeVisibilityState(
continue;
if (shelf_hidden_) {
if (window->IsVisible())
- MinimizeWindow(window);
+ MinimizeDockedWindow(window);
} else {
- if (!wm::IsWindowMinimized(window))
- RestoreWindow(window);
+ if (!wm::GetWindowState(window)->IsMinimized())
+ RestoreDockedWindow(window);
}
}
}
@@ -493,16 +494,17 @@ void DockedWindowLayoutManager::WillChangeVisibilityState(
////////////////////////////////////////////////////////////////////////////////
// DockLayoutManager private implementation:
-void DockedWindowLayoutManager::MinimizeWindow(aura::Window* window) {
+void DockedWindowLayoutManager::MinimizeDockedWindow(aura::Window* window) {
DCHECK_NE(window->type(), aura::client::WINDOW_TYPE_POPUP);
views::corewm::SetWindowVisibilityAnimationType(
window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
window->Hide();
- if (wm::IsActiveWindow(window))
- wm::DeactivateWindow(window);
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ if (window_state->IsActive())
+ window_state->Deactivate();
}
-void DockedWindowLayoutManager::RestoreWindow(aura::Window* window) {
+void DockedWindowLayoutManager::RestoreDockedWindow(aura::Window* window) {
DCHECK_NE(window->type(), aura::client::WINDOW_TYPE_POPUP);
window->Show();
}
diff --git a/ash/wm/dock/docked_window_layout_manager.h b/ash/wm/dock/docked_window_layout_manager.h
index e4542b3..8bea763 100644
--- a/ash/wm/dock/docked_window_layout_manager.h
+++ b/ash/wm/dock/docked_window_layout_manager.h
@@ -9,7 +9,6 @@
#include "ash/shelf/shelf_layout_manager_observer.h"
#include "ash/shell_observer.h"
#include "ash/wm/dock/dock_types.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/workspace/snap_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -163,8 +162,8 @@ class ASH_EXPORT DockedWindowLayoutManager
static const int kMinDockGap;
// Minimize / restore window and relayout.
- void MinimizeWindow(aura::Window* window);
- void RestoreWindow(aura::Window* window);
+ void MinimizeDockedWindow(aura::Window* window);
+ void RestoreDockedWindow(aura::Window* window);
// Updates docked layout state when a window gets inside the dock.
void OnWindowDocked(aura::Window* window);
diff --git a/ash/wm/dock/docked_window_layout_manager_unittest.cc b/ash/wm/dock/docked_window_layout_manager_unittest.cc
index 14ba0ab..68601ad 100644
--- a/ash/wm/dock/docked_window_layout_manager_unittest.cc
+++ b/ash/wm/dock/docked_window_layout_manager_unittest.cc
@@ -23,7 +23,7 @@
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/panels/panel_layout_manager.h"
#include "ash/wm/window_resizer.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/basictypes.h"
#include "base/command_line.h"
@@ -190,7 +190,7 @@ class DockedWindowLayoutManagerTest
// x-coordinate can get adjusted by snapping or sticking.
// y-coordinate could be changed by possible automatic layout if docked.
if (window->parent()->id() != internal::kShellWindowId_DockedContainer &&
- GetRestoreBoundsInScreen(window) == NULL) {
+ !wm::GetWindowState(window)->HasRestoreBounds()) {
EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
}
}
@@ -243,7 +243,7 @@ TEST_P(DockedWindowLayoutManagerTest, AutoPlacingLeft) {
// Create two additional windows and test their auto-placement
scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1));
gfx::Rect desktop_area = window1->parent()->bounds();
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
+ wm::GetWindowState(window1.get())->set_window_position_managed(true);
window1->Hide();
window1->SetBounds(gfx::Rect(250, 32, 231, 320));
window1->Show();
@@ -255,7 +255,7 @@ TEST_P(DockedWindowLayoutManagerTest, AutoPlacingLeft) {
",32 231x320", window1->bounds().ToString());
scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2));
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::GetWindowState(window2.get())->set_window_position_managed(true);
// To avoid any auto window manager changes due to SetBounds, the window
// gets first hidden and then shown again.
window2->Hide();
@@ -294,7 +294,7 @@ TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRight) {
// Create two additional windows and test their auto-placement
scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1));
gfx::Rect desktop_area = window1->parent()->bounds();
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
+ wm::GetWindowState(window1.get())->set_window_position_managed(true);
window1->Hide();
window1->SetBounds(gfx::Rect(16, 32, 231, 320));
window1->Show();
@@ -306,7 +306,7 @@ TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRight) {
",32 231x320", window1->bounds().ToString());
scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2));
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::GetWindowState(window2.get())->set_window_position_managed(true);
// To avoid any auto window manager changes due to SetBounds, the window
// gets first hidden and then shown again.
window2->Hide();
@@ -350,7 +350,7 @@ TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) {
scoped_ptr<aura::Window> window1(
CreateTestWindowInShellWithDelegate(NULL, 1, bounds));
gfx::Rect desktop_area = window1->parent()->bounds();
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
+ wm::GetWindowState(window1.get())->set_window_position_managed(true);
window1->Hide();
window1->Show();
@@ -363,7 +363,7 @@ TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) {
bounds = gfx::Rect(632, 48, 256, 512);
scoped_ptr<aura::Window> window2(
CreateTestWindowInShellWithDelegate(NULL, 2, bounds));
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::GetWindowState(window2.get())->set_window_position_managed(true);
// To avoid any auto window manager changes due to SetBounds, the window
// gets first hidden and then shown again.
window2->Hide();
diff --git a/ash/wm/dock/docked_window_resizer.cc b/ash/wm/dock/docked_window_resizer.cc
index e168955..2882f3b 100644
--- a/ash/wm/dock/docked_window_resizer.cc
+++ b/ash/wm/dock/docked_window_resizer.cc
@@ -15,8 +15,7 @@
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/dock/docked_window_layout_manager.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/workspace/magnetism_matcher.h"
#include "ash/wm/workspace/workspace_window_resizer.h"
#include "base/command_line.h"
@@ -80,10 +79,10 @@ void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) {
// Temporarily clear kWindowTrackedByWorkspaceKey for windows that are snapped
// to screen edges e.g. when they are docked. This prevents the windows from
// getting snapped to other nearby windows during the drag.
- wm::WindowSettings* window_settings = wm::GetWindowSettings(GetTarget());
- bool was_tracked_by_workspace = window_settings->tracked_by_workspace();
+ wm::WindowState* window_state = wm::GetWindowState(GetTarget());
+ bool was_tracked_by_workspace = window_state->tracked_by_workspace();
if (set_tracked_by_workspace)
- window_settings->SetTrackedByWorkspace(false);
+ window_state->SetTrackedByWorkspace(false);
gfx::Point modified_location(location.x() + offset.x(),
location.y() + offset.y());
@@ -91,7 +90,7 @@ void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) {
next_window_resizer_->Drag(modified_location, event_flags);
if (!resizer)
return;
- window_settings->SetTrackedByWorkspace(was_tracked_by_workspace);
+ window_state->SetTrackedByWorkspace(was_tracked_by_workspace);
DockedWindowLayoutManager* new_dock_layout =
GetDockedLayoutManagerAtPoint(last_location_);
@@ -121,24 +120,24 @@ void DockedWindowResizer::CompleteDrag(int event_flags) {
// Temporarily clear kWindowTrackedByWorkspaceKey for panels so that they
// don't get forced into the workspace that may be shrunken because of docked
// windows.
- wm::WindowSettings* window_settings = wm::GetWindowSettings(GetTarget());
- bool was_tracked_by_workspace = window_settings->tracked_by_workspace();
+ wm::WindowState* window_state = wm::GetWindowState(GetTarget());
+ bool was_tracked_by_workspace = window_state->tracked_by_workspace();
if (was_docked_)
- window_settings->SetTrackedByWorkspace(false);
+ window_state->SetTrackedByWorkspace(false);
// The root window can change when dragging into a different screen.
next_window_resizer_->CompleteDrag(event_flags);
FinishedDragging();
- window_settings->SetTrackedByWorkspace(was_tracked_by_workspace);
+ window_state->SetTrackedByWorkspace(was_tracked_by_workspace);
}
void DockedWindowResizer::RevertDrag() {
// Temporarily clear kWindowTrackedByWorkspaceKey for panels so that they
// don't get forced into the workspace that may be shrunken because of docked
// windows.
- wm::WindowSettings* window_settings = wm::GetWindowSettings(GetTarget());
- bool was_tracked_by_workspace = window_settings->tracked_by_workspace();
+ wm::WindowState* window_state = wm::GetWindowState(GetTarget());
+ bool was_tracked_by_workspace = window_state->tracked_by_workspace();
if (was_docked_)
- window_settings->SetTrackedByWorkspace(false);
+ window_state->SetTrackedByWorkspace(false);
next_window_resizer_->RevertDrag();
// Restore docked state to what it was before the drag if necessary.
if (was_docked_ && !is_docked_) {
@@ -146,7 +145,7 @@ void DockedWindowResizer::RevertDrag() {
is_docked_ = was_docked_;
}
FinishedDragging();
- window_settings->SetTrackedByWorkspace(was_tracked_by_workspace);
+ window_state->SetTrackedByWorkspace(was_tracked_by_workspace);
}
aura::Window* DockedWindowResizer::GetTarget() {
@@ -227,7 +226,7 @@ void DockedWindowResizer::StartedDragging() {
if (GetTarget()->type() != aura::client::WINDOW_TYPE_PANEL &&
GetTarget()->parent()->id() == kShellWindowId_DefaultContainer) {
// The window is going to be reparented - avoid completing the drag.
- wm::GetWindowSettings(GetTarget())->set_continue_drag_after_reparent(true);
+ wm::GetWindowState(GetTarget())->set_continue_drag_after_reparent(true);
// Reparent the window into the docked windows container in order to get it
// on top of other docked windows.
@@ -243,16 +242,16 @@ void DockedWindowResizer::StartedDragging() {
void DockedWindowResizer::FinishedDragging() {
if (!did_move_or_resize_)
return;
-
aura::Window* window = GetTarget();
+ wm::WindowState* window_state = wm::GetWindowState(window);
const bool attached_panel =
window->type() == aura::client::WINDOW_TYPE_PANEL &&
- wm::GetWindowSettings(window)->panel_attached();
+ window_state->panel_attached();
const bool is_resized =
(details_.bounds_change & WindowResizer::kBoundsChange_Resizes) != 0;
// No longer restore to pre-docked bounds if a window has been resized.
if (is_resized && is_docked_)
- ClearRestoreBounds(window);
+ window_state->ClearRestoreBounds();
// Check if the window needs to be docked or returned to workspace.
aura::Window* dock_container = Shell::GetContainer(
diff --git a/ash/wm/dock/docked_window_resizer_unittest.cc b/ash/wm/dock/docked_window_resizer_unittest.cc
index 34a39d2..024187c 100644
--- a/ash/wm/dock/docked_window_resizer_unittest.cc
+++ b/ash/wm/dock/docked_window_resizer_unittest.cc
@@ -22,7 +22,7 @@
#include "ash/wm/dock/docked_window_layout_manager.h"
#include "ash/wm/drag_window_resizer.h"
#include "ash/wm/panels/panel_layout_manager.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "ui/aura/client/aura_constants.h"
@@ -200,7 +200,7 @@ class DockedWindowResizerTest
// x-coordinate can get adjusted by snapping or sticking.
// y-coordinate could be changed by possible automatic layout if docked.
if (window->parent()->id() != internal::kShellWindowId_DockedContainer &&
- GetRestoreBoundsInScreen(window) == NULL) {
+ !wm::GetWindowState(window)->HasRestoreBounds()) {
EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
}
}
@@ -701,7 +701,8 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther)
// Maximize the second window - Maximized area should be shrunk.
const gfx::Rect restored_bounds = w2->bounds();
- wm::MaximizeWindow(w2.get());
+ wm::WindowState* w2_state = wm::GetWindowState(w2.get());
+ w2_state->Maximize();
EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() -
manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap,
w2->bounds().width());
@@ -745,7 +746,7 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther)
w2->bounds().width());
// Unmaximize the second window.
- wm::RestoreWindow(w2.get());
+ w2_state->Restore();
// Its bounds should get restored.
EXPECT_EQ(restored_bounds, w2->bounds());
}
@@ -1029,7 +1030,7 @@ TEST_P(DockedWindowResizerTest, DragToShelf)
if (test_panels()) {
// The panel should be touching the shelf and attached.
EXPECT_EQ(shelf_y, w1->bounds().bottom());
- EXPECT_TRUE(wm::GetWindowSettings(w1.get())->panel_attached());
+ EXPECT_TRUE(wm::GetWindowState(w1.get())->panel_attached());
} else {
// The window should not be touching the shelf.
EXPECT_EQ(shelf_y - kDistanceFromShelf, w1->bounds().bottom());
diff --git a/ash/wm/drag_window_resizer.cc b/ash/wm/drag_window_resizer.cc
index e07c96e..6a1ae1b 100644
--- a/ash/wm/drag_window_resizer.cc
+++ b/ash/wm/drag_window_resizer.cc
@@ -9,7 +9,6 @@
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/drag_window_controller.h"
-#include "ash/wm/property_util.h"
#include "base/memory/weak_ptr.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc
index 3e1a31d..b27fc7b 100644
--- a/ash/wm/frame_painter.cc
+++ b/ash/wm/frame_painter.cc
@@ -12,8 +12,7 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/logging.h" // DCHECK
#include "grit/ash_resources.h"
@@ -230,7 +229,7 @@ FramePainter::~FramePainter() {
// Sometimes we are destroyed before the window closes, so ensure we clean up.
if (window_) {
window_->RemoveObserver(this);
- wm::GetWindowSettings(window_)->RemoveObserver(this);
+ wm::GetWindowState(window_)->RemoveObserver(this);
}
}
@@ -274,7 +273,7 @@ void FramePainter::Init(
// itself in OnWindowDestroying() below, or in the destructor if we go away
// before the window.
window_->AddObserver(this);
- wm::GetWindowSettings(window_)->AddObserver(this);
+ wm::GetWindowState(window_)->AddObserver(this);
// Solo-window header updates are handled by the workspace controller when
// this window is added to the desktop.
@@ -394,7 +393,7 @@ bool FramePainter::ShouldUseMinimalHeaderStyle(Themed header_themed) const {
// for tab dragging).
return (frame_->IsMaximized() || frame_->IsFullscreen()) &&
header_themed == THEMED_NO &&
- wm::GetWindowSettings(frame_->GetNativeWindow())->tracked_by_workspace();
+ wm::GetWindowState(frame_->GetNativeWindow())->tracked_by_workspace();
}
void FramePainter::PaintHeader(views::NonClientFrameView* view,
@@ -619,12 +618,12 @@ void FramePainter::OnThemeChanged() {
}
///////////////////////////////////////////////////////////////////////////////
-// WindowSettings::jObserver overrides:
+// WindowState::Observer overrides:
void FramePainter::OnTrackedByWorkspaceChanged(aura::Window* window,
bool old) {
// When 'TrackedByWorkspace' changes, we are going to paint the header
// differently. Schedule a paint to ensure everything is updated correctly.
- if (wm::GetWindowSettings(window)->tracked_by_workspace())
+ if (wm::GetWindowState(window)->tracked_by_workspace())
frame_->non_client_view()->SchedulePaint();
}
@@ -640,8 +639,8 @@ void FramePainter::OnWindowPropertyChanged(aura::Window* window,
// Maximized and fullscreen windows don't want resize handles overlapping the
// content area, because when the user moves the cursor to the right screen
// edge we want them to be able to hit the scroll bar.
- if (ash::wm::IsWindowMaximized(window) ||
- ash::wm::IsWindowFullscreen(window)) {
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ if (window_state->IsMaximizedOrFullscreen()) {
window->set_hit_test_bounds_override_inner(gfx::Insets());
} else {
window->set_hit_test_bounds_override_inner(
@@ -667,7 +666,7 @@ void FramePainter::OnWindowDestroying(aura::Window* destroying) {
// Must be removed here and not in the destructor, as the aura::Window is
// already destroyed when our destructor runs.
window_->RemoveObserver(this);
- wm::GetWindowSettings(window_)->RemoveObserver(this);
+ wm::GetWindowState(window_)->RemoveObserver(this);
// If we have two or more windows open and we close this one, we might trigger
// the solo window appearance for another window.
@@ -727,7 +726,7 @@ int FramePainter::GetHeaderCornerRadius() const {
// tracked by the workspace code. (Windows which are not tracked by the
// workspace code are used for tab dragging.)
bool square_corners = ((frame_->IsMaximized() || frame_->IsFullscreen())) &&
- wm::GetWindowSettings(frame_->GetNativeWindow())->tracked_by_workspace();
+ wm::GetWindowState(frame_->GetNativeWindow())->tracked_by_workspace();
const int kCornerRadius = 2;
return square_corners ? 0 : kCornerRadius;
}
@@ -784,7 +783,7 @@ bool FramePainter::UseSoloWindowHeaderInRoot(RootWindow* root_window,
!IsSoloWindowHeaderCandidate(window) ||
!IsVisibleToRoot(window))
continue;
- if (wm::IsWindowMaximized(window))
+ if (wm::GetWindowState(window)->IsMaximized())
return false;
++visible_window_count;
if (visible_window_count > 1)
diff --git a/ash/wm/frame_painter.h b/ash/wm/frame_painter.h
index d790221..f1fddb1 100644
--- a/ash/wm/frame_painter.h
+++ b/ash/wm/frame_painter.h
@@ -6,7 +6,7 @@
#define ASH_WM_FRAME_PAINTER_H_
#include "ash/ash_export.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h" // OVERRIDE
#include "base/gtest_prod_util.h"
@@ -41,7 +41,7 @@ class FrameCaptionButtonContainerView;
// layout constants for Ash window frames.
class ASH_EXPORT FramePainter : public aura::WindowObserver,
public gfx::AnimationDelegate,
- public wm::WindowSettings::Observer {
+ public wm::WindowState::Observer {
public:
// Opacity values for the window header in various states, from 0 to 255.
static int kActiveWindowOpacity;
diff --git a/ash/wm/frame_painter_unittest.cc b/ash/wm/frame_painter_unittest.cc
index 7353bc4..006358e 100644
--- a/ash/wm/frame_painter_unittest.cc
+++ b/ash/wm/frame_painter_unittest.cc
@@ -10,7 +10,7 @@
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
@@ -481,7 +481,7 @@ TEST_F(FramePainterTest, MAYBE_UseSoloWindowHeaderMultiDisplay) {
EXPECT_TRUE(checker1.IsPaintScheduledAndReset());
// Change the w3 state to maximize. Doesn't affect to w1.
- wm::MaximizeWindow(w3->GetNativeWindow());
+ wm::GetWindowState(w3->GetNativeWindow())->Maximize();
EXPECT_TRUE(p1->UseSoloWindowHeader());
EXPECT_FALSE(p2->UseSoloWindowHeader());
EXPECT_FALSE(p3->UseSoloWindowHeader());
@@ -541,7 +541,7 @@ TEST_F(FramePainterTest, GetHeaderOpacity) {
0));
// Regular maximized windows are fully opaque.
- ash::wm::MaximizeWindow(w1->GetNativeWindow());
+ wm::GetWindowState(w1->GetNativeWindow())->Maximize();
EXPECT_EQ(255,
p1->GetHeaderOpacity(FramePainter::ACTIVE,
IDR_AURA_WINDOW_HEADER_BASE_ACTIVE,
@@ -566,9 +566,9 @@ TEST_F(FramePainterTest, MinimalHeaderStyle) {
// style.
EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_YES));
- wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(false);
+ wm::GetWindowState(w->GetNativeWindow())->SetTrackedByWorkspace(false);
EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO));
- wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(true);
+ wm::GetWindowState(w->GetNativeWindow())->SetTrackedByWorkspace(true);
}
// Ensure the title text is vertically aligned with the window icon.
diff --git a/ash/wm/gestures/system_pinch_handler.cc b/ash/wm/gestures/system_pinch_handler.cc
index 3b97f5a..d2e7ce2 100644
--- a/ash/wm/gestures/system_pinch_handler.cc
+++ b/ash/wm/gestures/system_pinch_handler.cc
@@ -8,8 +8,8 @@
#include "ash/screen_ash.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/window_animations.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "ui/aura/window.h"
@@ -44,22 +44,20 @@ SystemGestureStatus SystemPinchHandler::ProcessGestureEvent(
// The target has changed, somehow. Let's bale.
if (!widget_ || !widget_->widget_delegate()->CanResize())
return SYSTEM_GESTURE_END;
-
+ wm::WindowState* window_state = wm::GetWindowState(target_);
switch (event.type()) {
case ui::ET_GESTURE_END: {
if (event.details().touch_points() > kSystemGesturePoints)
break;
if (phantom_state_ == PHANTOM_WINDOW_MAXIMIZED) {
- if (!wm::IsWindowMaximized(target_) &&
- !wm::IsWindowFullscreen(target_))
- wm::MaximizeWindow(target_);
+ if (!window_state->IsMaximizedOrFullscreen())
+ window_state->Maximize();
} else if (phantom_state_ == PHANTOM_WINDOW_MINIMIZED) {
- if (wm::IsWindowMaximized(target_) ||
- wm::IsWindowFullscreen(target_)) {
- wm::RestoreWindow(target_);
+ if (window_state->IsMaximizedOrFullscreen()) {
+ window_state->Restore();
} else {
- wm::MinimizeWindow(target_);
+ window_state->Minimize();
// NOTE: Minimizing the window will cause this handler to be
// destroyed. So do not access anything from |this| from here.
@@ -92,11 +90,10 @@ SystemGestureStatus SystemPinchHandler::ProcessGestureEvent(
event.details().swipe_left() ? internal::SnapSizer::LEFT_EDGE :
internal::SnapSizer::RIGHT_EDGE);
} else if (event.details().swipe_up()) {
- if (!wm::IsWindowMaximized(target_) &&
- !wm::IsWindowFullscreen(target_))
- wm::MaximizeWindow(target_);
+ if (!window_state->IsMaximizedOrFullscreen())
+ window_state->Maximize();
} else if (event.details().swipe_down()) {
- wm::MinimizeWindow(target_);
+ window_state->Minimize();
} else {
NOTREACHED() << "Swipe happened without a direction.";
}
@@ -121,11 +118,11 @@ gfx::Rect SystemPinchHandler::GetPhantomWindowScreenBounds(
}
if (pinch_factor_ < kPinchThresholdForMinimize) {
- if (wm::IsWindowMaximized(window) || wm::IsWindowFullscreen(window)) {
- const gfx::Rect* restore = GetRestoreBoundsInScreen(window);
- if (restore) {
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ if (window_state->IsMaximizedOrFullscreen()) {
+ if (window_state->HasRestoreBounds()) {
phantom_state_ = PHANTOM_WINDOW_MINIMIZED;
- return *restore;
+ return window_state->GetRestoreBoundsInScreen();
}
return window->bounds();
}
diff --git a/ash/wm/gestures/two_finger_drag_handler.cc b/ash/wm/gestures/two_finger_drag_handler.cc
index c379f54..d5e28d8 100644
--- a/ash/wm/gestures/two_finger_drag_handler.cc
+++ b/ash/wm/gestures/two_finger_drag_handler.cc
@@ -5,6 +5,7 @@
#include "ash/wm/gestures/two_finger_drag_handler.h"
#include "ash/wm/window_resizer.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "ui/aura/client/window_types.h"
@@ -91,9 +92,11 @@ bool TwoFingerDragHandler::ProcessGestureEvent(aura::Window* target,
return false;
}
+ wm::WindowState* window_state = wm::GetWindowState(target);
+
if (event.type() == ui::ET_GESTURE_BEGIN &&
event.details().touch_points() == 2) {
- if (!window_resizer_.get() && wm::IsWindowNormal(target) &&
+ if (!window_resizer_.get() && window_state->IsNormalShowState() &&
target->type() == aura::client::WINDOW_TYPE_NORMAL) {
if (WindowComponentsAllowMoving(first_finger_hittest_,
target->delegate()->GetNonClientComponent(event.location()))) {
@@ -114,7 +117,7 @@ bool TwoFingerDragHandler::ProcessGestureEvent(aura::Window* target,
// Consume all two-finger gestures on a normal window.
return event.details().touch_points() == 2 &&
target->type() == aura::client::WINDOW_TYPE_NORMAL &&
- wm::IsWindowNormal(target);
+ window_state->IsNormalShowState();
}
if (target != window_resizer_->GetTarget())
@@ -135,14 +138,12 @@ bool TwoFingerDragHandler::ProcessGestureEvent(aura::Window* target,
// For a swipe, the window either maximizes, minimizes, or snaps. In this
// case, cancel the drag, and do the appropriate action.
Reset();
-
if (event.details().swipe_up()) {
- if (wm::CanMaximizeWindow(target))
- wm::MaximizeWindow(target);
- } else if (event.details().swipe_down() &&
- wm::CanMinimizeWindow(target)) {
- wm::MinimizeWindow(target);
- } else if (wm::CanSnapWindow(target)) {
+ if (window_state->CanMaximize())
+ window_state->Maximize();
+ } else if (event.details().swipe_down() && window_state->CanMinimize()) {
+ window_state->Minimize();
+ } else if (window_state->CanSnap()) {
ui::ScopedLayerAnimationSettings scoped_setter(
target->layer()->GetAnimator());
scoped_setter.SetPreemptionStrategy(
diff --git a/ash/wm/overview/window_selector.cc b/ash/wm/overview/window_selector.cc
index 785edd4..50f8234 100644
--- a/ash/wm/overview/window_selector.cc
+++ b/ash/wm/overview/window_selector.cc
@@ -12,7 +12,7 @@
#include "ash/wm/overview/window_selector_delegate.h"
#include "ash/wm/overview/window_selector_panels.h"
#include "ash/wm/overview/window_selector_window.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "base/auto_reset.h"
#include "base/metrics/histogram.h"
#include "base/timer/timer.h"
@@ -113,7 +113,7 @@ WindowSelector::WindowSelector(const WindowList& windows,
observed_windows_.insert(windows[i]);
if (windows[i]->type() == aura::client::WINDOW_TYPE_PANEL &&
- wm::GetWindowSettings(windows[i])->panel_attached()) {
+ wm::GetWindowState(windows[i])->panel_attached()) {
// Attached panel windows are grouped into a single overview item per
// root window (display).
std::vector<WindowSelectorPanels*>::iterator iter =
diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc
index ea6f9e9..579b346 100644
--- a/ash/wm/panels/panel_layout_manager.cc
+++ b/ash/wm/panels/panel_layout_manager.cc
@@ -15,9 +15,8 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/frame_painter.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/window_animations.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/auto_reset.h"
#include "base/bind.h"
@@ -351,7 +350,7 @@ void PanelLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
if (in_add_window_)
return;
base::AutoReset<bool> auto_reset_in_add_window(&in_add_window_, true);
- if (!wm::GetWindowSettings(child)->panel_attached()) {
+ if (!wm::GetWindowState(child)->panel_attached()) {
// This should only happen when a window is added to panel container as a
// result of bounds change from within the application during a drag.
// If so we have already stopped the drag and should reparent the panel
diff --git a/ash/wm/panels/panel_window_resizer.cc b/ash/wm/panels/panel_window_resizer.cc
index 606a7e8..dcd4559 100644
--- a/ash/wm/panels/panel_window_resizer.cc
+++ b/ash/wm/panels/panel_window_resizer.cc
@@ -13,8 +13,7 @@
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/panels/panel_layout_manager.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "base/memory/weak_ptr.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
@@ -130,7 +129,7 @@ PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer,
panel_container_(NULL),
initial_panel_container_(NULL),
did_move_or_resize_(false),
- was_attached_(wm::GetWindowSettings(GetTarget())->panel_attached()),
+ was_attached_(wm::GetWindowState(GetTarget())->panel_attached()),
should_attach_(was_attached_),
weak_ptr_factory_(this) {
DCHECK(details_.is_resizable);
@@ -191,8 +190,8 @@ void PanelWindowResizer::StartedDragging() {
GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget());
if (!was_attached_) {
// Attach the panel while dragging placing it in front of other panels.
- wm::GetWindowSettings(GetTarget())->set_continue_drag_after_reparent(true);
- wm::GetWindowSettings(GetTarget())->set_panel_attached(true);
+ wm::GetWindowState(GetTarget())->set_continue_drag_after_reparent(true);
+ wm::GetWindowState(GetTarget())->set_panel_attached(true);
// We use root window coordinates to ensure that during the drag the panel
// is reparented to a container in the root window that has that window.
GetTarget()->SetDefaultParentByRootWindow(
@@ -204,8 +203,8 @@ void PanelWindowResizer::StartedDragging() {
void PanelWindowResizer::FinishDragging() {
if (!did_move_or_resize_)
return;
- if (wm::GetWindowSettings(GetTarget())->panel_attached() != should_attach_) {
- wm::GetWindowSettings(GetTarget())->set_panel_attached(should_attach_);
+ if (wm::GetWindowState(GetTarget())->panel_attached() != should_attach_) {
+ wm::GetWindowState(GetTarget())->set_panel_attached(should_attach_);
// We use last known location to ensure that after the drag the panel
// is reparented to a container in the root window that has that location.
GetTarget()->SetDefaultParentByRootWindow(
diff --git a/ash/wm/panels/panel_window_resizer_unittest.cc b/ash/wm/panels/panel_window_resizer_unittest.cc
index 81bff9c..7faba1f 100644
--- a/ash/wm/panels/panel_window_resizer_unittest.cc
+++ b/ash/wm/panels/panel_window_resizer_unittest.cc
@@ -18,7 +18,7 @@
#include "ash/test/test_launcher_delegate.h"
#include "ash/wm/drag_window_resizer.h"
#include "ash/wm/panels/panel_layout_manager.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/base/hit_test.h"
@@ -98,7 +98,8 @@ class PanelWindowResizerTest : public test::AshTestBase {
// Test dragging the panel slightly, then detaching, and then reattaching
// dragging out by the vector (dx, dy).
void DetachReattachTest(aura::Window* window, int dx, int dy) {
- EXPECT_TRUE(wm::GetWindowSettings(window)->panel_attached());
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_TRUE(window_state->panel_attached());
aura::RootWindow* root_window = window->GetRootWindow();
EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
DragStart(window);
@@ -118,7 +119,7 @@ class PanelWindowResizerTest : public test::AshTestBase {
// The panel should be detached when the drag completes.
DragEnd();
- EXPECT_FALSE(wm::GetWindowSettings(window)->panel_attached());
+ EXPECT_FALSE(window_state->panel_attached());
EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
window->parent()->id());
EXPECT_EQ(root_window, window->GetRootWindow());
@@ -130,7 +131,7 @@ class PanelWindowResizerTest : public test::AshTestBase {
DragEnd();
// The panel should be reattached and have snapped to the launcher.
- EXPECT_TRUE(wm::GetWindowSettings(window)->panel_attached());
+ EXPECT_TRUE(window_state->panel_attached());
EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x());
EXPECT_EQ(initial_bounds.y(), window->GetBoundsInScreen().y());
EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
@@ -290,7 +291,7 @@ TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) {
EXPECT_EQ(root_windows[0], window->GetRootWindow());
EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x());
EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
- EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
window->parent()->id());
@@ -300,7 +301,7 @@ TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) {
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
- EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
window->parent()->id());
}
@@ -321,7 +322,7 @@ TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) {
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
- EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
window->parent()->id());
}
@@ -342,7 +343,7 @@ TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) {
DragMove(0, -100);
DragEnd();
EXPECT_EQ(root_windows[0], window->GetRootWindow());
- EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
// Drag the window just above the other display's launcher.
DragStart(window.get());
@@ -355,7 +356,7 @@ TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) {
// When dropped should move to second display's panel container.
EXPECT_EQ(root_windows[1], window->GetRootWindow());
- EXPECT_TRUE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
}
@@ -381,26 +382,26 @@ TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) {
// When dropped should move to second display's panel container.
EXPECT_EQ(root_windows[1], window->GetRootWindow());
- EXPECT_TRUE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
}
TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) {
scoped_ptr<aura::Window> window(
CreatePanelWindow(gfx::Rect(0, 0, 201, 201)));
- EXPECT_TRUE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
DragStart(window.get());
DragMove(0, -100);
DragRevert();
- EXPECT_TRUE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id());
// Detach panel.
DragStart(window.get());
DragMove(0, -100);
DragEnd();
- EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
window->parent()->id());
@@ -410,7 +411,7 @@ TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) {
// When the drag is reverted it should remain detached.
DragRevert();
- EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached());
+ EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
window->parent()->id());
}
diff --git a/ash/wm/property_util.cc b/ash/wm/property_util.cc
deleted file mode 100644
index f78eebd..0000000
--- a/ash/wm/property_util.cc
+++ /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.
-
-#include "ash/wm/property_util.h"
-
-#include "ash/screen_ash.h"
-#include "ash/wm/window_properties.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/window.h"
-#include "ui/base/ui_base_types.h"
-#include "ui/gfx/rect.h"
-
-namespace ash {
-
-void SetRestoreBoundsInScreen(aura::Window* window, const gfx::Rect& bounds) {
- window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds));
-}
-
-void SetRestoreBoundsInParent(aura::Window* window, const gfx::Rect& bounds) {
- SetRestoreBoundsInScreen(window,
- ScreenAsh::ConvertRectToScreen(window->parent(), bounds));
-}
-
-const gfx::Rect* GetRestoreBoundsInScreen(aura::Window* window) {
- return window->GetProperty(aura::client::kRestoreBoundsKey);
-}
-
-gfx::Rect GetRestoreBoundsInParent(aura::Window* window) {
- const gfx::Rect* rect = GetRestoreBoundsInScreen(window);
- if (!rect)
- return gfx::Rect();
- return ScreenAsh::ConvertRectFromScreen(window->parent(), *rect);
-}
-
-void ClearRestoreBounds(aura::Window* window) {
- window->ClearProperty(aura::client::kRestoreBoundsKey);
-}
-
-void SetWindowAlwaysRestoresToRestoreBounds(aura::Window* window, bool value) {
- window->SetProperty(internal::kWindowRestoresToRestoreBounds, value);
-}
-
-bool GetWindowAlwaysRestoresToRestoreBounds(const aura::Window* window) {
- return window->GetProperty(internal::kWindowRestoresToRestoreBounds);
-}
-
-} // namespace ash
diff --git a/ash/wm/property_util.h b/ash/wm/property_util.h
deleted file mode 100644
index 6a0d89a..0000000
--- a/ash/wm/property_util.h
+++ /dev/null
@@ -1,51 +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_PROPERTY_UTIL_H_
-#define ASH_WM_PROPERTY_UTIL_H_
-
-#include "ash/ash_export.h"
-
-namespace aura {
-class Window;
-}
-
-namespace gfx {
-class Rect;
-}
-
-namespace ash {
-
-// Sets the restore bounds property on |window| in the virtual screen
-// coordinates. Deletes existing bounds value if exists.
-ASH_EXPORT void SetRestoreBoundsInScreen(aura::Window* window,
- const gfx::Rect& screen_bounds);
-// Same as |SetRestoreBoundsInScreen| except that the bounds is in the
-// parent's coordinates.
-ASH_EXPORT void SetRestoreBoundsInParent(aura::Window* window,
- const gfx::Rect& parent_bounds);
-
-// Returns the restore bounds property on |window| in the virtual screen
-// coordinates. The bounds can be NULL if the bounds property does not
-// exist for |window|. |window| owns the bounds object.
-ASH_EXPORT const gfx::Rect* GetRestoreBoundsInScreen(aura::Window* window);
-// Same as |GetRestoreBoundsInScreen| except that it returns the
-// bounds in the parent's coordinates.
-ASH_EXPORT gfx::Rect GetRestoreBoundsInParent(aura::Window* window);
-
-// Deletes and clears the restore bounds property on |window|.
-ASH_EXPORT void ClearRestoreBounds(aura::Window* window);
-
-// Sets whether |window| should always be restored to the restore bounds
-// (sometimes the workspace layout manager restores the window to its original
-// bounds instead of the restore bounds. Setting this key overrides that
-// behaviour). The flag is reset to the default value after the window is
-// restored.
-ASH_EXPORT void SetWindowAlwaysRestoresToRestoreBounds(aura::Window* window,
- bool value);
-ASH_EXPORT bool GetWindowAlwaysRestoresToRestoreBounds(
- const aura::Window* window);
-} // namespace ash
-
-#endif // ASH_WM_PROPERTY_UTIL_H_
diff --git a/ash/wm/stacking_controller.cc b/ash/wm/stacking_controller.cc
index d846c78..0d23d69 100644
--- a/ash/wm/stacking_controller.cc
+++ b/ash/wm/stacking_controller.cc
@@ -10,7 +10,7 @@
#include "ash/shell_window_ids.h"
#include "ash/wm/always_on_top_controller.h"
#include "ash/wm/coordinate_conversion.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -92,7 +92,7 @@ aura::Window* StackingController::GetDefaultParent(aura::Window* context,
return GetContainerById(
target_root, internal::kShellWindowId_UnparentedControlContainer);
case aura::client::WINDOW_TYPE_PANEL:
- if (wm::GetWindowSettings(window)->panel_attached())
+ if (wm::GetWindowState(window)->panel_attached())
return GetContainerById(target_root,
internal::kShellWindowId_PanelContainer);
else
diff --git a/ash/wm/stacking_controller_unittest.cc b/ash/wm/stacking_controller_unittest.cc
index 6f5d1f8..b7b1f1b 100644
--- a/ash/wm/stacking_controller_unittest.cc
+++ b/ash/wm/stacking_controller_unittest.cc
@@ -5,7 +5,6 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc
index c7305a0..80ec248 100644
--- a/ash/wm/system_gesture_event_filter_unittest.cc
+++ b/ash/wm/system_gesture_event_filter_unittest.cc
@@ -18,6 +18,7 @@
#include "ash/test/test_launcher_delegate.h"
#include "ash/volume_control_delegate.h"
#include "ash/wm/gestures/long_press_affordance_handler.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/time/time.h"
@@ -353,13 +354,16 @@ TEST_F(SystemGestureEventFilterTest, MultiFingerSwipeGestures) {
// Swipe down to minimize.
generator.GestureMultiFingerScroll(kTouchPoints, points, 15, kSteps, 0, 150);
- EXPECT_TRUE(wm::IsWindowMinimized(toplevel->GetNativeWindow()));
+
+ wm::WindowState* toplevel_state =
+ wm::GetWindowState(toplevel->GetNativeWindow());
+ EXPECT_TRUE(toplevel_state->IsMinimized());
toplevel->Restore();
// Swipe up to maximize.
generator.GestureMultiFingerScroll(kTouchPoints, points, 15, kSteps, 0, -150);
- EXPECT_TRUE(wm::IsWindowMaximized(toplevel->GetNativeWindow()));
+ EXPECT_TRUE(toplevel_state->IsMaximized());
toplevel->Restore();
@@ -405,16 +409,18 @@ TEST_F(SystemGestureEventFilterTest, TwoFingerDrag) {
aura::test::EventGenerator generator(root_window,
toplevel->GetNativeWindow());
+ wm::WindowState* toplevel_state =
+ wm::GetWindowState(toplevel->GetNativeWindow());
// Swipe down to minimize.
generator.GestureMultiFingerScroll(kTouchPoints, points, 15, kSteps, 0, 150);
- EXPECT_TRUE(wm::IsWindowMinimized(toplevel->GetNativeWindow()));
+ EXPECT_TRUE(toplevel_state->IsMinimized());
toplevel->Restore();
toplevel->GetNativeWindow()->SetBounds(bounds);
// Swipe up to maximize.
generator.GestureMultiFingerScroll(kTouchPoints, points, 15, kSteps, 0, -150);
- EXPECT_TRUE(wm::IsWindowMaximized(toplevel->GetNativeWindow()));
+ EXPECT_TRUE(toplevel_state->IsMaximized());
toplevel->Restore();
toplevel->GetNativeWindow()->SetBounds(bounds);
@@ -496,14 +502,16 @@ TEST_F(SystemGestureEventFilterTest, WindowsWithMaxSizeDontSnap) {
// Swipe down to minimize.
generator.GestureMultiFingerScroll(kTouchPoints, points, 15, kSteps, 0, 150);
- EXPECT_TRUE(wm::IsWindowMinimized(toplevel->GetNativeWindow()));
+ wm::WindowState* toplevel_state =
+ wm::GetWindowState(toplevel->GetNativeWindow());
+ EXPECT_TRUE(toplevel_state->IsMinimized());
toplevel->Restore();
toplevel->GetNativeWindow()->SetBounds(bounds);
// Check that swiping up doesn't maximize.
generator.GestureMultiFingerScroll(kTouchPoints, points, 15, kSteps, 0, -150);
- EXPECT_FALSE(wm::IsWindowMaximized(toplevel->GetNativeWindow()));
+ EXPECT_FALSE(toplevel_state->IsMaximized());
toplevel->Restore();
toplevel->GetNativeWindow()->SetBounds(bounds);
diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/toplevel_window_event_handler.cc
index d58087d..213f79d 100644
--- a/ash/wm/toplevel_window_event_handler.cc
+++ b/ash/wm/toplevel_window_event_handler.cc
@@ -5,10 +5,9 @@
#include "ash/wm/toplevel_window_event_handler.h"
#include "ash/shell.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/resize_shadow_controller.h"
#include "ash/wm/window_resizer.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "base/message_loop/message_loop.h"
@@ -104,10 +103,9 @@ void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowHierarchyChanging(
const HierarchyChangeParams& params) {
if (params.receiver != resizer_->GetTarget())
return;
-
- if (wm::GetWindowSettings(params.receiver)->continue_drag_after_reparent()) {
- wm::GetWindowSettings(params.receiver)->
- set_continue_drag_after_reparent(false);
+ wm::WindowState* state = wm::GetWindowState(params.receiver);
+ if (state->continue_drag_after_reparent()) {
+ state->set_continue_drag_after_reparent(false);
AddHandlers(params.new_parent);
} else {
handler_->CompleteDrag(DRAG_COMPLETE, 0);
@@ -118,7 +116,8 @@ void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowPropertyChanged(
aura::Window* window,
const void* key,
intptr_t old) {
- if (key == aura::client::kShowStateKey && !wm::IsWindowNormal(window))
+ if (key == aura::client::kShowStateKey &&
+ !wm::GetWindowState(window)->IsNormalShowState())
handler_->CompleteDrag(DRAG_COMPLETE, 0);
}
@@ -287,22 +286,24 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
target->delegate()->GetNonClientComponent(event->location());
if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0)
return;
- if (!wm::IsWindowNormal(target))
+
+ wm::WindowState* window_state = wm::GetWindowState(target);
+ if (!window_state->IsNormalShowState())
return;
if (fabs(event->details().velocity_y()) >
kMinVertVelocityForWindowMinimize) {
// Minimize/maximize.
if (event->details().velocity_y() > 0 &&
- wm::CanMinimizeWindow(target)) {
- wm::MinimizeWindow(target);
- SetWindowAlwaysRestoresToRestoreBounds(target, true);
- SetRestoreBoundsInParent(target, pre_drag_window_bounds_);
- } else if (wm::CanMaximizeWindow(target)) {
- SetRestoreBoundsInParent(target, pre_drag_window_bounds_);
- wm::MaximizeWindow(target);
+ window_state->CanMinimize()) {
+ window_state->Minimize();
+ window_state->set_always_restores_to_restore_bounds(true);
+ window_state->SetRestoreBoundsInParent(pre_drag_window_bounds_);
+ } else if (window_state->CanMaximize()) {
+ window_state->SetRestoreBoundsInParent(pre_drag_window_bounds_);
+ window_state->Maximize();
}
- } else if (wm::CanSnapWindow(target) &&
+ } else if (window_state->CanSnap() &&
fabs(event->details().velocity_x()) >
kMinHorizVelocityForWindowSwipe) {
// Snap left/right.
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc
index ab6012e..b51a330 100644
--- a/ash/wm/toplevel_window_event_handler_unittest.cc
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc
@@ -10,9 +10,9 @@
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/lock_state_controller_impl2.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/resize_shadow.h"
#include "ash/wm/resize_shadow_controller.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "ash/wm/workspace_controller.h"
@@ -438,12 +438,14 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) {
base::TimeDelta::FromMilliseconds(5),
10);
RunAllPendingInMessageLoop();
+
+ wm::WindowState* window_state = wm::GetWindowState(target.get());
EXPECT_NE(old_bounds.ToString(), target->bounds().ToString());
- EXPECT_TRUE(wm::IsWindowMaximized(target.get()));
+ EXPECT_TRUE(window_state->IsMaximized());
EXPECT_EQ(old_bounds.ToString(),
- GetRestoreBoundsInScreen(target.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
- wm::RestoreWindow(target.get());
+ window_state->Restore();
target->SetBounds(old_bounds);
// Minimize.
@@ -454,10 +456,10 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) {
10);
RunAllPendingInMessageLoop();
EXPECT_NE(old_bounds.ToString(), target->bounds().ToString());
- EXPECT_TRUE(wm::IsWindowMinimized(target.get()));
- EXPECT_TRUE(GetWindowAlwaysRestoresToRestoreBounds(target.get()));
+ EXPECT_TRUE(window_state->IsMinimized());
+ EXPECT_TRUE(window_state->always_restores_to_restore_bounds());
EXPECT_EQ(old_bounds.ToString(),
- GetRestoreBoundsInScreen(target.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
}
// Tests that a gesture cannot minimize a window in login/lock screen.
@@ -485,7 +487,7 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDragMinimizeLoginScreen) {
base::TimeDelta::FromMilliseconds(5),
10);
RunAllPendingInMessageLoop();
- EXPECT_FALSE(wm::IsWindowMinimized(target.get()));
+ EXPECT_FALSE(wm::GetWindowState(target.get())->IsMinimized());
}
TEST_F(ToplevelWindowEventHandlerTest, GestureDragToRestore) {
@@ -495,7 +497,8 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDragToRestore) {
0,
gfx::Rect(10, 20, 30, 40)));
window->Show();
- ash::wm::ActivateWindow(window.get());
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->Activate();
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
window.get());
@@ -508,10 +511,10 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDragToRestore) {
10);
RunAllPendingInMessageLoop();
EXPECT_NE(old_bounds.ToString(), window->bounds().ToString());
- EXPECT_TRUE(wm::IsWindowMinimized(window.get()));
- EXPECT_TRUE(GetWindowAlwaysRestoresToRestoreBounds(window.get()));
+ EXPECT_TRUE(window_state->IsMinimized());
+ EXPECT_TRUE(window_state->always_restores_to_restore_bounds());
EXPECT_EQ(old_bounds.ToString(),
- GetRestoreBoundsInScreen(window.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
}
// Tests that an unresizable window cannot be dragged or snapped using gestures.
@@ -655,9 +658,9 @@ TEST_F(ToplevelWindowEventHandlerTest, MAYBE_MinimizeMaximizeCompletes) {
generator.MoveMouseBy(10, 11);
RunAllPendingInMessageLoop();
EXPECT_EQ("10,11 100x100", target->bounds().ToString());
-
- wm::MinimizeWindow(target.get());
- wm::RestoreWindow(target.get());
+ wm::WindowState* window_state = wm::GetWindowState(target.get());
+ window_state->Minimize();
+ window_state->Restore();
generator.PressLeftButton();
generator.MoveMouseBy(10, 11);
@@ -675,9 +678,9 @@ TEST_F(ToplevelWindowEventHandlerTest, MAYBE_MinimizeMaximizeCompletes) {
generator.MoveMouseBy(10, 11);
RunAllPendingInMessageLoop();
EXPECT_EQ("10,11 100x100", target->bounds().ToString());
-
- wm::MaximizeWindow(target.get());
- wm::RestoreWindow(target.get());
+ wm::WindowState* window_state = wm::GetWindowState(target.get());
+ window_state->Maximize();
+ window_state->Restore();
generator.PressLeftButton();
generator.MoveMouseBy(10, 11);
diff --git a/ash/wm/user_activity_detector.cc b/ash/wm/user_activity_detector.cc
index 21503f3..64cfbe3 100644
--- a/ash/wm/user_activity_detector.cc
+++ b/ash/wm/user_activity_detector.cc
@@ -4,7 +4,6 @@
#include "ash/wm/user_activity_detector.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/user_activity_observer.h"
#include "ui/events/event.h"
diff --git a/ash/wm/video_detector.cc b/ash/wm/video_detector.cc
index 743b49c..cf7436e 100644
--- a/ash/wm/video_detector.cc
+++ b/ash/wm/video_detector.cc
@@ -5,6 +5,7 @@
#include "ash/wm/video_detector.h"
#include "ash/shell.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
@@ -122,8 +123,8 @@ void VideoDetector::MaybeNotifyObservers(aura::Window* window,
return;
aura::Window* toplevel_window = wm::GetActivatableWindow(window);
- bool is_fullscreen =
- toplevel_window ? wm::IsWindowFullscreen(toplevel_window) : false;
+ bool is_fullscreen = toplevel_window ?
+ wm::GetWindowState(toplevel_window)->IsFullscreen() : false;
FOR_EACH_OBSERVER(VideoDetectorObserver,
observers_,
diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc
index 7cb4bbc..ef1f1e5 100644
--- a/ash/wm/window_cycle_controller_unittest.cc
+++ b/ash/wm/window_cycle_controller_unittest.cc
@@ -12,6 +12,7 @@
#include "ash/test/ash_test_base.h"
#include "ash/test/test_shell_delegate.h"
#include "ash/wm/window_cycle_list.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/client/aura_constants.h"
@@ -185,20 +186,20 @@ TEST_F(WindowCycleControllerTest, MaximizedWindow) {
// Create a couple of test windows.
scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
-
- wm::MaximizeWindow(window1.get());
- wm::ActivateWindow(window1.get());
- EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
+ window1_state->Maximize();
+ window1_state->Activate();
+ EXPECT_TRUE(window1_state->IsActive());
// Rotate focus, this should move focus to window0.
WindowCycleController* controller =
Shell::GetInstance()->window_cycle_controller();
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
- EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
+ EXPECT_TRUE(wm::GetWindowState(window0.get())->IsActive());
// One more time.
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
- EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
+ EXPECT_TRUE(window1_state->IsActive());
}
// Cycles to a minimized window.
@@ -206,21 +207,23 @@ TEST_F(WindowCycleControllerTest, Minimized) {
// Create a couple of test windows.
scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
+ wm::WindowState* window0_state = wm::GetWindowState(window0.get());
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
- wm::MinimizeWindow(window1.get());
- wm::ActivateWindow(window0.get());
- EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
+ window1_state->Minimize();
+ window0_state->Activate();
+ EXPECT_TRUE(window0_state->IsActive());
// Rotate focus, this should move focus to window1 and unminimize it.
WindowCycleController* controller =
Shell::GetInstance()->window_cycle_controller();
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
- EXPECT_FALSE(wm::IsWindowMinimized(window1.get()));
- EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
+ EXPECT_FALSE(window1_state->IsMinimized());
+ EXPECT_TRUE(window1_state->IsActive());
// One more time back to w0.
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
- EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
+ EXPECT_TRUE(window0_state->IsActive());
}
TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) {
diff --git a/ash/wm/window_properties.cc b/ash/wm/window_properties.cc
index 39291cc..4df599a 100644
--- a/ash/wm/window_properties.cc
+++ b/ash/wm/window_properties.cc
@@ -4,8 +4,10 @@
#include "ash/wm/window_properties.h"
+#include "ash/wm/window_state.h"
#include "ui/aura/window_property.h"
-#include "ui/gfx/rect.h"
+
+DECLARE_WINDOW_PROPERTY_TYPE(ash::wm::WindowState*);
namespace ash {
namespace internal {
@@ -13,10 +15,7 @@ DEFINE_WINDOW_PROPERTY_KEY(bool, kAnimateToFullscreenKey, true);
DEFINE_WINDOW_PROPERTY_KEY(bool, kFullscreenUsesMinimalChromeKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kStayInSameRootWindowKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kUsesScreenCoordinatesKey, false);
-DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Rect,
- kPreAutoManagedWindowBoundsKey,
- NULL);
-DEFINE_WINDOW_PROPERTY_KEY(bool, kWindowRestoresToRestoreBounds, false);
-
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(wm::WindowState,
+ kWindowStateKey, NULL);
} // namespace internal
} // namespace ash
diff --git a/ash/wm/window_properties.h b/ash/wm/window_properties.h
index 20154da..1bf28ff 100644
--- a/ash/wm/window_properties.h
+++ b/ash/wm/window_properties.h
@@ -6,15 +6,19 @@
#define ASH_WM_WINDOW_PROPERTIES_H_
#include "ash/ash_export.h"
-#include "ash/wm/property_util.h"
-#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
-namespace gfx {
-class Rect;
+namespace aura {
+class Window;
+
+template<typename T>
+struct WindowProperty;
}
namespace ash {
+namespace wm {
+class WindowState;
+} // namespace wm
namespace internal {
// Shell-specific window property keys.
@@ -37,18 +41,12 @@ ASH_EXPORT extern const aura::WindowProperty<bool>* const
ASH_EXPORT extern const aura::WindowProperty<bool>* const
kStayInSameRootWindowKey;
-// A property to remember the window position which was set before the
-// auto window position manager changed the window bounds, so that it can get
-// restored when only this one window gets shown.
-ASH_EXPORT extern const aura::WindowProperty<gfx::Rect*>* const
- kPreAutoManagedWindowBoundsKey;
-
// Property to tell if the container uses the screen coordinates.
extern const aura::WindowProperty<bool>* const kUsesScreenCoordinatesKey;
-// A property key to tell the workspace layout manager to always restore the
-// window to the restore-bounds (false by default).
-extern const aura::WindowProperty<bool>* const kWindowRestoresToRestoreBounds;
+// A property key to store WindowState in the window. The window state
+// is owned by the window.
+extern const aura::WindowProperty<wm::WindowState*>* const kWindowStateKey;
// Alphabetical sort.
diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc
index 1ea317a..65b390a 100644
--- a/ash/wm/window_resizer.cc
+++ b/ash/wm/window_resizer.cc
@@ -9,7 +9,7 @@
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/dock/docked_window_layout_manager.h"
-#include "ash/wm/property_util.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
@@ -106,6 +106,7 @@ const int WindowResizer::kBoundsChangeDirection_Vertical = 2;
WindowResizer::Details::Details()
: window(NULL),
+ window_state(NULL),
window_component(HTNOWHERE),
bounds_change(0),
position_change_direction(0),
@@ -119,6 +120,7 @@ WindowResizer::Details::Details(aura::Window* window,
int window_component,
aura::client::WindowMoveSource source)
: window(window),
+ window_state(wm::GetWindowState(window)),
initial_bounds_in_parent(window->bounds()),
restore_bounds(gfx::Rect()),
initial_location_in_parent(location),
@@ -131,10 +133,10 @@ WindowResizer::Details::Details(aura::Window* window,
GetSizeChangeDirectionForWindowComponent(window_component)),
is_resizable(bounds_change != kBoundsChangeDirection_None),
source(source) {
- if (wm::IsWindowNormal(window) &&
- GetRestoreBoundsInScreen(window) &&
+ if (window_state->IsNormalShowState() &&
+ window_state->HasRestoreBounds() &&
window_component == HTCAPTION)
- restore_bounds = *GetRestoreBoundsInScreen(window);
+ restore_bounds = window_state->GetRestoreBoundsInScreen();
}
WindowResizer::Details::~Details() {
diff --git a/ash/wm/window_resizer.h b/ash/wm/window_resizer.h
index 6583d89..29479b3 100644
--- a/ash/wm/window_resizer.h
+++ b/ash/wm/window_resizer.h
@@ -16,6 +16,9 @@ class Window;
}
namespace ash {
+namespace wm {
+class WindowState;
+}
// WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving
// or resizing a window. All coordinates passed to this are in the parent
@@ -65,8 +68,13 @@ class ASH_EXPORT WindowResizer {
~Details();
// The window we're resizing.
+ // TODO(oshima): replace this with accessor method to
+ // |window_state->window()|.
aura::Window* window;
+ // The ash window state for the |window| above.
+ wm::WindowState* window_state;
+
// Initial bounds of the window in parent coordinates.
gfx::Rect initial_bounds_in_parent;
diff --git a/ash/wm/window_settings.cc b/ash/wm/window_settings.cc
deleted file mode 100644
index cd62688..0000000
--- a/ash/wm/window_settings.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/wm/window_settings.h"
-
-#include "ui/aura/window.h"
-#include "ui/aura/window_property.h"
-#include "ui/gfx/display.h"
-
-DECLARE_WINDOW_PROPERTY_TYPE(ash::wm::WindowSettings*);
-
-namespace ash {
-namespace wm {
-
-DEFINE_OWNED_WINDOW_PROPERTY_KEY(WindowSettings,
- kWindowSettingsKey, NULL);
-
-WindowSettings::WindowSettings(aura::Window* window)
- : window_(window),
- tracked_by_workspace_(true),
- window_position_managed_(false),
- bounds_changed_by_user_(false),
- panel_attached_(true),
- continue_drag_after_reparent_(false),
- ignored_by_shelf_(false) {
-}
-
-WindowSettings::~WindowSettings() {
-}
-
-void WindowSettings::AddObserver(Observer* observer) {
- observer_list_.AddObserver(observer);
-}
-
-void WindowSettings::RemoveObserver(Observer* observer) {
- observer_list_.RemoveObserver(observer);
-}
-
-void WindowSettings::SetTrackedByWorkspace(bool tracked_by_workspace) {
- if (tracked_by_workspace_ == tracked_by_workspace)
- return;
- bool old = tracked_by_workspace_;
- tracked_by_workspace_ = tracked_by_workspace;
- FOR_EACH_OBSERVER(Observer, observer_list_,
- OnTrackedByWorkspaceChanged(window_, old));
-}
-
-WindowSettings* GetWindowSettings(aura::Window* window) {
- WindowSettings* settings = window->GetProperty(kWindowSettingsKey);
- if(!settings) {
- settings = new WindowSettings(window);
- window->SetProperty(kWindowSettingsKey, settings);
- }
- return settings;
-}
-
-const WindowSettings* GetWindowSettings(const aura::Window* window) {
- return GetWindowSettings(const_cast<aura::Window*>(window));
-}
-
-} // namespace wm
-} // namespace ash
diff --git a/ash/wm/window_settings.h b/ash/wm/window_settings.h
deleted file mode 100644
index 749ff2e..0000000
--- a/ash/wm/window_settings.h
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_WM_WINDOW_SETTINGS_H_
-#define ASH_WM_WINDOW_SETTINGS_H_
-
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "base/observer_list.h"
-
-namespace aura {
-class Window;
-}
-
-namespace ash {
-namespace wm {
-
-// Per managed window information should be stored here
-// instead of using plain aura window property.
-class ASH_EXPORT WindowSettings {
- public:
- class ASH_EXPORT Observer {
- public:
- // Called when the tracked_by_workspace has changed.
- virtual void OnTrackedByWorkspaceChanged(aura::Window* window,
- bool old_value) {}
- };
-
- explicit WindowSettings(aura::Window* window);
- ~WindowSettings();
-
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
-
- // Whether the window is tracked by workspace code. Default is
- // true. If set to false the workspace does not switch the current
- // workspace, nor does it attempt to impose constraints on the
- // bounds of the window. This is intended for tab dragging.
- bool tracked_by_workspace() const { return tracked_by_workspace_; }
- void SetTrackedByWorkspace(bool tracked_by_workspace);
-
- // Whether or not the window's position can be managed by the
- // auto management logic.
- bool window_position_managed() const { return window_position_managed_; }
- void set_window_position_managed(bool window_position_managed) {
- window_position_managed_ = window_position_managed;
- }
-
- // Whether or not the window's position or size was changed by a user.
- bool bounds_changed_by_user() const { return bounds_changed_by_user_; }
- void set_bounds_changed_by_user(bool bounds_changed_by_user) {
- bounds_changed_by_user_ = bounds_changed_by_user;
- }
-
- // True if this window is an attached panel.
- bool panel_attached() const {
- return panel_attached_;
- }
- void set_panel_attached(bool panel_attached) {
- panel_attached_ = panel_attached;
- }
-
- // Indicates that an in progress drag should be continued after the
- // window is reparented to another container.
- bool continue_drag_after_reparent() const {
- return continue_drag_after_reparent_;
- }
- void set_continue_drag_after_reparent(bool value) {
- continue_drag_after_reparent_ = value;
- }
-
- // True if the window is ignored by the shelf layout manager for
- // purposes of darkening the shelf.
- bool ignored_by_shelf() const { return ignored_by_shelf_; }
- void set_ignored_by_shelf(bool ignored_by_shelf) {
- ignored_by_shelf_ = ignored_by_shelf;
- }
-
- private:
- // The owner of this window settings.
- aura::Window* window_;
-
- bool tracked_by_workspace_;
- bool window_position_managed_;
- bool bounds_changed_by_user_;
- bool panel_attached_;
- bool continue_drag_after_reparent_;
- bool ignored_by_shelf_;
-
- ObserverList<Observer> observer_list_;
-
- DISALLOW_COPY_AND_ASSIGN(WindowSettings);
-};
-
-// Returns the WindowSettings for |window|. Creates WindowSettings
-// if it didn't exist. The settings object is owned by |window|.
-ASH_EXPORT WindowSettings* GetWindowSettings(aura::Window* window);
-
-// const version of GetWindowSettings.
-ASH_EXPORT const WindowSettings*
-GetWindowSettings(const aura::Window* window);
-
-} // namespace wm
-} // namespace ash
-
-#endif // ASH_WM_WINDOW_SETTINGS_H_
diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc
new file mode 100644
index 0000000..bbb3fc7
--- /dev/null
+++ b/ash/wm/window_state.cc
@@ -0,0 +1,223 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/window_state.h"
+
+#include "ash/root_window_controller.h"
+#include "ash/screen_ash.h"
+#include "ash/shell_window_ids.h"
+#include "ash/wm/window_properties.h"
+#include "ash/wm/window_util.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_delegate.h"
+#include "ui/gfx/display.h"
+#include "ui/views/corewm/window_util.h"
+
+namespace ash {
+namespace wm {
+
+// static
+bool WindowState::IsMaximizedOrFullscreenState(ui::WindowShowState show_state) {
+ return show_state == ui::SHOW_STATE_FULLSCREEN ||
+ show_state == ui::SHOW_STATE_MAXIMIZED;
+}
+
+WindowState::WindowState(aura::Window* window)
+ : window_(window),
+ tracked_by_workspace_(true),
+ window_position_managed_(false),
+ bounds_changed_by_user_(false),
+ panel_attached_(true),
+ continue_drag_after_reparent_(false),
+ ignored_by_shelf_(false),
+ always_restores_to_restore_bounds_(false) {
+}
+
+WindowState::~WindowState() {
+}
+
+ui::WindowShowState WindowState::GetShowState() const {
+ return window_->GetProperty(aura::client::kShowStateKey);
+}
+
+bool WindowState::IsMinimized() const {
+ return GetShowState() == ui::SHOW_STATE_MINIMIZED;
+}
+
+bool WindowState::IsMaximized() const {
+ return GetShowState() == ui::SHOW_STATE_MAXIMIZED;
+}
+
+bool WindowState::IsFullscreen() const {
+ return GetShowState() == ui::SHOW_STATE_FULLSCREEN;
+}
+
+bool WindowState::IsMaximizedOrFullscreen() const {
+ return IsMaximizedOrFullscreenState(GetShowState());
+}
+
+bool WindowState::IsNormalShowState() const {
+ ui::WindowShowState state = window_->GetProperty(aura::client::kShowStateKey);
+ return state == ui::SHOW_STATE_NORMAL || state == ui::SHOW_STATE_DEFAULT;
+}
+
+bool WindowState::IsActive() const {
+ return IsActiveWindow(window_);
+}
+
+bool WindowState::CanMaximize() const {
+ return window_->GetProperty(aura::client::kCanMaximizeKey);
+}
+
+bool WindowState::CanMinimize() const {
+ internal::RootWindowController* controller =
+ internal::RootWindowController::ForWindow(window_);
+ if (!controller)
+ return false;
+ aura::Window* lockscreen = controller->GetContainer(
+ internal::kShellWindowId_LockScreenContainersContainer);
+ if (lockscreen->Contains(window_))
+ return false;
+
+ return true;
+}
+
+bool WindowState::CanResize() const {
+ return window_->GetProperty(aura::client::kCanResizeKey);
+}
+
+bool WindowState::CanActivate() const {
+ return views::corewm::CanActivateWindow(window_);
+}
+
+bool WindowState::CanSnap() const {
+ if (!CanResize())
+ return false;
+ if (window_->type() == aura::client::WINDOW_TYPE_PANEL)
+ return false;
+ // If a window has a maximum size defined, snapping may make it too big.
+ return window_->delegate() ? window_->delegate()->GetMaximumSize().IsEmpty() :
+ true;
+}
+
+bool WindowState::HasRestoreBounds() const {
+ return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL;
+}
+
+void WindowState::Maximize() {
+ window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+}
+
+void WindowState::Minimize() {
+ window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
+}
+
+void WindowState::Unminimize() {
+ window_->SetProperty(
+ aura::client::kShowStateKey,
+ window_->GetProperty(aura::client::kRestoreShowStateKey));
+ window_->ClearProperty(aura::client::kRestoreShowStateKey);
+}
+
+void WindowState::Activate() {
+ ActivateWindow(window_);
+}
+
+void WindowState::Deactivate() {
+ DeactivateWindow(window_);
+}
+
+void WindowState::Restore() {
+ window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
+}
+
+void WindowState::ToggleMaximized() {
+ if (IsMaximized())
+ Restore();
+ else if (CanMaximize())
+ Maximize();
+}
+
+void WindowState::SetBoundsInScreen(
+ const gfx::Rect& bounds_in_screen) {
+ gfx::Rect bounds_in_parent =
+ ScreenAsh::ConvertRectFromScreen(window_->parent(),
+ bounds_in_screen);
+ window_->SetBounds(bounds_in_parent);
+}
+
+void WindowState::SaveCurrentBoundsForRestore() {
+ gfx::Rect bounds_in_screen =
+ ScreenAsh::ConvertRectToScreen(window_->parent(),
+ window_->bounds());
+ SetRestoreBoundsInScreen(bounds_in_screen);
+}
+
+gfx::Rect WindowState::GetRestoreBoundsInScreen() const {
+ return *window_->GetProperty(aura::client::kRestoreBoundsKey);
+}
+
+gfx::Rect WindowState::GetRestoreBoundsInParent() const {
+ return ScreenAsh::ConvertRectFromScreen(window_->parent(),
+ GetRestoreBoundsInScreen());
+}
+
+void WindowState::SetRestoreBoundsInScreen(const gfx::Rect& bounds) {
+ window_->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds));
+}
+
+void WindowState::SetRestoreBoundsInParent(const gfx::Rect& bounds) {
+ SetRestoreBoundsInScreen(
+ ScreenAsh::ConvertRectToScreen(window_->parent(), bounds));
+}
+
+void WindowState::ClearRestoreBounds() {
+ window_->ClearProperty(aura::client::kRestoreBoundsKey);
+}
+
+void WindowState::SetPreAutoManageWindowBounds(
+ const gfx::Rect& bounds) {
+ pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds));
+}
+
+void WindowState::AddObserver(Observer* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void WindowState::RemoveObserver(Observer* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
+void WindowState::SetTrackedByWorkspace(bool tracked_by_workspace) {
+ if (tracked_by_workspace_ == tracked_by_workspace)
+ return;
+ bool old = tracked_by_workspace_;
+ tracked_by_workspace_ = tracked_by_workspace;
+ FOR_EACH_OBSERVER(Observer, observer_list_,
+ OnTrackedByWorkspaceChanged(window_, old));
+}
+
+WindowState* GetActiveWindowState() {
+ aura::Window* active = GetActiveWindow();
+ return active ? GetWindowState(active) : NULL;
+}
+
+WindowState* GetWindowState(aura::Window* window) {
+ if (!window)
+ return NULL;
+ WindowState* settings = window->GetProperty(internal::kWindowStateKey);
+ if(!settings) {
+ settings = new WindowState(window);
+ window->SetProperty(internal::kWindowStateKey, settings);
+ }
+ return settings;
+}
+
+const WindowState* GetWindowState(const aura::Window* window) {
+ return GetWindowState(const_cast<aura::Window*>(window));
+}
+
+} // namespace wm
+} // namespace ash
diff --git a/ash/wm/window_state.h b/ash/wm/window_state.h
new file mode 100644
index 0000000..6145de0
--- /dev/null
+++ b/ash/wm/window_state.h
@@ -0,0 +1,216 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_WM_WINDOW_STATE_H_
+#define ASH_WM_WINDOW_STATE_H_
+
+#include "ash/ash_export.h"
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+#include "ui/base/ui_base_types.h"
+
+namespace aura {
+class Window;
+}
+
+namespace gfx {
+class Rect;
+}
+
+namespace ash {
+namespace wm {
+
+// WindowState manages and defines ash specific window state and
+// behavior. Ash specific per-window state (such as ones that controls
+// window manager behavior) and ash specific window behavior (such as
+// maximize, minimize, snap sizing etc) should be added here instead
+// of defining separate functions (like |MaximizeWindow(aura::Window*
+// window)|) or using aura Window property.
+// The WindowState gets created when first accessed by
+// |wm::GetWindowState|, and deleted when the window is deleted.
+// Prefer using this class instead of passing aura::Window* around in
+// ash code as this is often what you need to interact with, and
+// accessing the window using |window()| is cheap.
+class ASH_EXPORT WindowState {
+ public:
+ class ASH_EXPORT Observer {
+ public:
+ // Called when the tracked_by_workspace has changed.
+ virtual void OnTrackedByWorkspaceChanged(aura::Window* window,
+ bool old_value) {}
+ };
+
+ static bool IsMaximizedOrFullscreenState(ui::WindowShowState state);
+
+ explicit WindowState(aura::Window* window);
+ ~WindowState();
+
+ aura::Window* window() { return window_; }
+ const aura::Window* window() const { return window_; }
+
+ // Returns the window's current shows tate.
+ ui::WindowShowState GetShowState() const;
+
+ // Predicates to check window state.
+ bool IsMinimized() const;
+ bool IsMaximized() const;
+ bool IsFullscreen() const;
+ bool IsMaximizedOrFullscreen() const;
+ // True if the window's show state is SHOW_STATE_NORMAL or
+ // SHOW_STATE_DEFAULT.
+ bool IsNormalShowState() const;
+ bool IsActive() const;
+
+ // Checks if the window can change its state accordingly.
+ bool CanMaximize() const;
+ bool CanMinimize() const;
+ bool CanResize() const;
+ bool CanSnap() const;
+ bool CanActivate() const;
+
+ // Returns true if the window has restore bounds.
+ bool HasRestoreBounds() const;
+
+ void Maximize();
+ void Minimize();
+ void Unminimize();
+ void Activate();
+ void Deactivate();
+ void Restore();
+ void ToggleMaximized();
+
+ // Sets the window's bounds in screen coordinates.
+ void SetBoundsInScreen(const gfx::Rect& bounds_in_screen);
+
+ // Saves the current bounds to be used as a restore bounds.
+ void SaveCurrentBoundsForRestore();
+
+ // Same as |GetRestoreBoundsInScreen| except that it returns the
+ // bounds in the parent's coordinates.
+ gfx::Rect GetRestoreBoundsInParent() const;
+
+ // Returns the restore bounds property on the window in the virtual screen
+ // coordinates. The bounds can be NULL if the bounds property does not
+ // exist for the window. The window owns the bounds object.
+ gfx::Rect GetRestoreBoundsInScreen() const;
+
+ // Same as |SetRestoreBoundsInScreen| except that the bounds is in the
+ // parent's coordinates.
+ void SetRestoreBoundsInParent(const gfx::Rect& bounds_in_parent);
+
+ // Sets the restore bounds property on the window in the virtual screen
+ // coordinates. Deletes existing bounds value if exists.
+ void SetRestoreBoundsInScreen(const gfx::Rect& bounds_in_screen);
+
+ // Deletes and clears the restore bounds property on the window.
+ void ClearRestoreBounds();
+
+ // Sets whether the window should always be restored to the restore bounds
+ // (sometimes the workspace layout manager restores the window to its original
+ // bounds instead of the restore bounds. Setting this key overrides that
+ // behaviour). The flag is reset to the default value after the window is
+ // restored.
+ bool always_restores_to_restore_bounds() const {
+ return always_restores_to_restore_bounds_;
+ }
+ void set_always_restores_to_restore_bounds(bool value) {
+ always_restores_to_restore_bounds_ = value;
+ }
+
+ // Gets/Sets the bounds of the window before it was moved by the auto window
+ // management. As long as it was not auto-managed, it will return NULL.
+ const gfx::Rect* pre_auto_manage_window_bounds() const {
+ return pre_auto_manage_window_bounds_.get();
+ }
+ void SetPreAutoManageWindowBounds(const gfx::Rect& bounds);
+
+ // Layout related properties
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ // Whether the window is tracked by workspace code. Default is
+ // true. If set to false the workspace does not switch the current
+ // workspace, nor does it attempt to impose constraints on the
+ // bounds of the window. This is intended for tab dragging.
+ bool tracked_by_workspace() const { return tracked_by_workspace_; }
+ void SetTrackedByWorkspace(bool tracked_by_workspace);
+
+ // Whether or not the window's position can be managed by the
+ // auto management logic.
+ bool window_position_managed() const { return window_position_managed_; }
+ void set_window_position_managed(bool window_position_managed) {
+ window_position_managed_ = window_position_managed;
+ }
+
+ // Whether or not the window's position or size was changed by a user.
+ bool bounds_changed_by_user() const { return bounds_changed_by_user_; }
+ void set_bounds_changed_by_user(bool bounds_changed_by_user) {
+ bounds_changed_by_user_ = bounds_changed_by_user;
+ }
+
+ // True if this window is an attached panel.
+ bool panel_attached() const {
+ return panel_attached_;
+ }
+ void set_panel_attached(bool panel_attached) {
+ panel_attached_ = panel_attached;
+ }
+
+ // Indicates that an in progress drag should be continued after the
+ // window is reparented to another container.
+ bool continue_drag_after_reparent() const {
+ return continue_drag_after_reparent_;
+ }
+ void set_continue_drag_after_reparent(bool value) {
+ continue_drag_after_reparent_ = value;
+ }
+
+ // True if the window is ignored by the shelf layout manager for
+ // purposes of darkening the shelf.
+ bool ignored_by_shelf() const { return ignored_by_shelf_; }
+ void set_ignored_by_shelf(bool ignored_by_shelf) {
+ ignored_by_shelf_ = ignored_by_shelf;
+ }
+
+ private:
+ // The owner of this window settings.
+ aura::Window* window_;
+
+ bool tracked_by_workspace_;
+ bool window_position_managed_;
+ bool bounds_changed_by_user_;
+ bool panel_attached_;
+ bool continue_drag_after_reparent_;
+ bool ignored_by_shelf_;
+
+ bool always_restores_to_restore_bounds_;
+
+ // A property to remember the window position which was set before the
+ // auto window position manager changed the window bounds, so that it can get
+ // restored when only this one window gets shown.
+ scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_;
+
+ ObserverList<Observer> observer_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowState);
+};
+
+// Returns the WindowState for active window. Returns |NULL|
+// if there is no active window.
+ASH_EXPORT WindowState* GetActiveWindowState();
+
+// Returns the WindowState for |window|. Creates WindowState
+// if it didn't exist. The settings object is owned by |window|.
+ASH_EXPORT WindowState* GetWindowState(aura::Window* window);
+
+// const version of GetWindowState.
+ASH_EXPORT const WindowState*
+GetWindowState(const aura::Window* window);
+
+} // namespace wm
+} // namespace ash
+
+#endif // ASH_WM_WINDOW_STATE_H_
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index 19028b8..6d85c83 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -7,16 +7,12 @@
#include <vector>
#include "ash/ash_constants.h"
-#include "ash/root_window_controller.h"
#include "ash/shell.h"
-#include "ash/shell_window_ids.h"
#include "ash/wm/window_properties.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
-#include "ui/aura/window_delegate.h"
-#include "ui/compositor/layer.h"
#include "ui/gfx/display.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
@@ -53,79 +49,11 @@ bool CanActivateWindow(aura::Window* window) {
return views::corewm::CanActivateWindow(window);
}
-bool CanMaximizeWindow(const aura::Window* window) {
- return window->GetProperty(aura::client::kCanMaximizeKey);
-}
-
-bool CanMinimizeWindow(const aura::Window* window) {
- internal::RootWindowController* controller =
- internal::RootWindowController::ForWindow(window);
- if (!controller)
- return false;
- aura::Window* lockscreen = controller->GetContainer(
- internal::kShellWindowId_LockScreenContainersContainer);
- if (lockscreen->Contains(window))
- return false;
-
- return true;
-}
-
-bool CanResizeWindow(const aura::Window* window) {
- return window->GetProperty(aura::client::kCanResizeKey);
-}
-
-bool CanSnapWindow(aura::Window* window) {
- if (!CanResizeWindow(window))
- return false;
- if (window->type() == aura::client::WINDOW_TYPE_PANEL)
- return false;
- // If a window has a maximum size defined, snapping may make it too big.
- return window->delegate() ? window->delegate()->GetMaximumSize().IsEmpty() :
- true;
-}
-
-bool IsWindowNormal(const aura::Window* window) {
- return IsWindowStateNormal(window->GetProperty(aura::client::kShowStateKey));
-}
-
-bool IsWindowStateNormal(ui::WindowShowState state) {
- return state == ui::SHOW_STATE_NORMAL || state == ui::SHOW_STATE_DEFAULT;
-}
-
-bool IsWindowMaximized(const aura::Window* window) {
- return window->GetProperty(aura::client::kShowStateKey) ==
- ui::SHOW_STATE_MAXIMIZED;
-}
-
-bool IsWindowMinimized(const aura::Window* window) {
+bool IsWindowMinimized(aura::Window* window) {
return window->GetProperty(aura::client::kShowStateKey) ==
ui::SHOW_STATE_MINIMIZED;
}
-bool IsWindowFullscreen(const aura::Window* window) {
- return window->GetProperty(aura::client::kShowStateKey) ==
- ui::SHOW_STATE_FULLSCREEN;
-}
-
-void MaximizeWindow(aura::Window* window) {
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
-}
-
-void MinimizeWindow(aura::Window* window) {
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
-}
-
-void RestoreWindow(aura::Window* window) {
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
-}
-
-void ToggleMaximizedWindow(aura::Window* window) {
- if (ash::wm::IsWindowMaximized(window))
- ash::wm::RestoreWindow(window);
- else if (ash::wm::CanMaximizeWindow(window))
- ash::wm::MaximizeWindow(window);
-}
-
void CenterWindow(aura::Window* window) {
const gfx::Display display =
Shell::GetScreen()->GetDisplayNearestWindow(window);
@@ -138,16 +66,6 @@ void SetAnimateToFullscreen(aura::Window* window, bool animate) {
window->SetProperty(ash::internal::kAnimateToFullscreenKey, animate);
}
-const gfx::Rect* GetPreAutoManageWindowBounds(const aura::Window* window) {
- return window->GetProperty(ash::internal::kPreAutoManagedWindowBoundsKey);
-}
-
-void SetPreAutoManageWindowBounds(aura::Window* window,
- const gfx::Rect& bounds) {
- window->SetProperty(ash::internal::kPreAutoManagedWindowBoundsKey,
- new gfx::Rect(bounds));
-}
-
void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area,
gfx::Rect* bounds) {
AdjustBoundsToEnsureWindowVisibility(
diff --git a/ash/wm/window_util.h b/ash/wm/window_util.h
index a911099..7c8ffe9 100644
--- a/ash/wm/window_util.h
+++ b/ash/wm/window_util.h
@@ -27,7 +27,7 @@ const int kMinimumOnScreenArea = 10;
namespace wm {
-// Convenience setters/getters for |aura::client::kRootWindowActiveWindow|.
+// Utility functions for window activation.
ASH_EXPORT void ActivateWindow(aura::Window* window);
ASH_EXPORT void DeactivateWindow(aura::Window* window);
ASH_EXPORT bool IsActiveWindow(aura::Window* window);
@@ -41,44 +41,8 @@ ASH_EXPORT bool CanActivateWindow(aura::Window* window);
// this is probably what you're looking for.
ASH_EXPORT aura::Window* GetActivatableWindow(aura::Window* window);
-// Returns true if |window| can be maximized.
-ASH_EXPORT bool CanMaximizeWindow(const aura::Window* window);
-
-// Returns true if |window| can be minimized.
-ASH_EXPORT bool CanMinimizeWindow(const aura::Window* window);
-
-// Returns true if |window| can be resized.
-ASH_EXPORT bool CanResizeWindow(const aura::Window* window);
-
-// Returns true if |window| can be snapped to the left or right.
-ASH_EXPORT bool CanSnapWindow(aura::Window* window);
-
-// Returns true if |window| is normal or default.
-ASH_EXPORT bool IsWindowNormal(const aura::Window* window);
-
-// Returns true if |state| is normal or default.
-ASH_EXPORT bool IsWindowStateNormal(const ui::WindowShowState state);
-
-// Returns true if |window| is in the maximized state.
-ASH_EXPORT bool IsWindowMaximized(const aura::Window* window);
-
-// Returns true if |window| is minimized.
-ASH_EXPORT bool IsWindowMinimized(const aura::Window* window);
-
-// Returns true if |window| is in the fullscreen state.
-ASH_EXPORT bool IsWindowFullscreen(const aura::Window* window);
-
-// Maximizes |window|, which must not be NULL.
-ASH_EXPORT void MaximizeWindow(aura::Window* window);
-
-// Minimizes |window|, which must not be NULL.
-ASH_EXPORT void MinimizeWindow(aura::Window* window);
-
-// Restores |window|, which must not be NULL.
-ASH_EXPORT void RestoreWindow(aura::Window* window);
-
-// Maximizes or restores |window| based on its state. |window| must not be NULL.
-ASH_EXPORT void ToggleMaximizedWindow(aura::Window* window);
+// TODO(oshima): remove this.
+ASH_EXPORT bool IsWindowMinimized(aura::Window* window);
// Moves the window to the center of the display.
ASH_EXPORT void CenterWindow(aura::Window* window);
@@ -86,16 +50,6 @@ ASH_EXPORT void CenterWindow(aura::Window* window);
// Change the availability of animation to the fullscreen of the |window|.
ASH_EXPORT void SetAnimateToFullscreen(aura::Window* window, bool animate);
-// Get |window| bounds of the window before it was moved by the auto window
-// management. As long as it was not managed, it will return NULL.
-ASH_EXPORT const gfx::Rect* GetPreAutoManageWindowBounds(
- const aura::Window* window);
-
-// Remember the |bounds| of a |window| before an automated window management
-// operation takes place.
-ASH_EXPORT void SetPreAutoManageWindowBounds(aura::Window* window,
- const gfx::Rect& bounds);
-
// Move the given bounds inside the given |visible_area|, including a
// safety margin given by |kMinimumOnScreenArea|.
ASH_EXPORT void AdjustBoundsToEnsureMinimumWindowVisibility(
diff --git a/ash/wm/workspace/auto_window_management.cc b/ash/wm/workspace/auto_window_management.cc
index fac0def..31227a6 100644
--- a/ash/wm/workspace/auto_window_management.cc
+++ b/ash/wm/workspace/auto_window_management.cc
@@ -8,9 +8,8 @@
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/wm/mru_window_tracker.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/window_animations.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "ui/aura/window.h"
@@ -30,20 +29,20 @@ const int kWindowAutoMoveDurationMS = 125;
// Check if any management should be performed (with a given |window|).
bool UseAutoWindowManager(const aura::Window* window) {
- const wm::WindowSettings* settings = wm::GetWindowSettings(window);
- return settings->tracked_by_workspace() &&
- settings->window_position_managed();
+ const wm::WindowState* window_state = wm::GetWindowState(window);
+ return window_state->tracked_by_workspace() &&
+ window_state->window_position_managed();
}
// Check if a given |window| can be managed. This includes that it's state is
// not minimized/maximized/the user has changed it's size by hand already.
// It furthermore checks for the WindowIsManaged status.
bool WindowPositionCanBeManaged(const aura::Window* window) {
- const wm::WindowSettings* settings = wm::GetWindowSettings(window);
- return settings->window_position_managed() &&
- !wm::IsWindowMinimized(window) &&
- !wm::IsWindowMaximized(window) &&
- !settings->bounds_changed_by_user();
+ const wm::WindowState* window_state = wm::GetWindowState(window);
+ return window_state->window_position_managed() &&
+ !window_state->IsMinimized() &&
+ !window_state->IsMaximized() &&
+ !window_state->bounds_changed_by_user();
}
// Get the work area for a given |window| in parent coordinates.
@@ -104,7 +103,7 @@ void AutoPlaceSingleWindow(aura::Window* window, bool animated) {
gfx::Rect work_area = GetWorkAreaForWindowInParent(window);
gfx::Rect bounds = window->bounds();
const gfx::Rect* user_defined_area =
- ash::wm::GetPreAutoManageWindowBounds(window);
+ wm::GetWindowState(window)->pre_auto_manage_window_bounds();
if (user_defined_area) {
bounds = *user_defined_area;
ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area, &bounds);
@@ -155,7 +154,7 @@ aura::Window* GetReferenceWindow(const aura::RootWindow* root_window,
window->type() == aura::client::WINDOW_TYPE_NORMAL &&
window->GetRootWindow() == root_window &&
window->TargetVisibility() &&
- wm::GetWindowSettings(window)->window_position_managed()) {
+ wm::GetWindowState(window)->window_position_managed()) {
if (found && found != window) {
// no need to check !signle_window because the function must have
// been already returned in the "if (!single_window)" below.
@@ -187,8 +186,10 @@ void RearrangeVisibleWindowOnHideOrRemove(const aura::Window* removed_window) {
}
void RearrangeVisibleWindowOnShow(aura::Window* added_window) {
+ wm::WindowState* added_window_state = wm::GetWindowState(added_window);
+
if (!UseAutoWindowManager(added_window) ||
- wm::GetWindowSettings(added_window)->bounds_changed_by_user() ||
+ added_window_state->bounds_changed_by_user() ||
!added_window->TargetVisibility())
return;
// Find a single open managed window.
@@ -213,17 +214,18 @@ void RearrangeVisibleWindowOnShow(aura::Window* added_window) {
// Push the other window to the size only if there are two windows left.
if (single_window) {
- // When going from one to two windows both windows loose their "positioned
- // by user" flags.
- wm::GetWindowSettings(added_window)->set_bounds_changed_by_user(false);
- wm::GetWindowSettings(other_shown_window)->
- set_bounds_changed_by_user(false);
+ // When going from one to two windows both windows loose their
+ // "positioned by user" flags.
+ added_window_state->set_bounds_changed_by_user(false);
+ wm::WindowState* other_window_state =
+ wm::GetWindowState(other_shown_window);
+ other_window_state->set_bounds_changed_by_user(false);
if (WindowPositionCanBeManaged(other_shown_window)) {
// Don't override pre auto managed bounds as the current bounds
// may not be original.
- if (!ash::wm::GetPreAutoManageWindowBounds(other_shown_window))
- ash::wm::SetPreAutoManageWindowBounds(other_shown_window, other_bounds);
+ if (!other_window_state->pre_auto_manage_window_bounds())
+ other_window_state->SetPreAutoManageWindowBounds(other_bounds);
// Push away the other window after remembering its current position.
if (MoveRectToOneSide(work_area, move_other_right, &other_bounds))
@@ -235,8 +237,8 @@ void RearrangeVisibleWindowOnShow(aura::Window* added_window) {
// it also to the opposite location if needed. Since it is just
// being shown, we do not need to animate it.
gfx::Rect added_bounds = added_window->bounds();
- if (!ash::wm::GetPreAutoManageWindowBounds(added_window))
- ash::wm::SetPreAutoManageWindowBounds(added_window, added_bounds);
+ if (!added_window_state->pre_auto_manage_window_bounds())
+ added_window_state->SetPreAutoManageWindowBounds(added_bounds);
if (MoveRectToOneSide(work_area, !move_other_right, &added_bounds))
added_window->SetBounds(added_bounds);
}
diff --git a/ash/wm/workspace/colored_window_controller.cc b/ash/wm/workspace/colored_window_controller.cc
index 81339b5..bffff54 100644
--- a/ash/wm/workspace/colored_window_controller.cc
+++ b/ash/wm/workspace/colored_window_controller.cc
@@ -5,7 +5,7 @@
#include "ash/wm/workspace/colored_window_controller.h"
#include "ash/shell_window_ids.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/canvas.h"
@@ -65,7 +65,7 @@ ColoredWindowController::ColoredWindowController(aura::Window* parent,
widget->Init(params);
// Do this so the parent doesn't attempt to enforce any bounds constraints on
// us.
- wm::GetWindowSettings(widget->GetNativeView())->SetTrackedByWorkspace(false);
+ wm::GetWindowState(widget->GetNativeView())->SetTrackedByWorkspace(false);
widget->GetNativeView()->SetProperty(aura::client::kAnimationsDisabledKey,
true);
widget->GetNativeView()->SetName(window_name);
diff --git a/ash/wm/workspace/snap_sizer.cc b/ash/wm/workspace/snap_sizer.cc
index 877f101..8f2ed39 100644
--- a/ash/wm/workspace/snap_sizer.cc
+++ b/ash/wm/workspace/snap_sizer.cc
@@ -8,8 +8,8 @@
#include "ash/ash_switches.h"
#include "ash/screen_ash.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/window_resizer.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
@@ -125,20 +125,22 @@ std::vector<int> BuildIdealWidthList(aura::Window* window) {
// Changes |window|'s bounds to |snap_bounds| while preserving the restore
// bounds.
-void SnapWindowToBounds(aura::Window* window, const gfx::Rect& snap_bounds) {
- if (wm::IsWindowMaximized(window) || wm::IsWindowFullscreen(window)) {
+void SnapWindowToBounds(wm::WindowState* window_state,
+ const gfx::Rect& snap_bounds) {
+ if (window_state->IsMaximizedOrFullscreen()) {
// Before we can set the bounds we need to restore the window.
// Restoring the window will set the window to its restored bounds.
// To avoid an unnecessary bounds changes (which may have side effects)
// we set the restore bounds to the bounds we want, restore the window,
// then reset the restore bounds. This way no unnecessary bounds
// changes occurs and the original restore bounds is remembered.
- gfx::Rect restore_bounds_in_screen = *GetRestoreBoundsInScreen(window);
- SetRestoreBoundsInParent(window, snap_bounds);
- wm::RestoreWindow(window);
- SetRestoreBoundsInScreen(window, restore_bounds_in_screen);
+ gfx::Rect restore_bounds_in_screen =
+ window_state->GetRestoreBoundsInScreen();
+ window_state->SetRestoreBoundsInParent(snap_bounds);
+ window_state->Restore();
+ window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen);
} else {
- window->SetBounds(snap_bounds);
+ window_state->window()->SetBounds(snap_bounds);
}
}
@@ -168,15 +170,17 @@ SnapSizer::~SnapSizer() {
}
void SnapSizer::SnapWindow(aura::Window* window, SnapSizer::Edge edge) {
- if (!wm::CanSnapWindow(window))
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ if (!window_state->CanSnap())
return;
internal::SnapSizer sizer(window, gfx::Point(), edge,
internal::SnapSizer::OTHER_INPUT);
- SnapWindowToBounds(window, sizer.GetSnapBounds(window->bounds()));
+ SnapWindowToBounds(window_state,
+ sizer.GetSnapBounds(window_state->window()->bounds()));
}
void SnapSizer::SnapWindowToTargetBounds() {
- SnapWindowToBounds(window_, target_bounds());
+ SnapWindowToBounds(wm::GetWindowState(window_), target_bounds());
}
void SnapSizer::Update(const gfx::Point& location) {
diff --git a/ash/wm/workspace/snap_sizer_unittest.cc b/ash/wm/workspace/snap_sizer_unittest.cc
index ea27519..e0c9033 100644
--- a/ash/wm/workspace/snap_sizer_unittest.cc
+++ b/ash/wm/workspace/snap_sizer_unittest.cc
@@ -8,8 +8,7 @@
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "ui/aura/root_window.h"
@@ -87,7 +86,8 @@ TEST_F(SnapSizerTest, MinimumSize) {
// It should be possible to snap a window with a minimum size.
delegate.set_minimum_size(gfx::Size(kWorkAreaBounds.width() - 1, 0));
- EXPECT_TRUE(ash::wm::CanSnapWindow(window.get()));
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ EXPECT_TRUE(window_state->CanSnap());
SnapSizer::SnapWindow(window.get(), SnapSizer::RIGHT_EDGE);
gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x() + 1,
kWorkAreaBounds.y(),
@@ -98,7 +98,7 @@ TEST_F(SnapSizerTest, MinimumSize) {
// It should not be possible to snap a window with a maximum size.
delegate.set_minimum_size(gfx::Size());
delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, INT_MAX));
- EXPECT_FALSE(ash::wm::CanSnapWindow(window.get()));
+ EXPECT_FALSE(window_state->CanSnap());
}
// Test that repeadedly calling SnapSizer::SnapWindow() steps through the ideal
@@ -231,35 +231,37 @@ TEST_F(SnapSizerTest, AlternateFrameCaptionButtonStyle) {
TEST_F(SnapSizerTest, RestoreBounds) {
scoped_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
- EXPECT_TRUE(wm::IsWindowNormal(window.get()));
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+
+ EXPECT_TRUE(window_state->IsNormalShowState());
// 1) Start with restored window with restore bounds set.
gfx::Rect restore_bounds = window->GetBoundsInScreen();
restore_bounds.set_width(restore_bounds.width() + 1);
- SetRestoreBoundsInScreen(window.get(), restore_bounds);
+ window_state->SetRestoreBoundsInScreen(restore_bounds);
SnapSizer::SnapWindow(window.get(), SnapSizer::LEFT_EDGE);
SnapSizer::SnapWindow(window.get(), SnapSizer::RIGHT_EDGE);
EXPECT_NE(restore_bounds.ToString(), window->GetBoundsInScreen().ToString());
EXPECT_EQ(restore_bounds.ToString(),
- GetRestoreBoundsInScreen(window.get())->ToString());
- wm::RestoreWindow(window.get());
+ window_state->GetRestoreBoundsInScreen().ToString());
+ window_state->Restore();
EXPECT_EQ(restore_bounds.ToString(), window->GetBoundsInScreen().ToString());
// 2) Start with restored bounds set as a result of maximizing the window.
- wm::MaximizeWindow(window.get());
+ window_state->Maximize();
gfx::Rect maximized_bounds = window->GetBoundsInScreen();
EXPECT_NE(maximized_bounds.ToString(), restore_bounds.ToString());
EXPECT_EQ(restore_bounds.ToString(),
- GetRestoreBoundsInScreen(window.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
SnapSizer::SnapWindow(window.get(), SnapSizer::LEFT_EDGE);
EXPECT_NE(restore_bounds.ToString(), window->GetBoundsInScreen().ToString());
EXPECT_NE(maximized_bounds.ToString(),
window->GetBoundsInScreen().ToString());
EXPECT_EQ(restore_bounds.ToString(),
- GetRestoreBoundsInScreen(window.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
- wm::RestoreWindow(window.get());
+ window_state->Restore();
EXPECT_EQ(restore_bounds.ToString(), window->GetBoundsInScreen().ToString());
}
@@ -267,12 +269,13 @@ TEST_F(SnapSizerTest, RestoreBounds) {
// at the snapped bounds and not at the auto-managed (centered) bounds.
TEST_F(SnapSizerTest, AutoManaged) {
scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
- wm::GetWindowSettings(window.get())->set_window_position_managed(true);
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->set_window_position_managed(true);
window->Hide();
window->SetBounds(gfx::Rect(100, 100, 100, 100));
window->Show();
- wm::MaximizeWindow(window.get());
+ window_state->Maximize();
SnapSizer::SnapWindow(window.get(), SnapSizer::RIGHT_EDGE);
const gfx::Rect kWorkAreaBounds =
@@ -286,7 +289,7 @@ TEST_F(SnapSizerTest, AutoManaged) {
window->GetBoundsInScreen().ToString());
// The window should still be auto managed despite being right maximized.
- EXPECT_TRUE(wm::GetWindowSettings(window.get())->window_position_managed());
+ EXPECT_TRUE(wm::GetWindowState(window.get())->window_position_managed());
}
} // namespace ash
diff --git a/ash/wm/workspace/workspace_event_handler.cc b/ash/wm/workspace/workspace_event_handler.cc
index 870a925..e174644 100644
--- a/ash/wm/workspace/workspace_event_handler.cc
+++ b/ash/wm/workspace/workspace_event_handler.cc
@@ -9,7 +9,7 @@
#include "ash/shell_delegate.h"
#include "ash/touch/touch_uma.h"
#include "ash/wm/coordinate_conversion.h"
-#include "ash/wm/property_util.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_window_resizer.h"
#include "ui/aura/client/aura_constants.h"
@@ -24,36 +24,29 @@
namespace ash {
namespace {
-void SingleAxisMaximize(aura::Window* window,
+void SingleAxisMaximize(wm::WindowState* window_state,
const gfx::Rect& maximize_rect_in_screen) {
- gfx::Rect bounds_in_screen =
- ScreenAsh::ConvertRectToScreen(window->parent(), window->bounds());
- SetRestoreBoundsInScreen(window, bounds_in_screen);
- gfx::Rect bounds_in_parent =
- ScreenAsh::ConvertRectFromScreen(window->parent(),
- maximize_rect_in_screen);
- window->SetBounds(bounds_in_parent);
+ window_state->SaveCurrentBoundsForRestore();
+ window_state->SetBoundsInScreen(maximize_rect_in_screen);
}
-void SingleAxisUnmaximize(aura::Window* window,
+void SingleAxisUnmaximize(wm::WindowState* window_state,
const gfx::Rect& restore_bounds_in_screen) {
- gfx::Rect restore_bounds = ScreenAsh::ConvertRectFromScreen(
- window->parent(), restore_bounds_in_screen);
- window->SetBounds(restore_bounds);
- ClearRestoreBounds(window);
+ window_state->SetBoundsInScreen(restore_bounds_in_screen);
+ window_state->ClearRestoreBounds();
}
-void ToggleMaximizedState(aura::Window* window) {
- if (GetRestoreBoundsInScreen(window)) {
- if (window->GetProperty(aura::client::kShowStateKey) ==
- ui::SHOW_STATE_NORMAL) {
- window->SetBounds(GetRestoreBoundsInParent(window));
- ClearRestoreBounds(window);
+void ToggleMaximizedState(wm::WindowState* window_state) {
+ if (window_state->HasRestoreBounds()) {
+ if (window_state->GetShowState() == ui::SHOW_STATE_NORMAL) {
+ window_state->window()->SetBounds(
+ window_state->GetRestoreBoundsInParent());
+ window_state->ClearRestoreBounds();
} else {
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
+ window_state->Restore();
}
- } else if (wm::CanMaximizeWindow(window)) {
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+ } else if (window_state->CanMaximize()) {
+ window_state->Maximize();
}
}
@@ -93,7 +86,7 @@ void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) {
ToplevelWindowEventHandler::OnMouseEvent(event);
return;
}
-
+ wm::WindowState* target_state = wm::GetWindowState(target);
if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
event->IsOnlyLeftMouseButton() &&
target->delegate()->GetNonClientComponent(event->location()) ==
@@ -103,13 +96,13 @@ void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) {
destroyed_ = &destroyed;
ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction(
ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK);
- ToggleMaximizedState(target);
+ ToggleMaximizedState(target_state);
if (destroyed)
return;
destroyed_ = NULL;
}
multi_window_resize_controller_.Hide();
- HandleVerticalResizeDoubleClick(target, event);
+ HandleVerticalResizeDoubleClick(target_state, event);
break;
}
default:
@@ -130,7 +123,8 @@ void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) {
// TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP is counted once.
TouchUMA::GetInstance()->RecordGestureAction(
TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP);
- ToggleMaximizedState(target); // |this| may be destroyed from here.
+ // |this| may be destroyed from here.
+ ToggleMaximizedState(wm::GetWindowState(target));
event->StopPropagation();
return;
} else {
@@ -143,29 +137,28 @@ void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) {
}
void WorkspaceEventHandler::HandleVerticalResizeDoubleClick(
- aura::Window* target,
+ wm::WindowState* target_state,
ui::MouseEvent* event) {
+ aura::Window* target = target_state->window();
gfx::Rect max_size(target->delegate()->GetMaximumSize());
- if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
- !wm::IsWindowMaximized(target)) {
+ if (event->flags() & ui::EF_IS_DOUBLE_CLICK && !target_state->IsMaximized()) {
int component =
target->delegate()->GetNonClientComponent(event->location());
- gfx::Rect work_area =
- Shell::GetScreen()->GetDisplayNearestWindow(target).work_area();
- const gfx::Rect* restore_bounds =
- GetRestoreBoundsInScreen(target);
+ gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
+ target).work_area();
if (component == HTBOTTOM || component == HTTOP) {
// Don't maximize vertically if the window has a max height defined.
if (max_size.height() != 0)
return;
- if (restore_bounds &&
+ if (target_state->HasRestoreBounds() &&
(target->bounds().height() == work_area.height() &&
target->bounds().y() == work_area.y())) {
- SingleAxisUnmaximize(target, *restore_bounds);
+ SingleAxisUnmaximize(target_state,
+ target_state->GetRestoreBoundsInScreen());
} else {
gfx::Point origin = target->bounds().origin();
wm::ConvertPointToScreen(target->parent(), &origin);
- SingleAxisMaximize(target,
+ SingleAxisMaximize(target_state,
gfx::Rect(origin.x(),
work_area.y(),
target->bounds().width(),
@@ -175,14 +168,15 @@ void WorkspaceEventHandler::HandleVerticalResizeDoubleClick(
// Don't maximize horizontally if the window has a max width defined.
if (max_size.width() != 0)
return;
- if (restore_bounds &&
+ if (target_state->HasRestoreBounds() &&
(target->bounds().width() == work_area.width() &&
target->bounds().x() == work_area.x())) {
- SingleAxisUnmaximize(target, *restore_bounds);
+ SingleAxisUnmaximize(target_state,
+ target_state->GetRestoreBoundsInScreen());
} else {
gfx::Point origin = target->bounds().origin();
wm::ConvertPointToScreen(target->parent(), &origin);
- SingleAxisMaximize(target,
+ SingleAxisMaximize(target_state,
gfx::Rect(work_area.x(),
origin.y(),
work_area.width(),
diff --git a/ash/wm/workspace/workspace_event_handler.h b/ash/wm/workspace/workspace_event_handler.h
index f175408..c761f2b 100644
--- a/ash/wm/workspace/workspace_event_handler.h
+++ b/ash/wm/workspace/workspace_event_handler.h
@@ -13,6 +13,10 @@ class Window;
}
namespace ash {
+namespace wm {
+class WindowState;
+}
+
namespace internal {
class WorkspaceEventHandlerTestHelper;
@@ -33,7 +37,7 @@ class WorkspaceEventHandler : public ToplevelWindowEventHandler {
// bottom vertical resize edge, and if so toggles the vertical height of the
// window between its restored state and the full available height of the
// workspace.
- void HandleVerticalResizeDoubleClick(aura::Window* target,
+ void HandleVerticalResizeDoubleClick(wm::WindowState* window_state,
ui::MouseEvent* event);
MultiWindowResizeController multi_window_resize_controller_;
diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc
index 9f4d326..843d136 100644
--- a/ash/wm/workspace/workspace_event_handler_unittest.cc
+++ b/ash/wm/workspace/workspace_event_handler_unittest.cc
@@ -7,7 +7,7 @@
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
-#include "ash/wm/property_util.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller.h"
#include "ash/wm/workspace_controller_test_helper.h"
@@ -109,8 +109,10 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
EXPECT_EQ(restored_bounds.width(), bounds_in_screen.width());
EXPECT_EQ(work_area.y(), bounds_in_screen.y());
EXPECT_EQ(work_area.height(), bounds_in_screen.height());
+
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
// Single-axis maximization is not considered real maximization.
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+ EXPECT_FALSE(window_state->IsMaximized());
// Restore.
generator.DoubleClickLeftButton();
@@ -118,14 +120,14 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
EXPECT_EQ(restored_bounds.ToString(), bounds_in_screen.ToString());
// Note that it should not even be restored at this point, it should have
// also cleared the restore rectangle.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window.get()));
+ EXPECT_FALSE(window_state->HasRestoreBounds());
// Double-click the top resize edge again to maximize vertically, then double
// click again to restore.
generator.DoubleClickLeftButton();
wd.set_window_component(HTCAPTION);
generator.DoubleClickLeftButton();
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+ EXPECT_FALSE(window_state->IsMaximized());
bounds_in_screen = window->GetBoundsInScreen();
EXPECT_EQ(restored_bounds.ToString(), bounds_in_screen.ToString());
@@ -138,7 +140,7 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
EXPECT_EQ(work_area.x(), bounds_in_screen.x());
EXPECT_EQ(work_area.width(), bounds_in_screen.width());
// Single-axis maximization is not considered real maximization.
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+ EXPECT_FALSE(window_state->IsMaximized());
// Restore.
wd.set_window_component(HTCAPTION);
@@ -174,7 +176,7 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
EXPECT_EQ(restored_bounds.width(), bounds_in_screen.width());
EXPECT_EQ(work_area2.y(), bounds_in_screen.y());
EXPECT_EQ(work_area2.height(), bounds_in_screen.height());
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+ EXPECT_FALSE(window_state->IsMaximized());
// Restore.
wd.set_window_component(HTCAPTION);
@@ -189,7 +191,7 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
EXPECT_EQ(restored_bounds.height(), bounds_in_screen.height());
EXPECT_EQ(work_area2.x(), bounds_in_screen.x());
EXPECT_EQ(work_area2.width(), bounds_in_screen.width());
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+ EXPECT_FALSE(window_state->IsMaximized());
// Restore.
wd.set_window_component(HTCAPTION);
@@ -251,16 +253,18 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) {
CreateTestWindow(&wd, gfx::Rect(1, 2, 30, 40)));
window->SetProperty(aura::client::kCanMaximizeKey, true);
wd.set_window_component(HTCAPTION);
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ EXPECT_FALSE(window_state->IsMaximized());
aura::RootWindow* root = Shell::GetPrimaryRootWindow();
aura::test::EventGenerator generator(root, window.get());
generator.DoubleClickLeftButton();
EXPECT_NE("1,2 30x40", window->bounds().ToString());
- EXPECT_TRUE(wm::IsWindowMaximized(window.get()));
+ EXPECT_TRUE(window_state->IsMaximized());
generator.DoubleClickLeftButton();
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+ EXPECT_FALSE(window_state->IsMaximized());
EXPECT_EQ("1,2 30x40", window->bounds().ToString());
// Double-clicking the middle button shouldn't toggle the maximized state.
@@ -274,7 +278,7 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) {
ui::EF_IS_DOUBLE_CLICK);
root->AsRootWindowHostDelegate()->OnHostMouseEvent(&release);
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+ EXPECT_FALSE(window_state->IsMaximized());
EXPECT_EQ("1,2 30x40", window->bounds().ToString());
EXPECT_FALSE(observer.DidPropertyChange(aura::client::kShowStateKey));
}
@@ -285,19 +289,21 @@ TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) {
scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
window->SetProperty(aura::client::kCanMaximizeKey, true);
wd.set_window_component(HTCAPTION);
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ EXPECT_FALSE(window_state->IsMaximized());
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
window.get());
generator.GestureTapAt(gfx::Point(25, 25));
generator.GestureTapAt(gfx::Point(25, 25));
RunAllPendingInMessageLoop();
EXPECT_NE(bounds.ToString(), window->bounds().ToString());
- EXPECT_TRUE(wm::IsWindowMaximized(window.get()));
+ EXPECT_TRUE(window_state->IsMaximized());
generator.GestureTapAt(gfx::Point(5, 5));
generator.GestureTapAt(gfx::Point(10, 10));
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
+ EXPECT_FALSE(window_state->IsMaximized());
EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
}
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
index d1219ad..c4d72c0 100644
--- a/ash/wm/workspace/workspace_layout_manager.cc
+++ b/ash/wm/workspace/workspace_layout_manager.cc
@@ -14,7 +14,7 @@
#include "ash/wm/frame_painter.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/auto_window_management.h"
#include "ui/aura/client/aura_constants.h"
@@ -37,15 +37,10 @@ namespace {
// must be visible when the window is added to the workspace.
const float kMinimumPercentOnScreenArea = 0.3f;
-bool IsMaximizedState(ui::WindowShowState state) {
- return state == ui::SHOW_STATE_MAXIMIZED ||
- state == ui::SHOW_STATE_FULLSCREEN;
-}
-
-void MoveToDisplayForRestore(aura::Window* window) {
- const gfx::Rect* restore_bounds = GetRestoreBoundsInScreen(window);
- if (!restore_bounds)
+void MoveToDisplayForRestore(wm::WindowState* window_state) {
+ if (!window_state->HasRestoreBounds())
return;
+ const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen();
// Move only if the restore bounds is outside of
// the display. There is no information about in which
@@ -53,20 +48,20 @@ void MoveToDisplayForRestore(aura::Window* window) {
// TODO(oshima): Restore information should contain the
// work area information like WindowResizer does for the
// last window location.
- gfx::Rect display_area =
- Shell::GetScreen()->GetDisplayNearestWindow(window).bounds();
+ gfx::Rect display_area = Shell::GetScreen()->GetDisplayNearestWindow(
+ window_state->window()).bounds();
- if (!display_area.Intersects(*restore_bounds)) {
+ if (!display_area.Intersects(restore_bounds)) {
DisplayController* display_controller =
Shell::GetInstance()->display_controller();
const gfx::Display& display =
- display_controller->GetDisplayMatching(*restore_bounds);
+ display_controller->GetDisplayMatching(restore_bounds);
aura::RootWindow* new_root =
display_controller->GetRootWindowForDisplayId(display.id());
- if (new_root != window->GetRootWindow()) {
+ if (new_root != window_state->window()->GetRootWindow()) {
aura::Window* new_container =
- Shell::GetContainer(new_root, window->parent()->id());
- new_container->AddChild(window);
+ Shell::GetContainer(new_root, window_state->window()->parent()->id());
+ new_container->AddChild(window_state->window());
}
}
}
@@ -89,7 +84,7 @@ void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) {
}
void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) {
- AdjustWindowBoundsWhenAdded(child);
+ AdjustWindowBoundsWhenAdded(wm::GetWindowState(child));
BaseLayoutManager::OnWindowAddedToLayout(child);
UpdateDesktopVisibility();
RearrangeVisibleWindowOnShow(child);
@@ -119,13 +114,13 @@ void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child,
void WorkspaceLayoutManager::SetChildBounds(
Window* child,
const gfx::Rect& requested_bounds) {
- if (!wm::GetWindowSettings(child)->tracked_by_workspace()) {
+ if (!wm::GetWindowState(child)->tracked_by_workspace()) {
SetChildBoundsDirect(child, requested_bounds);
return;
}
gfx::Rect child_bounds(requested_bounds);
// Some windows rely on this to set their initial bounds.
- if (!SetMaximizedOrFullscreenBounds(child)) {
+ if (!SetMaximizedOrFullscreenBounds(wm::GetWindowState(child))) {
// Non-maximized/full-screen windows have their size constrained to the
// work-area.
child_bounds.set_width(std::min(work_area_.width(), child_bounds.width()));
@@ -147,22 +142,22 @@ void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() {
void WorkspaceLayoutManager::OnTrackedByWorkspaceChanged(Window* window,
bool old){
- if (wm::GetWindowSettings(window)->tracked_by_workspace())
- SetMaximizedOrFullscreenBounds(window);
+ if (wm::GetWindowState(window)->tracked_by_workspace())
+ SetMaximizedOrFullscreenBounds(wm::GetWindowState(window));
}
void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window,
const void* key,
intptr_t old) {
+ wm::WindowState* window_state = wm::GetWindowState(window);
if (key == aura::client::kShowStateKey) {
ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old);
- ui::WindowShowState new_state =
- window->GetProperty(aura::client::kShowStateKey);
+ ui::WindowShowState new_state = window_state->GetShowState();
if (old_state != ui::SHOW_STATE_MINIMIZED &&
- GetRestoreBoundsInScreen(window) == NULL &&
- IsMaximizedState(new_state) &&
- !IsMaximizedState(old_state)) {
- SetRestoreBoundsInParent(window, window->bounds());
+ !window_state->HasRestoreBounds() &&
+ window_state->IsMaximizedOrFullscreen() &&
+ !wm::WindowState::IsMaximizedOrFullscreenState(old_state)) {
+ window_state->SaveCurrentBoundsForRestore();
}
// When restoring from a minimized state, we want to restore to the
// previous (maybe L/R maximized) state. Since we do also want to keep the
@@ -172,33 +167,31 @@ void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window,
if (old_state == ui::SHOW_STATE_MINIMIZED &&
(new_state == ui::SHOW_STATE_NORMAL ||
new_state == ui::SHOW_STATE_DEFAULT) &&
- GetRestoreBoundsInScreen(window) &&
- !GetWindowAlwaysRestoresToRestoreBounds(window)) {
- restore = *GetRestoreBoundsInScreen(window);
- SetRestoreBoundsInScreen(window, window->GetBoundsInScreen());
+ window_state->HasRestoreBounds() &&
+ !window_state->always_restores_to_restore_bounds()) {
+ restore = window_state->GetRestoreBoundsInScreen();
+ window_state->SaveCurrentBoundsForRestore();
}
- UpdateBoundsFromShowState(window, old_state);
- ShowStateChanged(window, old_state);
+ UpdateBoundsFromShowState(window_state, old_state);
+ ShowStateChanged(window_state, old_state);
// Set the restore rectangle to the previously set restore rectangle.
if (!restore.IsEmpty())
- SetRestoreBoundsInScreen(window, restore);
+ window_state->SetRestoreBoundsInScreen(restore);
}
if (key == aura::client::kAlwaysOnTopKey &&
window->GetProperty(aura::client::kAlwaysOnTopKey)) {
- internal::AlwaysOnTopController* controller =
- GetRootWindowController(window->GetRootWindow())->
- always_on_top_controller();
- controller->GetContainer(window)->AddChild(window);
+ GetRootWindowController(window->GetRootWindow())->
+ always_on_top_controller()->GetContainer(window)->AddChild(window);
}
}
void WorkspaceLayoutManager::ShowStateChanged(
- Window* window,
+ wm::WindowState* state,
ui::WindowShowState last_show_state) {
- BaseLayoutManager::ShowStateChanged(window, last_show_state);
+ BaseLayoutManager::ShowStateChanged(state, last_show_state);
UpdateDesktopVisibility();
}
@@ -209,26 +202,27 @@ void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange(
}
void WorkspaceLayoutManager::AdjustWindowBoundsForWorkAreaChange(
- Window* window,
+ wm::WindowState* window_state,
AdjustWindowReason reason) {
- if (!wm::GetWindowSettings(window)->tracked_by_workspace())
+ if (!window_state->tracked_by_workspace())
return;
// Do not cross fade here: the window's layer hierarchy may be messed up for
// the transition between mirroring and extended. See also: crbug.com/267698
// TODO(oshima): Differentiate display change and shelf visibility change, and
// bring back CrossFade animation.
- if (wm::IsWindowMaximized(window) &&
+ if (window_state->IsMaximized() &&
reason == ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED) {
- SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBoundsInParent(
- window->parent()->parent()));
+ SetChildBoundsDirect(window_state->window(),
+ ScreenAsh::GetMaximizedWindowBoundsInParent(
+ window_state->window()->parent()->parent()));
return;
}
- if (SetMaximizedOrFullscreenBounds(window))
+ if (SetMaximizedOrFullscreenBounds(window_state))
return;
- gfx::Rect bounds = window->bounds();
+ gfx::Rect bounds = window_state->window()->bounds();
switch (reason) {
case ADJUST_WINDOW_DISPLAY_SIZE_CHANGED:
// The work area may be smaller than the full screen. Put as much of the
@@ -239,26 +233,27 @@ void WorkspaceLayoutManager::AdjustWindowBoundsForWorkAreaChange(
ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_, &bounds);
break;
}
- if (window->bounds() != bounds)
- window->SetBounds(bounds);
+ if (window_state->window()->bounds() != bounds)
+ window_state->window()->SetBounds(bounds);
}
void WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded(
- Window* window) {
+ wm::WindowState* window_state) {
// Don't adjust window bounds if the bounds are empty as this
// happens when a new views::Widget is created.
// When a window is dragged and dropped onto a different
// root window, the bounds will be updated after they are added
// to the root window.
- if (window->bounds().IsEmpty())
+ if (window_state->window()->bounds().IsEmpty())
return;
- if (!wm::GetWindowSettings(window)->tracked_by_workspace())
+ if (!window_state->tracked_by_workspace())
return;
- if (SetMaximizedOrFullscreenBounds(window))
+ if (SetMaximizedOrFullscreenBounds(window_state))
return;
+ Window* window = window_state->window();
gfx::Rect bounds = window->bounds();
int min_width = bounds.width() * kMinimumPercentOnScreenArea;
int min_height = bounds.height() * kMinimumPercentOnScreenArea;
@@ -281,22 +276,19 @@ void WorkspaceLayoutManager::UpdateDesktopVisibility() {
}
void WorkspaceLayoutManager::UpdateBoundsFromShowState(
- Window* window,
+ wm::WindowState* window_state,
ui::WindowShowState last_show_state) {
+ aura::Window* window = window_state->window();
// See comment in SetMaximizedOrFullscreenBounds() as to why we use parent in
// these calculation.
- switch (window->GetProperty(aura::client::kShowStateKey)) {
+ switch (window_state->GetShowState()) {
case ui::SHOW_STATE_DEFAULT:
case ui::SHOW_STATE_NORMAL: {
- const gfx::Rect* restore = GetRestoreBoundsInScreen(window);
// Make sure that the part of the window is always visible
// when restored.
gfx::Rect bounds_in_parent;
- if (restore) {
- bounds_in_parent =
- ScreenAsh::ConvertRectFromScreen(window->parent()->parent(),
- *restore);
-
+ if (window_state->HasRestoreBounds()) {
+ bounds_in_parent = window_state->GetRestoreBoundsInParent();
ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(
work_area_, &bounds_in_parent);
} else {
@@ -318,12 +310,12 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowState(
else
CrossFadeToBounds(window, new_bounds);
}
- ClearRestoreBounds(window);
+ window_state->ClearRestoreBounds();
break;
}
case ui::SHOW_STATE_MAXIMIZED: {
- MoveToDisplayForRestore(window);
+ MoveToDisplayForRestore(window_state);
gfx::Rect new_bounds = ScreenAsh::GetMaximizedWindowBoundsInParent(
window->parent()->parent());
// If the window is restored from minimized state, do not make the cross
@@ -337,7 +329,7 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowState(
}
case ui::SHOW_STATE_FULLSCREEN: {
- MoveToDisplayForRestore(window);
+ MoveToDisplayForRestore(window_state);
gfx::Rect new_bounds = ScreenAsh::GetDisplayBoundsInParent(
window->parent()->parent());
if (window->GetProperty(kAnimateToFullscreenKey) &&
@@ -355,23 +347,24 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowState(
}
bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds(
- aura::Window* window) {
- if (!wm::GetWindowSettings(window)->tracked_by_workspace())
+ wm::WindowState* window_state) {
+ if (!window_state->tracked_by_workspace())
return false;
// During animations there is a transform installed on the workspace
// windows. For this reason this code uses the parent so that the transform is
// ignored.
- if (wm::IsWindowMaximized(window)) {
+ if (window_state->IsMaximized()) {
SetChildBoundsDirect(
- window, ScreenAsh::GetMaximizedWindowBoundsInParent(
- window->parent()->parent()));
+ window_state->window(), ScreenAsh::GetMaximizedWindowBoundsInParent(
+ window_state->window()->parent()->parent()));
return true;
}
- if (wm::IsWindowFullscreen(window)) {
+ if (window_state->IsFullscreen()) {
SetChildBoundsDirect(
- window,
- ScreenAsh::GetDisplayBoundsInParent(window->parent()->parent()));
+ window_state->window(),
+ ScreenAsh::GetDisplayBoundsInParent(
+ window_state->window()->parent()->parent()));
return true;
}
return false;
diff --git a/ash/wm/workspace/workspace_layout_manager.h b/ash/wm/workspace/workspace_layout_manager.h
index a9241a6..607a099 100644
--- a/ash/wm/workspace/workspace_layout_manager.h
+++ b/ash/wm/workspace/workspace_layout_manager.h
@@ -62,26 +62,26 @@ class ASH_EXPORT WorkspaceLayoutManager : public BaseLayoutManager {
private:
// Overridden from BaseLayoutManager:
- virtual void ShowStateChanged(aura::Window* window,
+ virtual void ShowStateChanged(wm::WindowState* window_state,
ui::WindowShowState last_show_state) OVERRIDE;
virtual void AdjustAllWindowsBoundsForWorkAreaChange(
AdjustWindowReason reason) OVERRIDE;
virtual void AdjustWindowBoundsForWorkAreaChange(
- aura::Window* window,
+ wm::WindowState* window_state,
AdjustWindowReason reason) OVERRIDE;
- void AdjustWindowBoundsWhenAdded(aura::Window* window);
+ void AdjustWindowBoundsWhenAdded(wm::WindowState* window_state);
void UpdateDesktopVisibility();
// Updates the bounds of the window for a show state change from
// |last_show_state|.
- void UpdateBoundsFromShowState(aura::Window* window,
+ void UpdateBoundsFromShowState(wm::WindowState* window_state,
ui::WindowShowState last_show_state);
- // If |window| is maximized or fullscreen the bounds of the window are set and
- // true is returned. Does nothing otherwise.
- bool SetMaximizedOrFullscreenBounds(aura::Window* window);
+ // If |window_state| is maximized or fullscreen the bounds of the
+ // window are set and true is returned. Does nothing otherwise.
+ bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state);
internal::ShelfLayoutManager* shelf_;
aura::Window* window_;
diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc
index 4bff261..3ea3a04 100644
--- a/ash/wm/workspace/workspace_layout_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc
@@ -10,8 +10,7 @@
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
@@ -57,11 +56,14 @@ TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
gfx::Rect bounds(10, 15, 25, 35);
window->SetBounds(bounds);
+
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+
// This will not be used for un-minimizing window.
- SetRestoreBoundsInScreen(window.get(), gfx::Rect(0, 0, 100, 100));
- wm::MinimizeWindow(window.get());
- wm::RestoreWindow(window.get());
- EXPECT_EQ("0,0 100x100", GetRestoreBoundsInScreen(window.get())->ToString());
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100));
+ window_state->Minimize();
+ window_state->Restore();
+ EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString());
EXPECT_EQ("10,15 25x35", window.get()->bounds().ToString());
if (!SupportsMultipleDisplays())
@@ -71,17 +73,17 @@ TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100),
ScreenAsh::GetSecondaryDisplay());
EXPECT_EQ(Shell::GetAllRootWindows()[1], window->GetRootWindow());
- wm::MinimizeWindow(window.get());
+ window_state->Minimize();
// This will not be used for un-minimizing window.
- SetRestoreBoundsInScreen(window.get(), gfx::Rect(0, 0, 100, 100));
- wm::RestoreWindow(window.get());
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100));
+ window_state->Restore();
EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString());
// Make sure the unminimized window moves inside the display when
// 2nd display is disconnected.
- wm::MinimizeWindow(window.get());
+ window_state->Minimize();
UpdateDisplay("400x300");
- wm::RestoreWindow(window.get());
+ window_state->Restore();
EXPECT_EQ(Shell::GetPrimaryRootWindow(), window->GetRootWindow());
EXPECT_TRUE(
Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
@@ -92,17 +94,19 @@ TEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) {
return;
scoped_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+
// Maximized -> Normal transition.
- wm::MaximizeWindow(window.get());
- SetRestoreBoundsInScreen(window.get(), gfx::Rect(-100, -100, 30, 40));
- wm::RestoreWindow(window.get());
+ window_state->Maximize();
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40));
+ window_state->Restore();
EXPECT_TRUE(
Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
EXPECT_EQ("-20,-30 30x40", window->bounds().ToString());
// Minimized -> Normal transition.
window->SetBounds(gfx::Rect(-100, -100, 30, 40));
- wm::MinimizeWindow(window.get());
+ window_state->Minimize();
EXPECT_FALSE(
Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
EXPECT_EQ("-100,-100 30x40", window->bounds().ToString());
@@ -116,8 +120,8 @@ TEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) {
ASSERT_EQ("0,0 30x40", window->bounds().ToString());
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
EXPECT_EQ(window->bounds(), window->GetRootWindow()->bounds());
- SetRestoreBoundsInScreen(window.get(), gfx::Rect(-100, -100, 30, 40));
- wm::RestoreWindow(window.get());
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40));
+ window_state->Restore();
EXPECT_TRUE(
Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
EXPECT_EQ("-20,-30 30x40", window->bounds().ToString());
@@ -134,25 +138,26 @@ TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) {
CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
EXPECT_EQ(root_windows[0], window->GetRootWindow());
- SetRestoreBoundsInScreen(window.get(), gfx::Rect(400, 0, 30, 40));
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40));
// Maximize the window in 2nd display as the restore bounds
// is inside 2nd display.
- wm::MaximizeWindow(window.get());
+ window_state->Maximize();
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("300,0 400x453", window->GetBoundsInScreen().ToString());
- wm::RestoreWindow(window.get());
+ window_state->Restore();
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("400,0 30x40", window->GetBoundsInScreen().ToString());
// If the restore bounds intersects with the current display,
// don't move.
- SetRestoreBoundsInScreen(window.get(), gfx::Rect(280, 0, 30, 40));
- wm::MaximizeWindow(window.get());
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(280, 0, 30, 40));
+ window_state->Maximize();
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("300,0 400x453", window->GetBoundsInScreen().ToString());
- wm::RestoreWindow(window.get());
+ window_state->Restore();
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("280,0 30x40", window->GetBoundsInScreen().ToString());
@@ -183,7 +188,8 @@ TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) {
CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
EXPECT_EQ(root_windows[0], window->GetRootWindow());
- SetRestoreBoundsInScreen(window.get(), gfx::Rect(400, 0, 30, 40));
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40));
// Maximize the window in 2nd display as the restore bounds
// is inside 2nd display.
window->SetProperty(aura::client::kShowStateKey,
@@ -191,19 +197,19 @@ TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) {
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString());
- wm::RestoreWindow(window.get());
+ window_state->Restore();
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("400,0 30x40", window->GetBoundsInScreen().ToString());
// If the restore bounds intersects with the current display,
// don't move.
- SetRestoreBoundsInScreen(window.get(), gfx::Rect(280, 0, 30, 40));
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(280, 0, 30, 40));
window->SetProperty(aura::client::kShowStateKey,
ui::SHOW_STATE_FULLSCREEN);
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString());
- wm::RestoreWindow(window.get());
+ window_state->Restore();
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("280,0 30x40", window->GetBoundsInScreen().ToString());
}
@@ -224,7 +230,7 @@ class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver {
if (!window_)
return;
- if (wm::IsWindowMaximized(window)) {
+ if (wm::GetWindowState(window)->IsMaximized()) {
aura::Window* w = window_;
window_ = NULL;
@@ -256,7 +262,9 @@ TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
window->AddObserver(&window_observer);
SetDefaultParentByPrimaryRootWindow(window.get());
window->Show();
- wm::ActivateWindow(window.get());
+
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->Activate();
scoped_ptr<aura::Window> window2(
CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40)));
@@ -264,8 +272,9 @@ TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
window2->Show();
window_observer.set_window(window2.get());
- wm::MaximizeWindow(window.get());
- EXPECT_EQ("10,20 30x40", GetRestoreBoundsInScreen(window.get())->ToString());
+ window_state->Maximize();
+ EXPECT_EQ("10,20 30x40",
+ window_state->GetRestoreBoundsInScreen().ToString());
window->RemoveObserver(&window_observer);
}
@@ -274,12 +283,13 @@ TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) {
scoped_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 30, 40)));
window->Show();
- wm::ActivateWindow(window.get());
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->Activate();
scoped_ptr<aura::Window> child_window(
aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 6, 7, 8),
window.get()));
child_window->Show();
- wm::MaximizeWindow(window.get());
+ window_state->Maximize();
EXPECT_EQ("5,6 7x8", child_window->bounds().ToString());
}
@@ -309,7 +319,7 @@ TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) {
parent->RemoveChild(out_window.get());
out_window->SetBounds(gfx::Rect(-200, -200, 200, 200));
// UserHasChangedWindowPositionOrSize flag shouldn't turn off this behavior.
- wm::GetWindowSettings(window.get())->set_bounds_changed_by_user(true);
+ wm::GetWindowState(window.get())->set_bounds_changed_by_user(true);
parent->AddChild(out_window.get());
EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 9992249..29be68b 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -21,8 +21,7 @@
#include "ash/wm/dock/docked_window_resizer.h"
#include "ash/wm/drag_window_resizer.h"
#include "ash/wm/panels/panel_window_resizer.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/phantom_window_controller.h"
#include "ash/wm/workspace/snap_sizer.h"
@@ -47,8 +46,9 @@ scoped_ptr<WindowResizer> CreateWindowResizer(
int window_component,
aura::client::WindowMoveSource source) {
DCHECK(window);
+ wm::WindowState* window_state = wm::GetWindowState(window);
// No need to return a resizer when the window cannot get resized.
- if (!wm::CanResizeWindow(window) && window_component != HTCAPTION)
+ if (!window_state->CanResize() && window_component != HTCAPTION)
return scoped_ptr<WindowResizer>();
// TODO(varkha): The chaining of window resizers causes some of the logic
@@ -69,9 +69,9 @@ scoped_ptr<WindowResizer> CreateWindowResizer(
window->parent()->id() == internal::kShellWindowId_PanelContainer)) {
// Allow dragging maximized windows if it's not tracked by workspace. This
// is set by tab dragging code.
- if (!wm::IsWindowNormal(window) &&
+ if (!window_state->IsNormalShowState() &&
(window_component != HTCAPTION ||
- wm::GetWindowSettings(window)->tracked_by_workspace())) {
+ window_state->tracked_by_workspace())) {
return scoped_ptr<WindowResizer>();
}
window_resizer = internal::WorkspaceWindowResizer::Create(
@@ -80,7 +80,7 @@ scoped_ptr<WindowResizer> CreateWindowResizer(
window_component,
source,
std::vector<aura::Window*>());
- } else if (wm::IsWindowNormal(window)) {
+ } else if (window_state->IsNormalShowState()) {
window_resizer = DefaultWindowResizer::Create(
window, point_in_parent, window_component, source);
}
@@ -374,14 +374,13 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
}
// |bounds| is in |window()->parent()|'s coordinates.
gfx::Rect bounds = CalculateBoundsForDrag(details_, location_in_parent);
-
- if (wm::IsWindowNormal(window()))
+ if (window_state()->IsNormalShowState())
AdjustBoundsForMainWindow(sticky_size, &bounds);
if (bounds != window()->bounds()) {
if (!did_move_or_resize_) {
if (!details_.restore_bounds.IsEmpty())
- ClearRestoreBounds(window());
+ window_state()->ClearRestoreBounds();
RestackWindows();
}
did_move_or_resize_ = true;
@@ -424,7 +423,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
}
void WorkspaceWindowResizer::CompleteDrag(int event_flags) {
- wm::GetWindowSettings(details_.window)->set_bounds_changed_by_user(true);
+ window_state()->set_bounds_changed_by_user(true);
snap_phantom_window_controller_.reset();
if (!did_move_or_resize_ || details_.window_component != HTCAPTION)
return;
@@ -434,19 +433,20 @@ void WorkspaceWindowResizer::CompleteDrag(int event_flags) {
// shortcut while dragging it. If the window is the result of dragging a tab
// out of a maximized window, it's already in the normal show state when this
// is called, so it does not matter.
- if (wm::IsWindowNormal(window()) &&
+ if (window_state()->IsNormalShowState() &&
(window()->type() != aura::client::WINDOW_TYPE_PANEL ||
- !wm::GetWindowSettings(window())->panel_attached()) &&
+ !window_state()->panel_attached()) &&
(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) {
- if (!GetRestoreBoundsInScreen(window())) {
+ if (!window_state()->HasRestoreBounds()) {
gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen(
window()->parent(), details_.initial_bounds_in_parent);
- SetRestoreBoundsInScreen(window(), details_.restore_bounds.IsEmpty() ?
- initial_bounds :
- details_.restore_bounds);
+ window_state()->SetRestoreBoundsInScreen(
+ details_.restore_bounds.IsEmpty() ?
+ initial_bounds :
+ details_.restore_bounds);
}
DCHECK(snap_sizer_);
- if (wm::CanResizeWindow(window()) &&
+ if (window_state()->CanResize() &&
!dock_layout_->is_dragged_window_docked()) {
snap_sizer_->SnapWindowToTargetBounds();
}
@@ -460,8 +460,9 @@ void WorkspaceWindowResizer::RevertDrag() {
return;
window()->SetBounds(details_.initial_bounds_in_parent);
- if (!details_.restore_bounds.IsEmpty())
- SetRestoreBoundsInScreen(details_.window, details_.restore_bounds);
+ if (!details_.restore_bounds.IsEmpty()) {
+ window_state()->SetRestoreBoundsInScreen(details_.restore_bounds);
+ }
if (details_.window_component == HTRIGHT) {
int last_x = details_.initial_bounds_in_parent.right();
@@ -731,8 +732,7 @@ bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds,
// Avoid magnetically snapping to popups, menus, tooltips, controls and
// windows that are not tracked by workspace.
- if (!wm::CanResizeWindow(window()) ||
- !wm::GetWindowSettings(window())->tracked_by_workspace())
+ if (!window_state()->CanResize() || !window_state()->tracked_by_workspace())
return false;
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
@@ -744,15 +744,16 @@ bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds,
root_window, kShellWindowId_DefaultContainer)->children();
for (aura::Window::Windows::const_reverse_iterator i = children.rbegin();
i != children.rend() && !matcher.AreEdgesObscured(); ++i) {
- aura::Window* other = *i;
- if (other == window() ||
- !other->IsVisible() ||
- !wm::IsWindowNormal(other) ||
- !wm::CanResizeWindow(other)) {
+ wm::WindowState* other_state = wm::GetWindowState(*i);
+ if (other_state->window() == window() ||
+ !other_state->window()->IsVisible() ||
+ !other_state->IsNormalShowState() ||
+ !other_state->CanResize()) {
continue;
}
- if (matcher.ShouldAttach(other->GetBoundsInScreen(), &magnetism_edge_)) {
- magnetism_window_ = other;
+ if (matcher.ShouldAttach(
+ other_state->window()->GetBoundsInScreen(), &magnetism_edge_)) {
+ magnetism_window_ = other_state->window();
window_tracker_.Add(magnetism_window_);
return true;
}
@@ -910,7 +911,7 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
}
const bool can_dock = dock_layout_->CanDockWindow(window(), snap_type_);
- if (!wm::CanSnapWindow(window()) && !can_dock)
+ if (!window_state()->CanSnap() && !can_dock)
return;
// Update phantom window with snapped or docked guide bounds.
diff --git a/ash/wm/workspace/workspace_window_resizer.h b/ash/wm/workspace/workspace_window_resizer.h
index d678e12..1cd0942 100644
--- a/ash/wm/workspace/workspace_window_resizer.h
+++ b/ash/wm/workspace/workspace_window_resizer.h
@@ -17,6 +17,10 @@
#include "ui/aura/window_tracker.h"
namespace ash {
+namespace wm {
+class WindowState;
+}
+
namespace internal {
class DockedWindowLayoutManager;
@@ -163,6 +167,8 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
aura::Window* window() const { return details_.window; }
+ wm::WindowState* window_state() { return details_.window_state; }
+
const Details details_;
const std::vector<aura::Window*> attached_windows_;
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc
index 5f096d0..51de51b7 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -13,8 +13,7 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/phantom_window_controller.h"
#include "ash/wm/workspace/snap_sizer.h"
@@ -546,6 +545,8 @@ TEST_F(WorkspaceWindowResizerTest, Edge) {
int bottom =
ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
window_->SetBounds(gfx::Rect(20, 30, 50, 60));
+ wm::WindowState* window_state = wm::GetWindowState(window_.get());
+
{
scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
window_.get(), gfx::Point(), HTCAPTION,
@@ -555,9 +556,9 @@ TEST_F(WorkspaceWindowResizerTest, Edge) {
resizer->CompleteDrag(0);
EXPECT_EQ("0,0 720x" + base::IntToString(bottom),
window_->bounds().ToString());
- ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get()));
+ ASSERT_TRUE(window_state->HasRestoreBounds());
EXPECT_EQ("20,30 50x60",
- GetRestoreBoundsInScreen(window_.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
}
// Try the same with the right side.
{
@@ -569,13 +570,13 @@ TEST_F(WorkspaceWindowResizerTest, Edge) {
resizer->CompleteDrag(0);
EXPECT_EQ("80,0 720x" + base::IntToString(bottom),
window_->bounds().ToString());
- ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get()));
+ ASSERT_TRUE(window_state->HasRestoreBounds());
EXPECT_EQ("20,30 50x60",
- GetRestoreBoundsInScreen(window_.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
}
// Test if the restore bounds is correct in multiple displays.
- ClearRestoreBounds(window_.get());
+ window_state->ClearRestoreBounds();
if (!SupportsMultipleDisplays())
return;
@@ -603,7 +604,7 @@ TEST_F(WorkspaceWindowResizerTest, Edge) {
EXPECT_EQ("100,0 100x" + base::IntToString(bottom),
window_->bounds().ToString());
EXPECT_EQ("800,10 50x60",
- GetRestoreBoundsInScreen(window_.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
}
}
@@ -1146,7 +1147,8 @@ TEST_F(WorkspaceWindowResizerTest, CtrlCompleteDragMoveToExactPosition) {
// Verifies that a dragged window will restore to its pre-maximized size.
TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) {
window_->SetBounds(gfx::Rect(0, 0, 1000, 1000));
- SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160));
+ wm::WindowState* window_state = wm::GetWindowState(window_.get());
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160));
scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
window_.get(), gfx::Point(), HTCAPTION,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
@@ -1157,14 +1159,16 @@ TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) {
resizer->CompleteDrag(0);
EXPECT_EQ("10,10 320x160", window_->bounds().ToString());
// The restore rectangle should get cleared as well.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window_.get()));
+ EXPECT_FALSE(window_state->HasRestoreBounds());
}
// Verifies that a dragged window will restore to its pre-maximized size.
TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) {
const gfx::Rect initial_bounds(0, 0, 200, 400);
window_->SetBounds(initial_bounds);
- SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160));
+
+ wm::WindowState* window_state = wm::GetWindowState(window_.get());
+ window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160));
scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
window_.get(), gfx::Point(), HTCAPTION,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
@@ -1175,7 +1179,7 @@ TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) {
resizer->RevertDrag();
EXPECT_EQ(initial_bounds.ToString(), window_->bounds().ToString());
EXPECT_EQ("96,112 320x160",
- GetRestoreBoundsInScreen(window_.get())->ToString());
+ window_state->GetRestoreBoundsInScreen().ToString());
}
// Check that only usable sizes get returned by the resizer.
@@ -1386,8 +1390,7 @@ TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) {
EXPECT_EQ("0,150 400x200", window_->bounds().ToString());
resizer->RevertDrag();
- EXPECT_FALSE(
- wm::GetWindowSettings(window_.get())->bounds_changed_by_user());
+ EXPECT_FALSE(wm::GetWindowState(window_.get())->bounds_changed_by_user());
}
// Check that a completed move / size does change the user coordinates.
@@ -1400,8 +1403,7 @@ TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) {
resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0);
EXPECT_EQ("0,150 400x200", window_->bounds().ToString());
resizer->CompleteDrag(0);
- EXPECT_TRUE(
- wm::GetWindowSettings(window_.get())->bounds_changed_by_user());
+ EXPECT_TRUE(wm::GetWindowState(window_.get())->bounds_changed_by_user());
}
}
diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc
index 8e63d34..8d37858 100644
--- a/ash/wm/workspace_controller.cc
+++ b/ash/wm/workspace_controller.cc
@@ -8,9 +8,8 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/base_layout_manager.h"
-#include "ash/wm/property_util.h"
#include "ash/wm/window_animations.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_event_handler.h"
#include "ash/wm/workspace/workspace_layout_manager.h"
@@ -65,16 +64,17 @@ WorkspaceWindowState WorkspaceController::GetWindowState() const {
bool has_maximized_window = false;
for (aura::Window::Windows::const_iterator i = windows.begin();
i != windows.end(); ++i) {
- if (wm::GetWindowSettings(*i)->ignored_by_shelf())
+ wm::WindowState* window_state = wm::GetWindowState(*i);
+ if (window_state->ignored_by_shelf())
continue;
ui::Layer* layer = (*i)->layer();
if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f)
continue;
- if (wm::IsWindowMaximized(*i)) {
+ if (window_state->IsMaximized()) {
// 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)) {
+ } else if (window_state->IsFullscreen()) {
return WORKSPACE_WINDOW_STATE_FULL_SCREEN;
}
if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds))
diff --git a/ash/wm/workspace_controller_unittest.cc b/ash/wm/workspace_controller_unittest.cc
index 92a4739..ecb8248 100644
--- a/ash/wm/workspace_controller_unittest.cc
+++ b/ash/wm/workspace_controller_unittest.cc
@@ -16,8 +16,7 @@
#include "ash/system/status_area_widget.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/shell_test_api.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_settings.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
@@ -103,9 +102,9 @@ class WorkspaceControllerTest : public test::AshTestBase {
aura::Window* CreateBrowserLikeWindow(const gfx::Rect& bounds) {
aura::Window* window = CreateTestWindow();
window->SetBounds(bounds);
- wm::WindowSettings* settings = wm::GetWindowSettings(window);
- settings->SetTrackedByWorkspace(true);
- settings->set_window_position_managed(true);
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ window_state->SetTrackedByWorkspace(true);
+ window_state->set_window_position_managed(true);
window->Show();
return window;
}
@@ -146,11 +145,13 @@ TEST_F(WorkspaceControllerTest, AddNormalWindowWhenEmpty) {
scoped_ptr<Window> w1(CreateTestWindow());
w1->SetBounds(gfx::Rect(0, 0, 250, 251));
- EXPECT_TRUE(GetRestoreBoundsInScreen(w1.get()) == NULL);
+ wm::WindowState* window_state = wm::GetWindowState(w1.get());
+
+ EXPECT_FALSE(window_state->HasRestoreBounds());
w1->Show();
- EXPECT_TRUE(GetRestoreBoundsInScreen(w1.get()) == NULL);
+ EXPECT_FALSE(window_state->HasRestoreBounds());
ASSERT_TRUE(w1->layer() != NULL);
EXPECT_TRUE(w1->layer()->visible());
@@ -275,8 +276,10 @@ TEST_F(WorkspaceControllerTest, SingleFullscreenWindow) {
EXPECT_EQ(w1.get(), GetDesktop()->children()[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("0,0 250x251", GetRestoreBoundsInScreen(w1.get())->ToString());
+ wm::WindowState* window_state = wm::GetWindowState(w1.get());
+
+ ASSERT_TRUE(window_state->HasRestoreBounds());
+ EXPECT_EQ("0,0 250x251", window_state->GetRestoreBoundsInScreen().ToString());
}
// Assertions around minimizing a single window.
@@ -290,7 +293,7 @@ TEST_F(WorkspaceControllerTest, MinimizeSingleWindow) {
// Show the window.
w1->Show();
- EXPECT_TRUE(wm::IsWindowNormal(w1.get()));
+ EXPECT_TRUE(wm::GetWindowState(w1.get())->IsNormalShowState());
EXPECT_TRUE(w1->layer()->IsDrawn());
}
@@ -302,7 +305,11 @@ TEST_F(WorkspaceControllerTest, MinimizeFullscreenWindow) {
w1->Show();
w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
w2->Show();
- wm::ActivateWindow(w2.get());
+
+ wm::WindowState* w1_state = wm::GetWindowState(w1.get());
+ wm::WindowState* w2_state = wm::GetWindowState(w2.get());
+
+ w2_state->Activate();
// Minimize w2.
w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
@@ -311,18 +318,18 @@ TEST_F(WorkspaceControllerTest, MinimizeFullscreenWindow) {
// Show the window, which should trigger unminimizing.
w2->Show();
- wm::ActivateWindow(w2.get());
+ w2_state->Activate();
- EXPECT_TRUE(wm::IsWindowFullscreen(w2.get()));
+ EXPECT_TRUE(w2_state->IsFullscreen());
EXPECT_TRUE(w1->layer()->IsDrawn());
EXPECT_TRUE(w2->layer()->IsDrawn());
// Minimize the window, which should hide the window.
- EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
+ EXPECT_TRUE(w2_state->IsActive());
+ w2_state->Minimize();
+ EXPECT_FALSE(w2_state->IsActive());
EXPECT_FALSE(w2->layer()->IsDrawn());
- EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
+ EXPECT_TRUE(w1_state->IsActive());
// Make the window normal.
w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
@@ -353,7 +360,7 @@ TEST_F(WorkspaceControllerTest, ShelfStateUpdated) {
// A visible ignored window should not trigger the overlap.
scoped_ptr<Window> w_ignored(CreateTestWindow());
w_ignored->SetBounds(touches_shelf_bounds);
- wm::GetWindowSettings(&(*w_ignored))->set_ignored_by_shelf(true);
+ wm::GetWindowState(&(*w_ignored))->set_ignored_by_shelf(true);
w_ignored->Show();
EXPECT_FALSE(GetWindowOverlapsShelf());
@@ -408,10 +415,12 @@ TEST_F(WorkspaceControllerTest, ShelfStateUpdated) {
// Since the restore from minimize will restore to the pre-minimize
// state (tested elsewhere), we abandon the current size and restore
// rect and set them to the window.
- gfx::Rect restore = *GetRestoreBoundsInScreen(w1.get());
+ wm::WindowState* window_state = wm::GetWindowState(w1.get());
+
+ gfx::Rect restore = window_state->GetRestoreBoundsInScreen();
EXPECT_EQ("0,0 800x597", w1->bounds().ToString());
EXPECT_EQ("0,1 101x102", restore.ToString());
- ClearRestoreBounds(w1.get());
+ window_state->ClearRestoreBounds();
w1->SetBounds(restore);
// Restore.
@@ -641,9 +650,10 @@ TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) {
&delegate, 1000, gfx::Rect(10, 11, 250, 251)));
w1->Show();
- wm::ActivateWindow(w1.get());
- wm::MaximizeWindow(w1.get());
- wm::MinimizeWindow(w1.get());
+ wm::WindowState* w1_state = wm::GetWindowState(w1.get());
+ w1_state->Activate();
+ w1_state->Maximize();
+ w1_state->Minimize();
w1->parent()->RemoveChild(w1.get());
@@ -695,7 +705,7 @@ TEST_F(WorkspaceControllerTest, TrackedByWorkspace) {
w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
SetDefaultParentByPrimaryRootWindow(w2.get());
w2->Show();
- wm::GetWindowSettings(w2.get())->SetTrackedByWorkspace(false);
+ wm::GetWindowState(w2.get())->SetTrackedByWorkspace(false);
wm::ActivateWindow(w2.get());
// Activating |w2| should force it to have the same parent as |w1|.
@@ -712,7 +722,7 @@ TEST_F(WorkspaceControllerTest, TrackedByWorkspace) {
// Transition it to tracked by worskpace. It should end up in the desktop
// workspace.
- wm::GetWindowSettings(w2.get())->SetTrackedByWorkspace(true);
+ wm::GetWindowState(w2.get())->SetTrackedByWorkspace(true);
EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
EXPECT_TRUE(w1->IsVisible());
EXPECT_TRUE(w2->IsVisible());
@@ -799,11 +809,12 @@ TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) {
window2.reset();
EXPECT_EQ("16,32 640x320", window1->bounds().ToString());
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
// Test 2: Set up two managed windows and check their auto positioning.
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
+ window1_state->set_window_position_managed(true);
scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(2));
- wm::GetWindowSettings(window3.get())->set_window_position_managed(true);
+ wm::GetWindowState(window3.get())->set_window_position_managed(true);
// To avoid any auto window manager changes due to SetBounds, the window
// gets first hidden and then shown again.
window3->Hide();
@@ -840,7 +851,7 @@ TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) {
// Test4: A single manageable window should get centered.
window4.reset();
- wm::GetWindowSettings(window1.get())->set_bounds_changed_by_user(false);
+ window1_state->set_bounds_changed_by_user(false);
// Trigger the auto window placement function by showing (and hiding) it.
window1->Hide();
window1->Show();
@@ -860,19 +871,22 @@ TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) {
window2->SetBounds(gfx::Rect(32, 48, 256, 512));
window1->Hide();
window2->Hide();
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
- EXPECT_FALSE(wm::GetWindowSettings(window1.get())->bounds_changed_by_user());
- EXPECT_FALSE(wm::GetWindowSettings(window2.get())->bounds_changed_by_user());
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
+ wm::WindowState* window2_state = wm::GetWindowState(window2.get());
+
+ window1_state->set_window_position_managed(true);
+ window2_state->set_window_position_managed(true);
+ EXPECT_FALSE(window1_state->bounds_changed_by_user());
+ EXPECT_FALSE(window2_state->bounds_changed_by_user());
// Check that the current location gets preserved if the user has
// positioned it previously.
- wm::GetWindowSettings(window1.get())->set_bounds_changed_by_user(true);
+ window1_state->set_bounds_changed_by_user(true);
window1->Show();
EXPECT_EQ("16,32 640x320", window1->bounds().ToString());
// Flag should be still set.
- EXPECT_TRUE(wm::GetWindowSettings(window1.get())->bounds_changed_by_user());
- EXPECT_FALSE(wm::GetWindowSettings(window2.get())->bounds_changed_by_user());
+ EXPECT_TRUE(window1_state->bounds_changed_by_user());
+ EXPECT_FALSE(window2_state->bounds_changed_by_user());
// Turn on the second window and make sure that both windows are now
// positionable again (user movement cleared).
@@ -884,14 +898,14 @@ TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) {
base::IntToString(desktop_area.width() - window2->bounds().width()) +
",48 256x512", window2->bounds().ToString());
// FLag should now be reset.
- EXPECT_FALSE(wm::GetWindowSettings(window1.get())->bounds_changed_by_user());
- EXPECT_FALSE(wm::GetWindowSettings(window2.get())->bounds_changed_by_user());
+ EXPECT_FALSE(window1_state->bounds_changed_by_user());
+ EXPECT_FALSE(window2_state->bounds_changed_by_user());
// Going back to one shown window should keep the state.
- wm::GetWindowSettings(window1.get())->set_bounds_changed_by_user(true);
+ window1_state->set_bounds_changed_by_user(true);
window2->Hide();
EXPECT_EQ("0,32 640x320", window1->bounds().ToString());
- EXPECT_TRUE(wm::GetWindowSettings(window1.get())->bounds_changed_by_user());
+ EXPECT_TRUE(window1_state->bounds_changed_by_user());
}
// Test if the single window will be restored at original position.
@@ -905,9 +919,9 @@ TEST_F(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) {
window1->Hide();
window2->Hide();
window3->Hide();
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
- wm::GetWindowSettings(window3.get())->set_window_position_managed(true);
+ wm::GetWindowState(window1.get())->set_window_position_managed(true);
+ wm::GetWindowState(window2.get())->set_window_position_managed(true);
+ wm::GetWindowState(window3.get())->set_window_position_managed(true);
window1->Show();
wm::ActivateWindow(window1.get());
@@ -948,7 +962,9 @@ TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) {
scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
gfx::Rect user_pos = gfx::Rect(16, 42, 640, 320);
window1->SetBounds(user_pos);
- ash::wm::SetPreAutoManageWindowBounds(window1.get(), user_pos);
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
+
+ window1_state->SetPreAutoManageWindowBounds(user_pos);
gfx::Rect desktop_area = window1->parent()->bounds();
// Create a second window to let the auto manager kick in.
@@ -956,8 +972,8 @@ TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) {
window2->SetBounds(gfx::Rect(32, 48, 256, 512));
window1->Hide();
window2->Hide();
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::GetWindowState(window1.get())->set_window_position_managed(true);
+ wm::GetWindowState(window2.get())->set_window_position_managed(true);
window1->Show();
EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString());
window2->Show();
@@ -973,32 +989,34 @@ TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) {
// After the other window get hidden the window has to move back to the
// previous position and the bounds should still be set and unchanged.
EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString());
- ASSERT_TRUE(ash::wm::GetPreAutoManageWindowBounds(window1.get()));
+ ASSERT_TRUE(window1_state->pre_auto_manage_window_bounds());
EXPECT_EQ(user_pos.ToString(),
- ash::wm::GetPreAutoManageWindowBounds(window1.get())->ToString());
+ window1_state->pre_auto_manage_window_bounds()->ToString());
}
// Test that a window from normal to minimize will repos the remaining.
TEST_F(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) {
scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
+ window1_state->set_window_position_managed(true);
window1->SetBounds(gfx::Rect(16, 32, 640, 320));
gfx::Rect desktop_area = window1->parent()->bounds();
scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::WindowState* window2_state = wm::GetWindowState(window2.get());
+ window2_state->set_window_position_managed(true);
window2->SetBounds(gfx::Rect(32, 48, 256, 512));
- ash::wm::MinimizeWindow(window1.get());
+ window1_state->Minimize();
// |window2| should be centered now.
EXPECT_TRUE(window2->IsVisible());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window2.get()));
+ EXPECT_TRUE(window2_state->IsNormalShowState());
EXPECT_EQ(base::IntToString(
(desktop_area.width() - window2->bounds().width()) / 2) +
",48 256x512", window2->bounds().ToString());
- ash::wm::RestoreWindow(window1.get());
+ window1_state->Restore();
// |window1| should be flush right and |window3| flush left.
EXPECT_EQ(base::IntToString(
desktop_area.width() - window1->bounds().width()) +
@@ -1009,19 +1027,21 @@ TEST_F(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) {
// Test that minimizing an initially maximized window will repos the remaining.
TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) {
scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
+ window1_state->set_window_position_managed(true);
gfx::Rect desktop_area = window1->parent()->bounds();
scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::WindowState* window2_state = wm::GetWindowState(window2.get());
+ window2_state->set_window_position_managed(true);
window2->SetBounds(gfx::Rect(32, 48, 256, 512));
- ash::wm::MaximizeWindow(window1.get());
- ash::wm::MinimizeWindow(window1.get());
+ window1_state->Maximize();
+ window1_state->Minimize();
// |window2| should be centered now.
EXPECT_TRUE(window2->IsVisible());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window2.get()));
+ EXPECT_TRUE(window2_state->IsNormalShowState());
EXPECT_EQ(base::IntToString(
(desktop_area.width() - window2->bounds().width()) / 2) +
",48 256x512", window2->bounds().ToString());
@@ -1031,11 +1051,13 @@ TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) {
TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) {
scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
+ window1_state->set_window_position_managed(true);
gfx::Rect desktop_area = window1->parent()->bounds();
scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::WindowState* window2_state = wm::GetWindowState(window2.get());
+ window2_state->set_window_position_managed(true);
window2->SetBounds(gfx::Rect(32, 40, 256, 512));
// Trigger the auto window placement function by showing (and hiding) it.
@@ -1048,12 +1070,12 @@ TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) {
",32 640x320", window1->bounds().ToString());
EXPECT_EQ("0,40 256x512", window2->bounds().ToString());
- ash::wm::MaximizeWindow(window1.get());
- ash::wm::MinimizeWindow(window1.get());
+ window1_state->Maximize();
+ window1_state->Minimize();
// |window2| should be centered now.
EXPECT_TRUE(window2->IsVisible());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window2.get()));
+ EXPECT_TRUE(window2_state->IsNormalShowState());
EXPECT_EQ(base::IntToString(
(desktop_area.width() - window2->bounds().width()) / 2) +
",40 256x512", window2->bounds().ToString());
@@ -1063,11 +1085,12 @@ TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) {
TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) {
scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
window1->SetBounds(gfx::Rect(16, 32, 640, 320));
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
+ wm::WindowState* window1_state = wm::GetWindowState(window1.get());
+ window1_state->set_window_position_managed(true);
gfx::Rect desktop_area = window1->parent()->bounds();
scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::GetWindowState(window2.get())->set_window_position_managed(true);
window2->SetBounds(gfx::Rect(32, 40, 256, 512));
// Trigger the auto window placement function by showing (and hiding) it.
@@ -1080,8 +1103,8 @@ TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) {
",32 640x320", window1->bounds().ToString());
EXPECT_EQ("0,40 256x512", window2->bounds().ToString());
- ash::wm::MaximizeWindow(window1.get());
- ash::wm::RestoreWindow(window1.get());
+ window1_state->Maximize();
+ window1_state->Restore();
// |window1| should be flush right and |window2| flush left.
EXPECT_EQ(base::IntToString(
@@ -1102,8 +1125,8 @@ TEST_F(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) {
window2->Hide();
window2->SetBounds(gfx::Rect(32, 48, 256, 512));
- wm::GetWindowSettings(window1.get())->set_window_position_managed(true);
- wm::GetWindowSettings(window2.get())->set_window_position_managed(true);
+ wm::GetWindowState(window1.get())->set_window_position_managed(true);
+ wm::GetWindowState(window2.get())->set_window_position_managed(true);
// Make sure nothing is animating.
window1->layer()->GetAnimator()->StopAnimating();
window2->layer()->GetAnimator()->StopAnimating();
@@ -1277,7 +1300,7 @@ TEST_F(WorkspaceControllerTest, DragFullscreenNonTrackedWindow) {
EXPECT_EQ(0, observer.change_count());
// Set tracked to false and repeat, now the window should move.
- wm::GetWindowSettings(w1.get())->SetTrackedByWorkspace(false);
+ wm::GetWindowState(w1.get())->SetTrackedByWorkspace(false);
generator.MoveMouseTo(5, 5);
generator.PressLeftButton();
generator.MoveMouseBy(100, 100);
@@ -1286,7 +1309,7 @@ TEST_F(WorkspaceControllerTest, DragFullscreenNonTrackedWindow) {
w1->bounds().ToString());
generator.ReleaseLeftButton();
- wm::GetWindowSettings(w1.get())->SetTrackedByWorkspace(true);
+ wm::GetWindowState(w1.get())->SetTrackedByWorkspace(true);
// Marking the window tracked again should snap back to origin.
EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString());
EXPECT_EQ(0, observer.change_count());
@@ -1326,7 +1349,7 @@ TEST_F(WorkspaceControllerTest, DragMaximizedNonTrackedWindow) {
EXPECT_EQ(0, observer.change_count());
// Set tracked to false and repeat, now the window should move.
- wm::GetWindowSettings(w1.get())->SetTrackedByWorkspace(false);
+ wm::GetWindowState(w1.get())->SetTrackedByWorkspace(false);
generator.MoveMouseTo(5, 5);
generator.PressLeftButton();
generator.MoveMouseBy(100, 100);
@@ -1335,7 +1358,7 @@ TEST_F(WorkspaceControllerTest, DragMaximizedNonTrackedWindow) {
w1->bounds().ToString());
generator.ReleaseLeftButton();
- wm::GetWindowSettings(w1.get())->SetTrackedByWorkspace(true);
+ wm::GetWindowState(w1.get())->SetTrackedByWorkspace(true);
// Marking the window tracked again should snap back to origin.
EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString());
EXPECT_EQ(0, observer.change_count());