diff options
41 files changed, 406 insertions, 299 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index d7104d2..3185ee0 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -493,6 +493,8 @@ 'wm/window_cycle_controller.h', 'wm/window_cycle_list.cc', 'wm/window_cycle_list.h', + 'wm/window_settings.cc', + 'wm/window_settings.h', 'wm/window_properties.cc', 'wm/window_properties.h', 'wm/window_resizer.cc', diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc index f22b07e..236fb00 100644 --- a/ash/wm/base_layout_manager.cc +++ b/ash/wm/base_layout_manager.cc @@ -10,6 +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_util.h" #include "ash/wm/workspace/workspace_window_resizer.h" #include "ui/aura/client/activation_client.h" @@ -60,7 +61,7 @@ gfx::Rect BaseLayoutManager::BoundsWithScreenEdgeVisible( } ///////////////////////////////////////////////////////////////////////////// -// BaseLayoutManager, LayoutManager overrides: +// BaseLayoutManager, aura::LayoutManager overrides: void BaseLayoutManager::OnWindowResized() { } @@ -68,6 +69,7 @@ void BaseLayoutManager::OnWindowResized() { void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) { windows_.insert(child); child->AddObserver(this); + wm::GetWindowSettings(child)->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)) @@ -77,6 +79,7 @@ void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) { void BaseLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { windows_.erase(child); child->RemoveObserver(this); + wm::GetWindowSettings(child)->RemoveObserver(this); } void BaseLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { @@ -104,15 +107,7 @@ void BaseLayoutManager::SetChildBounds(aura::Window* child, } ///////////////////////////////////////////////////////////////////////////// -// BaseLayoutManager, ash::ShellObserver overrides: - -void BaseLayoutManager::OnDisplayWorkAreaInsetsChanged() { - AdjustAllWindowsBoundsForWorkAreaChange( - ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED); -} - -///////////////////////////////////////////////////////////////////////////// -// BaseLayoutManager, WindowObserver overrides: +// BaseLayoutManager, aura::WindowObserver overrides: void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window, const void* key, @@ -161,6 +156,14 @@ void BaseLayoutManager::OnWindowActivated(aura::Window* gained_active, } } +///////////////////////////////////////////////////////////////////////////// +// BaseLayoutManager, ash::ShellObserver overrides: + +void BaseLayoutManager::OnDisplayWorkAreaInsetsChanged() { + AdjustAllWindowsBoundsForWorkAreaChange( + ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED); +} + ////////////////////////////////////////////////////////////////////////////// // BaseLayoutManager, protected: diff --git a/ash/wm/base_layout_manager.h b/ash/wm/base_layout_manager.h index 0fc2b36..c9e49e3 100644 --- a/ash/wm/base_layout_manager.h +++ b/ash/wm/base_layout_manager.h @@ -9,6 +9,7 @@ #include "ash/ash_export.h" #include "ash/shell_observer.h" +#include "ash/wm/window_settings.h" #include "base/basictypes.h" #include "base/compiler_specific.h" #include "ui/aura/client/activation_change_observer.h" @@ -32,9 +33,10 @@ namespace internal { // properly. class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, - public ash::ShellObserver, public aura::WindowObserver, - public aura::client::ActivationChangeObserver { + public aura::client::ActivationChangeObserver, + public ShellObserver, + public wm::WindowSettings::Observer { public: typedef std::set<aura::Window*> WindowSet; @@ -49,7 +51,7 @@ class ASH_EXPORT BaseLayoutManager static gfx::Rect BoundsWithScreenEdgeVisible(aura::Window* window, const gfx::Rect& restore_bounds); - // LayoutManager overrides: + // aura::LayoutManager overrides: virtual void OnWindowResized() OVERRIDE; virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; @@ -59,10 +61,7 @@ class ASH_EXPORT BaseLayoutManager virtual void SetChildBounds(aura::Window* child, const gfx::Rect& requested_bounds) OVERRIDE; - // ash::ShellObserver overrides: - virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE; - - // WindowObserver overrides: + // aura::WindowObserver overrides: virtual void OnWindowPropertyChanged(aura::Window* window, const void* key, intptr_t old) OVERRIDE; @@ -75,6 +74,9 @@ class ASH_EXPORT BaseLayoutManager virtual void OnWindowActivated(aura::Window* gained_active, aura::Window* lost_active) OVERRIDE; + // ash::ShellObserver overrides: + virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE; + protected: enum AdjustWindowReason { ADJUST_WINDOW_DISPLAY_SIZE_CHANGED, diff --git a/ash/wm/dock/docked_window_layout_manager_unittest.cc b/ash/wm/dock/docked_window_layout_manager_unittest.cc index b2f6ffd..a29f7a3 100644 --- a/ash/wm/dock/docked_window_layout_manager_unittest.cc +++ b/ash/wm/dock/docked_window_layout_manager_unittest.cc @@ -20,8 +20,8 @@ #include "ash/test/shell_test_api.h" #include "ash/test/test_launcher_delegate.h" #include "ash/wm/panels/panel_layout_manager.h" -#include "ash/wm/window_properties.h" #include "ash/wm/window_resizer.h" +#include "ash/wm/window_settings.h" #include "base/basictypes.h" #include "base/command_line.h" #include "ui/aura/client/aura_constants.h" @@ -176,7 +176,7 @@ class DockedWindowLayoutManagerTest if (window_type_ == aura::client::WINDOW_TYPE_PANEL) { ASSERT_NO_FATAL_FAILURE(DragStart(window)); - EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(window)->panel_attached()); // Drag enough to detach since our tests assume panels to be initially // detached. @@ -188,7 +188,7 @@ class DockedWindowLayoutManagerTest // The panel should be detached when the drag completes. DragEnd(); - EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(window)->panel_attached()); EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); EXPECT_EQ(root_window, window->GetRootWindow()); diff --git a/ash/wm/dock/docked_window_resizer.cc b/ash/wm/dock/docked_window_resizer.cc index bf07d22..b356175 100644 --- a/ash/wm/dock/docked_window_resizer.cc +++ b/ash/wm/dock/docked_window_resizer.cc @@ -15,7 +15,7 @@ #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_properties.h" +#include "ash/wm/window_settings.h" #include "ash/wm/workspace/magnetism_matcher.h" #include "ash/wm/workspace/phantom_window_controller.h" #include "ash/wm/workspace/workspace_window_resizer.h" @@ -76,9 +76,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. - bool tracked_by_workspace = GetTrackedByWorkspace(GetTarget()); + wm::WindowSettings* window_settings = wm::GetWindowSettings(GetTarget()); + bool was_tracked_by_workspace = window_settings->tracked_by_workspace(); if (set_tracked_by_workspace) - SetTrackedByWorkspace(GetTarget(), false); + window_settings->SetTrackedByWorkspace(false); gfx::Point modified_location(location.x() + offset.x(), location.y() + offset.y()); @@ -86,9 +87,7 @@ void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) { next_window_resizer_->Drag(modified_location, event_flags); if (!resizer) return; - - if (set_tracked_by_workspace) - SetTrackedByWorkspace(GetTarget(), tracked_by_workspace); + window_settings->SetTrackedByWorkspace(was_tracked_by_workspace); DockedWindowLayoutManager* new_dock_layout = GetDockedLayoutManagerAtPoint(last_location_); @@ -136,15 +135,14 @@ 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. - bool tracked_by_workspace = GetTrackedByWorkspace(GetTarget()); - bool set_tracked_by_workspace = was_docked_; - if (set_tracked_by_workspace) - SetTrackedByWorkspace(GetTarget(), false); + wm::WindowSettings* window_settings = wm::GetWindowSettings(GetTarget()); + bool was_tracked_by_workspace = window_settings->tracked_by_workspace(); + if (was_docked_) + window_settings->SetTrackedByWorkspace(false); // The root window can change when dragging into a different screen. next_window_resizer_->CompleteDrag(event_flags); FinishedDragging(); - if (set_tracked_by_workspace) - SetTrackedByWorkspace(GetTarget(), tracked_by_workspace); + window_settings->SetTrackedByWorkspace(was_tracked_by_workspace); } void DockedWindowResizer::RevertDrag() { @@ -153,14 +151,13 @@ 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. - bool tracked_by_workspace = GetTrackedByWorkspace(GetTarget()); - bool set_tracked_by_workspace = was_docked_; - if (set_tracked_by_workspace) - SetTrackedByWorkspace(GetTarget(), false); + wm::WindowSettings* window_settings = wm::GetWindowSettings(GetTarget()); + bool was_tracked_by_workspace = window_settings->tracked_by_workspace(); + if (was_docked_) + window_settings->SetTrackedByWorkspace(false); next_window_resizer_->RevertDrag(); FinishedDragging(); - if (set_tracked_by_workspace) - SetTrackedByWorkspace(GetTarget(), tracked_by_workspace); + window_settings->SetTrackedByWorkspace(was_tracked_by_workspace); } aura::Window* DockedWindowResizer::GetTarget() { @@ -279,7 +276,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. - GetTarget()->SetProperty(kContinueDragAfterReparent, true); + wm::GetWindowSettings(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. @@ -300,7 +297,7 @@ void DockedWindowResizer::FinishedDragging() { bool should_dock = was_docked_; const bool attached_panel = window->type() == aura::client::WINDOW_TYPE_PANEL && - window->GetProperty(kPanelAttachedKey); + wm::GetWindowSettings(window)->panel_attached(); // If a window was previously docked then keep it docked if it is resized and // still aligned at the screen edge. if ((was_docked_ || diff --git a/ash/wm/dock/docked_window_resizer_unittest.cc b/ash/wm/dock/docked_window_resizer_unittest.cc index 49aeca2..5d6566e 100644 --- a/ash/wm/dock/docked_window_resizer_unittest.cc +++ b/ash/wm/dock/docked_window_resizer_unittest.cc @@ -21,7 +21,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_properties.h" +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #include "base/command_line.h" #include "ui/aura/client/aura_constants.h" @@ -185,7 +185,7 @@ class DockedWindowResizerTest if (window_type_ == aura::client::WINDOW_TYPE_PANEL) { ASSERT_NO_FATAL_FAILURE(DragStart(window)); - EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(window)->panel_attached()); // Drag enough to detach since our tests assume panels to be initially // detached. @@ -197,7 +197,7 @@ class DockedWindowResizerTest // The panel should be detached when the drag completes. DragEnd(); - EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(window)->panel_attached()); EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); EXPECT_EQ(root_window, window->GetRootWindow()); @@ -1040,7 +1040,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(w1->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(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/frame_painter.cc b/ash/wm/frame_painter.cc index 29865e1..3b723f50 100644 --- a/ash/wm/frame_painter.cc +++ b/ash/wm/frame_painter.cc @@ -12,7 +12,7 @@ #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/property_util.h" -#include "ash/wm/window_properties.h" +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace/frame_caption_button_container_view.h" #include "base/logging.h" // DCHECK @@ -273,6 +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); // Solo-window header updates are handled by the workspace controller when // this window is added to the desktop. @@ -390,9 +391,9 @@ bool FramePainter::ShouldUseMinimalHeaderStyle(Themed header_themed) const { // - If the user has installed a theme with custom images for the header. // - For windows which are not tracked by the workspace code (which are used // for tab dragging). - return ((frame_->IsMaximized() || frame_->IsFullscreen()) && + return (frame_->IsMaximized() || frame_->IsFullscreen()) && header_themed == THEMED_NO && - GetTrackedByWorkspace(frame_->GetNativeWindow())); + wm::GetWindowSettings(frame_->GetNativeWindow())->tracked_by_workspace(); } void FramePainter::PaintHeader(views::NonClientFrameView* view, @@ -617,19 +618,21 @@ void FramePainter::OnThemeChanged() { } /////////////////////////////////////////////////////////////////////////////// +// WindowSettings::jObserver 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()) + frame_->non_client_view()->SchedulePaint(); +} + +/////////////////////////////////////////////////////////////////////////////// // aura::WindowObserver overrides: void FramePainter::OnWindowPropertyChanged(aura::Window* window, const void* key, intptr_t old) { - // When 'kWindowTrackedByWorkspaceKey' changes, we are going to paint the - // header differently. Schedule a paint to ensure everything is updated - // correctly. - if (key == internal::kWindowTrackedByWorkspaceKey && - GetTrackedByWorkspace(window)) { - frame_->non_client_view()->SchedulePaint(); - } - if (key != aura::client::kShowStateKey) return; @@ -663,6 +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); // If we have two or more windows open and we close this one, we might trigger // the solo window appearance for another window. @@ -722,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())) && - GetTrackedByWorkspace(frame_->GetNativeWindow()); + wm::GetWindowSettings(frame_->GetNativeWindow())->tracked_by_workspace(); const int kCornerRadius = 2; return square_corners ? 0 : kCornerRadius; } diff --git a/ash/wm/frame_painter.h b/ash/wm/frame_painter.h index 4a9e968..a5d40fb 100644 --- a/ash/wm/frame_painter.h +++ b/ash/wm/frame_painter.h @@ -6,6 +6,7 @@ #define ASH_WM_FRAME_PAINTER_H_ #include "ash/ash_export.h" +#include "ash/wm/window_settings.h" #include "base/basictypes.h" #include "base/compiler_specific.h" // OVERRIDE #include "base/gtest_prod_util.h" @@ -41,7 +42,8 @@ class FrameCaptionButtonContainerView; // various implementations of views::NonClientFrameView. Canonical source of // layout constants for Ash window frames. class ASH_EXPORT FramePainter : public aura::WindowObserver, - public ui::AnimationDelegate { + public ui::AnimationDelegate, + public wm::WindowSettings::Observer { public: // Opacity values for the window header in various states, from 0 to 255. static int kActiveWindowOpacity; @@ -145,6 +147,10 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE; virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE; + // ash::WindowSettings::Observer overrides: + virtual void OnTrackedByWorkspaceChanged(aura::Window* window, + bool old) OVERRIDE; + // Overridden from ui::AnimationDelegate virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; diff --git a/ash/wm/frame_painter_unittest.cc b/ash/wm/frame_painter_unittest.cc index f412afd..1bc6923 100644 --- a/ash/wm/frame_painter_unittest.cc +++ b/ash/wm/frame_painter_unittest.cc @@ -9,7 +9,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_util.h" #include "ash/wm/workspace/frame_caption_button_container_view.h" #include "base/memory/scoped_ptr.h" @@ -567,9 +567,9 @@ TEST_F(FramePainterTest, MinimalHeaderStyle) { // style. EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_YES)); - SetTrackedByWorkspace(w->GetNativeWindow(), false); + wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(false); EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); - SetTrackedByWorkspace(w->GetNativeWindow(), true); + wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(true); } // Ensure the title text is vertically aligned with the window icon. diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc index 2b00c88..65f15e6 100644 --- a/ash/wm/panels/panel_layout_manager.cc +++ b/ash/wm/panels/panel_layout_manager.cc @@ -17,7 +17,7 @@ #include "ash/wm/frame_painter.h" #include "ash/wm/property_util.h" #include "ash/wm/window_animations.h" -#include "ash/wm/window_properties.h" +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #include "base/auto_reset.h" #include "base/bind.h" @@ -342,7 +342,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 (!child->GetProperty(kPanelAttachedKey)) { + if (!wm::GetWindowSettings(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 67e4bd1..606a7e8 100644 --- a/ash/wm/panels/panel_window_resizer.cc +++ b/ash/wm/panels/panel_window_resizer.cc @@ -14,7 +14,7 @@ #include "ash/wm/coordinate_conversion.h" #include "ash/wm/panels/panel_layout_manager.h" #include "ash/wm/property_util.h" -#include "ash/wm/window_properties.h" +#include "ash/wm/window_settings.h" #include "base/memory/weak_ptr.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/env.h" @@ -130,7 +130,7 @@ PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer, panel_container_(NULL), initial_panel_container_(NULL), did_move_or_resize_(false), - was_attached_(GetTarget()->GetProperty(internal::kPanelAttachedKey)), + was_attached_(wm::GetWindowSettings(GetTarget())->panel_attached()), should_attach_(was_attached_), weak_ptr_factory_(this) { DCHECK(details_.is_resizable); @@ -191,8 +191,8 @@ void PanelWindowResizer::StartedDragging() { GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget()); if (!was_attached_) { // Attach the panel while dragging placing it in front of other panels. - GetTarget()->SetProperty(internal::kContinueDragAfterReparent, true); - GetTarget()->SetProperty(internal::kPanelAttachedKey, true); + wm::GetWindowSettings(GetTarget())->set_continue_drag_after_reparent(true); + wm::GetWindowSettings(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,9 +204,8 @@ void PanelWindowResizer::StartedDragging() { void PanelWindowResizer::FinishDragging() { if (!did_move_or_resize_) return; - if (GetTarget()->GetProperty(internal::kPanelAttachedKey) != - should_attach_) { - GetTarget()->SetProperty(internal::kPanelAttachedKey, should_attach_); + if (wm::GetWindowSettings(GetTarget())->panel_attached() != should_attach_) { + wm::GetWindowSettings(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 1f1bdf5..81bff9c 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_properties.h" +#include "ash/wm/window_settings.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" #include "ui/base/hit_test.h" @@ -98,7 +98,7 @@ 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(window->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(window)->panel_attached()); aura::RootWindow* root_window = window->GetRootWindow(); EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); DragStart(window); @@ -118,7 +118,7 @@ class PanelWindowResizerTest : public test::AshTestBase { // The panel should be detached when the drag completes. DragEnd(); - EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(window)->panel_attached()); EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); EXPECT_EQ(root_window, window->GetRootWindow()); @@ -130,7 +130,7 @@ class PanelWindowResizerTest : public test::AshTestBase { DragEnd(); // The panel should be reattached and have snapped to the launcher. - EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(window)->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 +290,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(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached()); EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); @@ -300,7 +300,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(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached()); EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); } @@ -321,7 +321,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(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached()); EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); } @@ -342,7 +342,7 @@ TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { DragMove(0, -100); DragEnd(); EXPECT_EQ(root_windows[0], window->GetRootWindow()); - EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached()); // Drag the window just above the other display's launcher. DragStart(window.get()); @@ -355,7 +355,7 @@ TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { // When dropped should move to second display's panel container. EXPECT_EQ(root_windows[1], window->GetRootWindow()); - EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(window.get())->panel_attached()); EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); } @@ -381,26 +381,26 @@ TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { // When dropped should move to second display's panel container. EXPECT_EQ(root_windows[1], window->GetRootWindow()); - EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(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(window->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(window.get())->panel_attached()); EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); DragStart(window.get()); DragMove(0, -100); DragRevert(); - EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); + EXPECT_TRUE(wm::GetWindowSettings(window.get())->panel_attached()); EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); // Detach panel. DragStart(window.get()); DragMove(0, -100); DragEnd(); - EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(window.get())->panel_attached()); EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); @@ -410,7 +410,7 @@ TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) { // When the drag is reverted it should remain detached. DragRevert(); - EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); + EXPECT_FALSE(wm::GetWindowSettings(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 index 5aac996..f78eebd 100644 --- a/ash/wm/property_util.cc +++ b/ash/wm/property_util.cc @@ -37,22 +37,6 @@ void ClearRestoreBounds(aura::Window* window) { window->ClearProperty(aura::client::kRestoreBoundsKey); } -void SetTrackedByWorkspace(aura::Window* window, bool value) { - window->SetProperty(internal::kWindowTrackedByWorkspaceKey, value); -} - -bool GetTrackedByWorkspace(const aura::Window* window) { - return window->GetProperty(internal::kWindowTrackedByWorkspaceKey); -} - -void SetIgnoredByShelf(aura::Window* window, bool value) { - window->SetProperty(internal::kIgnoredByShelfKey, value); -} - -bool GetIgnoredByShelf(const aura::Window* window) { - return window->GetProperty(internal::kIgnoredByShelfKey); -} - void SetWindowAlwaysRestoresToRestoreBounds(aura::Window* window, bool value) { window->SetProperty(internal::kWindowRestoresToRestoreBounds, value); } diff --git a/ash/wm/property_util.h b/ash/wm/property_util.h index 365a373e..6a0d89a 100644 --- a/ash/wm/property_util.h +++ b/ash/wm/property_util.h @@ -37,11 +37,6 @@ 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| is ignored when determining whether the shelf should -// be darkened when overlapped. -ASH_EXPORT void SetIgnoredByShelf(aura::Window* window, bool value); -ASH_EXPORT bool GetIgnoredByShelf(const 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 @@ -51,14 +46,6 @@ ASH_EXPORT void SetWindowAlwaysRestoresToRestoreBounds(aura::Window* window, bool value); ASH_EXPORT bool GetWindowAlwaysRestoresToRestoreBounds( const aura::Window* window); - -// Sets whether the specified 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. -ASH_EXPORT void SetTrackedByWorkspace(aura::Window* window, bool value); -ASH_EXPORT bool GetTrackedByWorkspace(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 4476a86..51e13b3 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_properties.h" +#include "ash/wm/window_settings.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" @@ -49,10 +49,6 @@ bool HasTransientParentWindow(aura::Window* window) { window->transient_parent()->type() != aura::client::WINDOW_TYPE_UNKNOWN; } -bool IsPanelAttached(aura::Window* window) { - return window->GetProperty(internal::kPanelAttachedKey); -} - internal::AlwaysOnTopController* GetAlwaysOnTopController(aura::RootWindow* root_window) { return internal::GetRootWindowController(root_window)-> @@ -96,7 +92,7 @@ aura::Window* StackingController::GetDefaultParent(aura::Window* context, return GetContainerById( target_root, internal::kShellWindowId_UnparentedControlContainer); case aura::client::WINDOW_TYPE_PANEL: - if (IsPanelAttached(window)) + if (wm::GetWindowSettings(window)->panel_attached()) return GetContainerById(target_root, internal::kShellWindowId_PanelContainer); else diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/toplevel_window_event_handler.cc index a0d4b5e..8f30b0e 100644 --- a/ash/wm/toplevel_window_event_handler.cc +++ b/ash/wm/toplevel_window_event_handler.cc @@ -7,8 +7,8 @@ #include "ash/shell.h" #include "ash/wm/property_util.h" #include "ash/wm/resize_shadow_controller.h" -#include "ash/wm/window_properties.h" #include "ash/wm/window_resizer.h" +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace/snap_sizer.h" #include "base/message_loop/message_loop.h" @@ -105,8 +105,9 @@ void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowHierarchyChanging( if (params.receiver != resizer_->GetTarget()) return; - if (params.receiver->GetProperty(internal::kContinueDragAfterReparent)) { - params.receiver->SetProperty(internal::kContinueDragAfterReparent, false); + if (wm::GetWindowSettings(params.receiver)->continue_drag_after_reparent()) { + wm::GetWindowSettings(params.receiver)-> + set_continue_drag_after_reparent(false); AddHandlers(params.new_parent); } else { handler_->CompleteDrag(DRAG_COMPLETE, 0); diff --git a/ash/wm/window_properties.cc b/ash/wm/window_properties.cc index c95cf90..39291cc 100644 --- a/ash/wm/window_properties.cc +++ b/ash/wm/window_properties.cc @@ -4,27 +4,19 @@ #include "ash/wm/window_properties.h" -#include "ash/root_window_controller.h" -#include "ash/wm/frame_painter.h" #include "ui/aura/window_property.h" #include "ui/gfx/rect.h" namespace ash { namespace internal { DEFINE_WINDOW_PROPERTY_KEY(bool, kAnimateToFullscreenKey, true); -DEFINE_WINDOW_PROPERTY_KEY(bool, kContinueDragAfterReparent, false); DEFINE_WINDOW_PROPERTY_KEY(bool, kFullscreenUsesMinimalChromeKey, false); -DEFINE_WINDOW_PROPERTY_KEY(bool, kIgnoredByShelfKey, false); -DEFINE_WINDOW_PROPERTY_KEY(bool, kPanelAttachedKey, true); DEFINE_WINDOW_PROPERTY_KEY(bool, kStayInSameRootWindowKey, false); DEFINE_WINDOW_PROPERTY_KEY(bool, kUsesScreenCoordinatesKey, false); -DEFINE_WINDOW_PROPERTY_KEY(bool, kUserChangedWindowPositionOrSizeKey, false); DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Rect, kPreAutoManagedWindowBoundsKey, NULL); -DEFINE_WINDOW_PROPERTY_KEY(bool, kWindowPositionManagedKey, false); DEFINE_WINDOW_PROPERTY_KEY(bool, kWindowRestoresToRestoreBounds, false); -DEFINE_WINDOW_PROPERTY_KEY(bool, kWindowTrackedByWorkspaceKey, true); } // namespace internal } // namespace ash diff --git a/ash/wm/window_properties.h b/ash/wm/window_properties.h index 341d9b8..20154da 100644 --- a/ash/wm/window_properties.h +++ b/ash/wm/window_properties.h @@ -25,35 +25,18 @@ namespace internal { // the fullscreen state. extern const aura::WindowProperty<bool>* const kAnimateToFullscreenKey; -// A property key to indicate that an in progress drag should be continued -// after the window is reparented to another container. -extern const aura::WindowProperty<bool>* const kContinueDragAfterReparent; - // A property key to indicate whether there is any chrome at all that cannot be // hidden when the window is fullscreen. This is unrelated to whether the full // chrome can be revealed by hovering the mouse at the top of the screen. ASH_EXPORT extern const aura::WindowProperty<bool>* const kFullscreenUsesMinimalChromeKey; -// True if the window is ignored by the shelf layout manager for purposes of -// darkening the shelf. -extern const aura::WindowProperty<bool>* const - kIgnoredByShelfKey; - -// True if this window is an attached panel. -ASH_EXPORT extern const aura::WindowProperty<bool>* const kPanelAttachedKey; - // If this is set to true, the window stays in the same root window // even if the bounds outside of its root window is set. // This is exported as it's used in the tests. ASH_EXPORT extern const aura::WindowProperty<bool>* const kStayInSameRootWindowKey; -// A property key to remember if a windows position or size was changed by a -// user. -ASH_EXPORT extern const aura::WindowProperty<bool>* const - kUserChangedWindowPositionOrSizeKey; - // 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. @@ -63,19 +46,10 @@ ASH_EXPORT extern const aura::WindowProperty<gfx::Rect*>* const // Property to tell if the container uses the screen coordinates. extern const aura::WindowProperty<bool>* const kUsesScreenCoordinatesKey; -// A property key to remember if a windows position can be managed by the -// workspace manager or not. -ASH_EXPORT extern const aura::WindowProperty<bool>* const - kWindowPositionManagedKey; - // 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; -// True if the window is controlled by the workspace manager. -extern const aura::WindowProperty<bool>* const - kWindowTrackedByWorkspaceKey; - // Alphabetical sort. } // namespace internal diff --git a/ash/wm/window_settings.cc b/ash/wm/window_settings.cc new file mode 100644 index 0000000..cd62688 --- /dev/null +++ b/ash/wm/window_settings.cc @@ -0,0 +1,63 @@ +// 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 new file mode 100644 index 0000000..001e18d --- /dev/null +++ b/ash/wm/window_settings.h @@ -0,0 +1,107 @@ +// 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 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_util.cc b/ash/wm/window_util.cc index ca205e9..3f0f234 100644 --- a/ash/wm/window_util.cc +++ b/ash/wm/window_util.cc @@ -132,28 +132,10 @@ void CenterWindow(aura::Window* window) { window->SetBoundsInScreen(center, display); } -bool IsWindowPositionManaged(const aura::Window* window) { - return window->GetProperty(ash::internal::kWindowPositionManagedKey); -} - -void SetWindowPositionManaged(aura::Window* window, bool managed) { - window->SetProperty(ash::internal::kWindowPositionManagedKey, managed); -} - void SetAnimateToFullscreen(aura::Window* window, bool animate) { window->SetProperty(ash::internal::kAnimateToFullscreenKey, animate); } -bool HasUserChangedWindowPositionOrSize(const aura::Window* window) { - return window->GetProperty( - ash::internal::kUserChangedWindowPositionOrSizeKey); -} - -void SetUserHasChangedWindowPositionOrSize(aura::Window* window, bool changed) { - window->SetProperty(ash::internal::kUserChangedWindowPositionOrSizeKey, - changed); -} - const gfx::Rect* GetPreAutoManageWindowBounds(const aura::Window* window) { return window->GetProperty(ash::internal::kPreAutoManagedWindowBoundsKey); } diff --git a/ash/wm/window_util.h b/ash/wm/window_util.h index c114b8d..a911099 100644 --- a/ash/wm/window_util.h +++ b/ash/wm/window_util.h @@ -83,22 +83,9 @@ ASH_EXPORT void ToggleMaximizedWindow(aura::Window* window); // Moves the window to the center of the display. ASH_EXPORT void CenterWindow(aura::Window* window); -// Returns true if |window|'s position can automatically be managed. -ASH_EXPORT bool IsWindowPositionManaged(const aura::Window* window); - -// Change the |window|'s position manageability to |managed|. -ASH_EXPORT void SetWindowPositionManaged(aura::Window* window, bool managed); - // Change the availability of animation to the fullscreen of the |window|. ASH_EXPORT void SetAnimateToFullscreen(aura::Window* window, bool animate); -// Returns true if the user has changed the |window|'s position or size. -ASH_EXPORT bool HasUserChangedWindowPositionOrSize(const aura::Window* window); - -// Marks a |window|'s coordinates to be changed by a user. -ASH_EXPORT void SetUserHasChangedWindowPositionOrSize(aura::Window* window, - bool changed); - // 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( diff --git a/ash/wm/workspace/auto_window_management.cc b/ash/wm/workspace/auto_window_management.cc index ddcd19c..97cf2e8 100644 --- a/ash/wm/workspace/auto_window_management.cc +++ b/ash/wm/workspace/auto_window_management.cc @@ -9,6 +9,7 @@ #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_util.h" #include "base/command_line.h" #include "ui/aura/window.h" @@ -28,18 +29,20 @@ const int kWindowAutoMoveDurationMS = 125; // Check if any management should be performed (with a given |window|). bool UseAutoWindowManager(const aura::Window* window) { - return GetTrackedByWorkspace(window) && - wm::IsWindowPositionManaged(window); + const wm::WindowSettings* settings = wm::GetWindowSettings(window); + return settings->tracked_by_workspace() && + settings->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) { - return (wm::IsWindowPositionManaged(window) && - !wm::IsWindowMinimized(window) && - !wm::IsWindowMaximized(window) && - !wm::HasUserChangedWindowPositionOrSize(window)); + const wm::WindowSettings* settings = wm::GetWindowSettings(window); + return settings->window_position_managed() && + !wm::IsWindowMinimized(window) && + !wm::IsWindowMaximized(window) && + !settings->bounds_changed_by_user(); } // Get the work area for a given |window|. @@ -149,7 +152,7 @@ aura::Window* GetReferenceWindow(const aura::RootWindow* root_window, window->type() == aura::client::WINDOW_TYPE_NORMAL && window->GetRootWindow() == root_window && window->TargetVisibility() && - wm::IsWindowPositionManaged(window)) { + wm::GetWindowSettings(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. @@ -182,7 +185,7 @@ void RearrangeVisibleWindowOnHideOrRemove(const aura::Window* removed_window) { void RearrangeVisibleWindowOnShow(aura::Window* added_window) { if (!UseAutoWindowManager(added_window) || - wm::HasUserChangedWindowPositionOrSize(added_window) || + wm::GetWindowSettings(added_window)->bounds_changed_by_user() || !added_window->TargetVisibility()) return; // Find a single open managed window. @@ -209,8 +212,9 @@ void RearrangeVisibleWindowOnShow(aura::Window* added_window) { if (single_window) { // When going from one to two windows both windows loose their "positioned // by user" flags. - ash::wm::SetUserHasChangedWindowPositionOrSize(added_window, false); - ash::wm::SetUserHasChangedWindowPositionOrSize(other_shown_window, false); + wm::GetWindowSettings(added_window)->set_bounds_changed_by_user(false); + wm::GetWindowSettings(other_shown_window)-> + set_bounds_changed_by_user(false); if (WindowPositionCanBeManaged(other_shown_window)) { // Don't override pre auto managed bounds as the current bounds diff --git a/ash/wm/workspace/colored_window_controller.cc b/ash/wm/workspace/colored_window_controller.cc index 08c3dc0..81339b5 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/property_util.h" +#include "ash/wm/window_settings.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. - SetTrackedByWorkspace(widget->GetNativeView(), false); + wm::GetWindowSettings(widget->GetNativeView())->SetTrackedByWorkspace(false); widget->GetNativeView()->SetProperty(aura::client::kAnimationsDisabledKey, true); widget->GetNativeView()->SetName(window_name); diff --git a/ash/wm/workspace/frame_caption_button_container_view.cc b/ash/wm/workspace/frame_caption_button_container_view.cc index 962f847..ddf602f 100644 --- a/ash/wm/workspace/frame_caption_button_container_view.cc +++ b/ash/wm/workspace/frame_caption_button_container_view.cc @@ -6,7 +6,7 @@ #include "ash/shell.h" #include "ash/shell_delegate.h" -#include "ash/wm/property_util.h" +#include "ash/wm/window_settings.h" #include "ash/wm/workspace/frame_maximize_button.h" #include "grit/ash_resources.h" #include "grit/ui_strings.h" // Accessibility names @@ -128,7 +128,8 @@ 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()) && - GetTrackedByWorkspace(frame_->GetNativeWindow())) { + wm::GetWindowSettings( + frame_->GetNativeWindow())->tracked_by_workspace()) { SetButtonImages(size_button_, IDR_AURA_WINDOW_MAXIMIZED_RESTORE2, IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_H, diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc index 78438f0..08980c2 100644 --- a/ash/wm/workspace/frame_maximize_button.cc +++ b/ash/wm/workspace/frame_maximize_button.cc @@ -13,11 +13,11 @@ #include "ash/wm/maximize_bubble_controller.h" #include "ash/wm/property_util.h" #include "ash/wm/window_animations.h" -#include "ash/wm/window_properties.h" -#include "ash/wm/window_util.h" +#include "ash/wm/window_settings.h" #include "ash/wm/workspace/phantom_window_controller.h" #include "ash/wm/workspace/snap_sizer.h" #include "grit/ash_strings.h" +#include "ui/aura/client/aura_constants.h" #include "ui/aura/window.h" #include "ui/base/events/event.h" #include "ui/base/events/event_handler.h" @@ -176,11 +176,7 @@ void FrameMaximizeButton::OnWindowBoundsChanged( void FrameMaximizeButton::OnWindowPropertyChanged(aura::Window* window, const void* key, intptr_t old) { - // Changing the window position is managed status should not Cancel. - // Note that this case might happen when a non user managed window - // transitions from maximized to L/R maximized. - if (key != ash::internal::kWindowPositionManagedKey) - Cancel(false); + Cancel(false); } void FrameMaximizeButton::OnWindowDestroying(aura::Window* window) { @@ -543,9 +539,9 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { // The auto position manager will kick in when this is the only window. // To avoid interference with it we tell it temporarily to not change // the coordinates of this window. - bool is_managed = ash::wm::IsWindowPositionManaged(window); - if (is_managed) - ash::wm::SetWindowPositionManaged(window, false); + wm::WindowSettings* settings = wm::GetWindowSettings(window); + bool was_managed = settings->window_position_managed(); + settings->set_window_position_managed(false); // Set the restore size we want to restore to. ash::SetRestoreBoundsInScreen(window, @@ -555,8 +551,7 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { // After the window is where we want it to be we allow the window to be // auto managed again. - if (is_managed) - ash::wm::SetWindowPositionManaged(window, true); + settings->set_window_position_managed(was_managed); } else { // Others might also have set up a restore rectangle already. If so, // we should not overwrite the restore rectangle. diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc index b39213e..258fd86 100644 --- a/ash/wm/workspace/workspace_layout_manager.cc +++ b/ash/wm/workspace/workspace_layout_manager.cc @@ -14,6 +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_util.h" #include "ash/wm/workspace/auto_window_management.h" #include "ui/aura/client/aura_constants.h" @@ -118,7 +119,7 @@ void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child, void WorkspaceLayoutManager::SetChildBounds( Window* child, const gfx::Rect& requested_bounds) { - if (!GetTrackedByWorkspace(child)) { + if (!wm::GetWindowSettings(child)->tracked_by_workspace()) { SetChildBoundsDirect(child, requested_bounds); return; } @@ -144,6 +145,12 @@ void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { } } +void WorkspaceLayoutManager::OnTrackedByWorkspaceChanged(Window* window, + bool old){ + if (wm::GetWindowSettings(window)->tracked_by_workspace()) + SetMaximizedOrFullscreenBounds(window); +} + void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window, const void* key, intptr_t old) { @@ -179,11 +186,6 @@ void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window, SetRestoreBoundsInScreen(window, restore); } - if (key == internal::kWindowTrackedByWorkspaceKey && - GetTrackedByWorkspace(window)) { - SetMaximizedOrFullscreenBounds(window); - } - if (key == aura::client::kAlwaysOnTopKey && window->GetProperty(aura::client::kAlwaysOnTopKey)) { internal::AlwaysOnTopController* controller = @@ -209,7 +211,7 @@ void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( void WorkspaceLayoutManager::AdjustWindowBoundsForWorkAreaChange( Window* window, AdjustWindowReason reason) { - if (!GetTrackedByWorkspace(window)) + if (!wm::GetWindowSettings(window)->tracked_by_workspace()) return; // Do not cross fade here: the window's layer hierarchy may be messed up for @@ -251,7 +253,7 @@ void WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded( if (window->bounds().IsEmpty()) return; - if (!GetTrackedByWorkspace(window)) + if (!wm::GetWindowSettings(window)->tracked_by_workspace()) return; if (SetMaximizedOrFullscreenBounds(window)) @@ -340,7 +342,7 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) { bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( aura::Window* window) { - if (!GetTrackedByWorkspace(window)) + if (!wm::GetWindowSettings(window)->tracked_by_workspace()) return false; // During animations there is a transform installed on the workspace diff --git a/ash/wm/workspace/workspace_layout_manager.h b/ash/wm/workspace/workspace_layout_manager.h index 4476ddc..b0d5fa9 100644 --- a/ash/wm/workspace/workspace_layout_manager.h +++ b/ash/wm/workspace/workspace_layout_manager.h @@ -56,6 +56,10 @@ class ASH_EXPORT WorkspaceLayoutManager : public BaseLayoutManager { const void* key, intptr_t old) OVERRIDE; + // ash::WindowSettings::Observer overrides: + virtual void OnTrackedByWorkspaceChanged(aura::Window* window, + bool old) OVERRIDE; + private: // Overridden from BaseLayoutManager: virtual void ShowStateChanged(aura::Window* window, diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc index 5ec242f..4bff261 100644 --- a/ash/wm/workspace/workspace_layout_manager_unittest.cc +++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc @@ -11,6 +11,7 @@ #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_util.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" @@ -308,7 +309,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::SetUserHasChangedWindowPositionOrSize(window.get(), true); + wm::GetWindowSettings(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 4b8c0aa..f68e64d 100644 --- a/ash/wm/workspace/workspace_window_resizer.cc +++ b/ash/wm/workspace/workspace_window_resizer.cc @@ -20,7 +20,7 @@ #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_properties.h" +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace/phantom_window_controller.h" #include "ash/wm/workspace/snap_sizer.h" @@ -67,8 +67,10 @@ scoped_ptr<WindowResizer> CreateWindowResizer( // Allow dragging maximized windows if it's not tracked by workspace. This // is set by tab dragging code. if (!wm::IsWindowNormal(window) && - (window_component != HTCAPTION || GetTrackedByWorkspace(window))) + (window_component != HTCAPTION || + wm::GetWindowSettings(window)->tracked_by_workspace())) { return scoped_ptr<WindowResizer>(); + } window_resizer = internal::WorkspaceWindowResizer::Create( window, point_in_parent, @@ -401,7 +403,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent, } void WorkspaceWindowResizer::CompleteDrag(int event_flags) { - wm::SetUserHasChangedWindowPositionOrSize(details_.window, true); + wm::GetWindowSettings(details_.window)->set_bounds_changed_by_user(true); snap_phantom_window_controller_.reset(); if (!did_move_or_resize_ || details_.window_component != HTCAPTION) return; @@ -413,7 +415,7 @@ void WorkspaceWindowResizer::CompleteDrag(int event_flags) { // is called, so it does not matter. if (wm::IsWindowNormal(window()) && (window()->type() != aura::client::WINDOW_TYPE_PANEL || - !window()->GetProperty(kPanelAttachedKey)) && + !wm::GetWindowSettings(window())->panel_attached()) && (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { if (!GetRestoreBoundsInScreen(window())) { gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( @@ -699,7 +701,8 @@ 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()) || !GetTrackedByWorkspace(window())) + if (!wm::CanResizeWindow(window()) || + !wm::GetWindowSettings(window())->tracked_by_workspace()) return false; Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); @@ -859,7 +862,7 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, return; if (window()->type() == aura::client::WINDOW_TYPE_PANEL && - window()->GetProperty(kPanelAttachedKey)) { + wm::GetWindowSettings(window())->panel_attached()) { return; } diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc index 80e0fd2..18520c5 100644 --- a/ash/wm/workspace/workspace_window_resizer_unittest.cc +++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc @@ -14,6 +14,7 @@ #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_util.h" #include "ash/wm/workspace/phantom_window_controller.h" #include "ash/wm/workspace/snap_sizer.h" @@ -1421,7 +1422,8 @@ TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) { EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); resizer->RevertDrag(); - EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window_.get())); + EXPECT_FALSE( + wm::GetWindowSettings(window_.get())->bounds_changed_by_user()); } // Check that a completed move / size does change the user coordinates. @@ -1434,7 +1436,8 @@ TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) { resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); resizer->CompleteDrag(0); - EXPECT_TRUE(ash::wm::HasUserChangedWindowPositionOrSize(window_.get())); + EXPECT_TRUE( + wm::GetWindowSettings(window_.get())->bounds_changed_by_user()); } } diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc index 7fbbda2..64e69e2 100644 --- a/ash/wm/workspace_controller.cc +++ b/ash/wm/workspace_controller.cc @@ -10,7 +10,7 @@ #include "ash/wm/base_layout_manager.h" #include "ash/wm/property_util.h" #include "ash/wm/window_animations.h" -#include "ash/wm/window_properties.h" +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace/workspace_event_handler.h" #include "ash/wm/workspace/workspace_layout_manager.h" @@ -65,7 +65,7 @@ WorkspaceWindowState WorkspaceController::GetWindowState() const { bool has_maximized_window = false; for (aura::Window::Windows::const_iterator i = windows.begin(); i != windows.end(); ++i) { - if (GetIgnoredByShelf(*i)) + if (wm::GetWindowSettings(*i)->ignored_by_shelf()) continue; ui::Layer* layer = (*i)->layer(); if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) diff --git a/ash/wm/workspace_controller_unittest.cc b/ash/wm/workspace_controller_unittest.cc index 4327225..39b1906 100644 --- a/ash/wm/workspace_controller_unittest.cc +++ b/ash/wm/workspace_controller_unittest.cc @@ -17,7 +17,7 @@ #include "ash/test/ash_test_base.h" #include "ash/test/shell_test_api.h" #include "ash/wm/property_util.h" -#include "ash/wm/window_properties.h" +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #include "base/command_line.h" #include "base/strings/string_number_conversions.h" @@ -103,8 +103,9 @@ class WorkspaceControllerTest : public test::AshTestBase { aura::Window* CreateBrowserLikeWindow(const gfx::Rect& bounds) { aura::Window* window = CreateTestWindow(); window->SetBounds(bounds); - SetTrackedByWorkspace(window, true); - wm::SetWindowPositionManaged(window, true); + wm::WindowSettings* settings = wm::GetWindowSettings(window); + settings->SetTrackedByWorkspace(true); + settings->set_window_position_managed(true); window->Show(); return window; } @@ -352,7 +353,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); - SetIgnoredByShelf(&(*w_ignored), true); + wm::GetWindowSettings(&(*w_ignored))->set_ignored_by_shelf(true); w_ignored->Show(); EXPECT_FALSE(GetWindowOverlapsShelf()); @@ -694,7 +695,7 @@ TEST_F(WorkspaceControllerTest, TrackedByWorkspace) { w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); SetDefaultParentByPrimaryRootWindow(w2.get()); w2->Show(); - SetTrackedByWorkspace(w2.get(), false); + wm::GetWindowSettings(w2.get())->SetTrackedByWorkspace(false); wm::ActivateWindow(w2.get()); // Activating |w2| should force it to have the same parent as |w1|. @@ -711,7 +712,7 @@ TEST_F(WorkspaceControllerTest, TrackedByWorkspace) { // Transition it to tracked by worskpace. It should end up in the desktop // workspace. - SetTrackedByWorkspace(w2.get(), true); + wm::GetWindowSettings(w2.get())->SetTrackedByWorkspace(true); EXPECT_TRUE(wm::IsActiveWindow(w2.get())); EXPECT_TRUE(w1->IsVisible()); EXPECT_TRUE(w2->IsVisible()); @@ -799,9 +800,10 @@ TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) { EXPECT_EQ("16,32 640x320", window1->bounds().ToString()); // Test 2: Set up two managed windows and check their auto positioning. - ash::wm::SetWindowPositionManaged(window1.get(), true); + wm::GetWindowSettings(window1.get())->set_window_position_managed(true); + scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(2)); - ash::wm::SetWindowPositionManaged(window3.get(), true); + wm::GetWindowSettings(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(); @@ -838,7 +840,7 @@ TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) { // Test4: A single manageable window should get centered. window4.reset(); - ash::wm::SetUserHasChangedWindowPositionOrSize(window1.get(), false); + wm::GetWindowSettings(window1.get())->set_bounds_changed_by_user(false); // Trigger the auto window placement function by showing (and hiding) it. window1->Hide(); window1->Show(); @@ -858,19 +860,19 @@ TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) { window2->SetBounds(gfx::Rect(32, 48, 256, 512)); window1->Hide(); window2->Hide(); - ash::wm::SetWindowPositionManaged(window1.get(), true); - ash::wm::SetWindowPositionManaged(window2.get(), true); - EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get())); - EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window2.get())); + 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()); // Check that the current location gets preserved if the user has // positioned it previously. - ash::wm::SetUserHasChangedWindowPositionOrSize(window1.get(), true); + wm::GetWindowSettings(window1.get())->set_bounds_changed_by_user(true); window1->Show(); EXPECT_EQ("16,32 640x320", window1->bounds().ToString()); // Flag should be still set. - EXPECT_TRUE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get())); - EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window2.get())); + EXPECT_TRUE(wm::GetWindowSettings(window1.get())->bounds_changed_by_user()); + EXPECT_FALSE(wm::GetWindowSettings(window2.get())->bounds_changed_by_user()); // Turn on the second window and make sure that both windows are now // positionable again (user movement cleared). @@ -882,14 +884,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(ash::wm::HasUserChangedWindowPositionOrSize(window1.get())); - EXPECT_FALSE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get())); + EXPECT_FALSE(wm::GetWindowSettings(window1.get())->bounds_changed_by_user()); + EXPECT_FALSE(wm::GetWindowSettings(window2.get())->bounds_changed_by_user()); // Going back to one shown window should keep the state. - ash::wm::SetUserHasChangedWindowPositionOrSize(window1.get(), true); + wm::GetWindowSettings(window1.get())->set_bounds_changed_by_user(true); window2->Hide(); EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); - EXPECT_TRUE(ash::wm::HasUserChangedWindowPositionOrSize(window1.get())); + EXPECT_TRUE(wm::GetWindowSettings(window1.get())->bounds_changed_by_user()); } // Test if the single window will be restored at original position. @@ -903,9 +905,9 @@ TEST_F(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) { window1->Hide(); window2->Hide(); window3->Hide(); - ash::wm::SetWindowPositionManaged(window1.get(), true); - ash::wm::SetWindowPositionManaged(window2.get(), true); - ash::wm::SetWindowPositionManaged(window3.get(), true); + 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); window1->Show(); wm::ActivateWindow(window1.get()); @@ -954,8 +956,8 @@ TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) { window2->SetBounds(gfx::Rect(32, 48, 256, 512)); window1->Hide(); window2->Hide(); - ash::wm::SetWindowPositionManaged(window1.get(), true); - ash::wm::SetWindowPositionManaged(window2.get(), true); + wm::GetWindowSettings(window1.get())->set_window_position_managed(true); + wm::GetWindowSettings(window2.get())->set_window_position_managed(true); window1->Show(); EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString()); window2->Show(); @@ -979,12 +981,12 @@ TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) { // Test that a window from normal to minimize will repos the remaining. TEST_F(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) { scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); - ash::wm::SetWindowPositionManaged(window1.get(), true); + wm::GetWindowSettings(window1.get())->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)); - ash::wm::SetWindowPositionManaged(window2.get(), true); + wm::GetWindowSettings(window2.get())->set_window_position_managed(true); window2->SetBounds(gfx::Rect(32, 48, 256, 512)); ash::wm::MinimizeWindow(window1.get()); @@ -1007,11 +1009,11 @@ 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)); - ash::wm::SetWindowPositionManaged(window1.get(), true); + wm::GetWindowSettings(window1.get())->set_window_position_managed(true); gfx::Rect desktop_area = window1->parent()->bounds(); scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); - ash::wm::SetWindowPositionManaged(window2.get(), true); + wm::GetWindowSettings(window2.get())->set_window_position_managed(true); window2->SetBounds(gfx::Rect(32, 48, 256, 512)); ash::wm::MaximizeWindow(window1.get()); @@ -1029,11 +1031,11 @@ TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) { TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) { scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); window1->SetBounds(gfx::Rect(16, 32, 640, 320)); - ash::wm::SetWindowPositionManaged(window1.get(), true); + wm::GetWindowSettings(window1.get())->set_window_position_managed(true); gfx::Rect desktop_area = window1->parent()->bounds(); scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); - ash::wm::SetWindowPositionManaged(window2.get(), true); + wm::GetWindowSettings(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. @@ -1061,11 +1063,11 @@ TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) { TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) { scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); window1->SetBounds(gfx::Rect(16, 32, 640, 320)); - ash::wm::SetWindowPositionManaged(window1.get(), true); + wm::GetWindowSettings(window1.get())->set_window_position_managed(true); gfx::Rect desktop_area = window1->parent()->bounds(); scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); - ash::wm::SetWindowPositionManaged(window2.get(), true); + wm::GetWindowSettings(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. @@ -1100,8 +1102,8 @@ TEST_F(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) { window2->Hide(); window2->SetBounds(gfx::Rect(32, 48, 256, 512)); - ash::wm::SetWindowPositionManaged(window1.get(), true); - ash::wm::SetWindowPositionManaged(window2.get(), true); + wm::GetWindowSettings(window1.get())->set_window_position_managed(true); + wm::GetWindowSettings(window2.get())->set_window_position_managed(true); // Make sure nothing is animating. window1->layer()->GetAnimator()->StopAnimating(); window2->layer()->GetAnimator()->StopAnimating(); @@ -1275,7 +1277,7 @@ TEST_F(WorkspaceControllerTest, DragFullscreenNonTrackedWindow) { EXPECT_EQ(0, observer.change_count()); // Set tracked to false and repeat, now the window should move. - SetTrackedByWorkspace(w1.get(), false); + wm::GetWindowSettings(w1.get())->SetTrackedByWorkspace(false); generator.MoveMouseTo(5, 5); generator.PressLeftButton(); generator.MoveMouseBy(100, 100); @@ -1284,7 +1286,7 @@ TEST_F(WorkspaceControllerTest, DragFullscreenNonTrackedWindow) { w1->bounds().ToString()); generator.ReleaseLeftButton(); - SetTrackedByWorkspace(w1.get(), true); + wm::GetWindowSettings(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()); @@ -1324,7 +1326,7 @@ TEST_F(WorkspaceControllerTest, DragMaximizedNonTrackedWindow) { EXPECT_EQ(0, observer.change_count()); // Set tracked to false and repeat, now the window should move. - SetTrackedByWorkspace(w1.get(), false); + wm::GetWindowSettings(w1.get())->SetTrackedByWorkspace(false); generator.MoveMouseTo(5, 5); generator.PressLeftButton(); generator.MoveMouseBy(100, 100); @@ -1333,7 +1335,7 @@ TEST_F(WorkspaceControllerTest, DragMaximizedNonTrackedWindow) { w1->bounds().ToString()); generator.ReleaseLeftButton(); - SetTrackedByWorkspace(w1.get(), true); + wm::GetWindowSettings(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()); diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 01c7598..27c1084 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -59,7 +59,7 @@ #endif #if defined(USE_ASH) -#include "ash/wm/window_util.h" +#include "ash/wm/window_settings.h" #endif using content::NavigationController; using content::RenderWidgetHost; @@ -1087,13 +1087,13 @@ class SessionRestoreImpl : public content::NotificationObserver { #if defined(USE_ASH) // Prevent the auto window management for this window on show. - ash::wm::SetUserHasChangedWindowPositionOrSize( - browser->window()->GetNativeWindow(), true); + ash::wm::GetWindowSettings(browser->window()->GetNativeWindow())-> + set_bounds_changed_by_user(true); #endif browser->window()->Show(); #if defined(USE_ASH) - ash::wm::SetUserHasChangedWindowPositionOrSize( - browser->window()->GetNativeWindow(), false); + ash::wm::GetWindowSettings(browser->window()->GetNativeWindow())-> + set_bounds_changed_by_user(false); #endif browser->set_is_session_restore(false); diff --git a/chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.cc index 0a52893..5eaf111 100644 --- a/chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.cc +++ b/chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.cc @@ -6,7 +6,7 @@ #include "apps/native_app_window.h" #include "apps/shell_window.h" -#include "ash/wm/window_properties.h" +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" @@ -147,7 +147,7 @@ void ShellWindowLauncherItemController::Clicked(const ui::Event& event) { aura::Window* panel_window = panel->GetNativeWindow(); // If the panel is attached on another display, move it to the current // display and activate it. - if (panel_window->GetProperty(ash::internal::kPanelAttachedKey) && + if (ash::wm::GetWindowSettings(panel_window)->panel_attached() && ash::wm::MoveWindowToEventRoot(panel_window, event)) { if (!panel->GetBaseWindow()->IsActive()) ShowAndActivateOrMinimize(panel); diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc index a253148..f014184 100644 --- a/chrome/browser/ui/views/apps/native_app_window_views.cc +++ b/chrome/browser/ui/views/apps/native_app_window_views.cc @@ -44,7 +44,7 @@ #include "ash/shell.h" #include "ash/wm/custom_frame_view_ash.h" #include "ash/wm/panels/panel_frame_view.h" -#include "ash/wm/window_properties.h" +#include "ash/wm/window_settings.h" #include "chrome/browser/ui/ash/ash_util.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" @@ -286,7 +286,7 @@ void NativeAppWindowViews::InitializePanelWindow( preferred_size_.width(), preferred_size_.height()); aura::Window* native_window = GetNativeWindow(); - native_window->SetProperty(ash::internal::kPanelAttachedKey, false); + ash::wm::GetWindowSettings(native_window)->set_panel_attached(false); native_window->SetDefaultParentByRootWindow( native_window->GetRootWindow(), native_window->GetBoundsInScreen()); window_->SetBounds(window_bounds); @@ -413,8 +413,8 @@ bool NativeAppWindowViews::IsAlwaysOnTop() const { if (!shell_window_->window_type_is_panel()) return false; #if defined(USE_ASH) - return window_->GetNativeWindow()->GetProperty( - ash::internal::kPanelAttachedKey); + return ash::wm::GetWindowSettings(window_->GetNativeWindow())-> + panel_attached(); #else return true; #endif @@ -751,8 +751,8 @@ bool NativeAppWindowViews::IsDetached() const { if (!shell_window_->window_type_is_panel()) return false; #if defined(USE_ASH) - return !window_->GetNativeWindow()->GetProperty( - ash::internal::kPanelAttachedKey); + return !ash::wm::GetWindowSettings(window_->GetNativeWindow())-> + panel_attached(); #else return false; #endif diff --git a/chrome/browser/ui/views/frame/browser_frame_aura.cc b/chrome/browser/ui/views/frame/browser_frame_aura.cc index b80f5dc..c49fab2 100644 --- a/chrome/browser/ui/views/frame/browser_frame_aura.cc +++ b/chrome/browser/ui/views/frame/browser_frame_aura.cc @@ -18,6 +18,7 @@ #include "ui/views/view.h" #if defined(USE_ASH) +#include "ash/wm/window_settings.h" #include "ash/wm/window_util.h" #endif @@ -166,7 +167,9 @@ BrowserFrameAura::~BrowserFrameAura() { void BrowserFrameAura::SetWindowAutoManaged() { #if defined(USE_ASH) if (browser_view_->browser()->type() != Browser::TYPE_POPUP || - browser_view_->browser()->is_app()) - ash::wm::SetWindowPositionManaged(GetNativeWindow(), true); + browser_view_->browser()->is_app()) { + ash::wm::GetWindowSettings(GetNativeWindow())-> + set_window_position_managed(true); + } #endif } diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc index 0fefaee..6e332cc 100644 --- a/chrome/browser/ui/views/status_bubble_views.cc +++ b/chrome/browser/ui/views/status_bubble_views.cc @@ -35,7 +35,7 @@ #include "url/gurl.h" #if defined(USE_ASH) -#include "ash/wm/property_util.h" +#include "ash/wm/window_settings.h" #endif // The alpha and color of the bubble's shadow. @@ -583,7 +583,8 @@ void StatusBubbleViews::Init() { popup_->SetOpacity(0x00); popup_->SetContentsView(view_); #if defined(USE_ASH) - ash::SetIgnoredByShelf(popup_->GetNativeWindow(), true); + ash::wm::GetWindowSettings(popup_->GetNativeWindow())-> + set_ignored_by_shelf(true); #endif Reposition(); } diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc index 3e8adb6..e6bfd9b 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc @@ -50,8 +50,7 @@ #if defined(USE_ASH) #include "ash/shell.h" #include "ash/wm/coordinate_conversion.h" -#include "ash/wm/property_util.h" -#include "ash/wm/window_util.h" +#include "ash/wm/window_settings.h" #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/base/gestures/gesture_recognizer.h" @@ -192,13 +191,13 @@ class DockView : public views::View { void SetTrackedByWorkspace(gfx::NativeWindow window, bool value) { #if defined(USE_ASH) - ash::SetTrackedByWorkspace(window, value); + ash::wm::GetWindowSettings(window)->SetTrackedByWorkspace(value); #endif } void SetWindowPositionManaged(gfx::NativeWindow window, bool value) { #if defined(USE_ASH) - ash::wm::SetWindowPositionManaged(window, value); + ash::wm::GetWindowSettings(window)->set_window_position_managed(value); #endif } diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc index de31997..6b0e545 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc @@ -4,7 +4,7 @@ #include "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" -#include "ash/wm/property_util.h" +#include "ash/wm/window_settings.h" #include "base/bind.h" #include "base/callback.h" #include "base/command_line.h" @@ -213,7 +213,8 @@ bool GetTrackedByWorkspace(Browser* browser) { #if !defined(USE_ASH) || defined(OS_WIN) // TODO(win_ash) return true; #else - return ash::GetTrackedByWorkspace(browser->window()->GetNativeWindow()); + return ash::wm::GetWindowSettings(browser->window()->GetNativeWindow())-> + tracked_by_workspace(); #endif } @@ -558,10 +559,10 @@ void DetachToOwnWindowStep2(DetachToBrowserTabDragControllerTest* test) { #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) bool IsWindowPositionManaged(aura::Window* window) { - return ash::wm::IsWindowPositionManaged(window); + return ash::wm::GetWindowSettings(window)->window_position_managed(); } bool HasUserChangedWindowPositionOrSize(aura::Window* window) { - return ash::wm::HasUserChangedWindowPositionOrSize(window); + return ash::wm::GetWindowSettings(window)->bounds_changed_by_user(); } #else bool IsWindowPositionManaged(gfx::NativeWindow window) { diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc index b3d460b..2e1d65c 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc +++ b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc @@ -7,7 +7,7 @@ #include "ash/test/ash_test_base.h" #include "ash/test/test_shell_delegate.h" #include "ash/wm/window_resizer.h" -#include "ash/wm/window_util.h" +#include "ash/wm/window_settings.h" #include "base/compiler_specific.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" @@ -61,8 +61,10 @@ class TestBrowserWindowAura : public TestBrowserWindow { Browser::CreateParams create_params = params; create_params.window = this; browser_.reset(new Browser(create_params)); - if (browser_->is_type_tabbed() || browser_->is_app()) - ash::wm::SetWindowPositionManaged(native_window_.get(), true); + if (browser_->is_type_tabbed() || browser_->is_app()) { + ash::wm::GetWindowSettings(native_window_.get())-> + set_window_position_managed(true); + } } private: |