diff options
author | benrg@chromium.org <benrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-11 00:29:18 +0000 |
---|---|---|
committer | benrg@chromium.org <benrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-11 00:29:18 +0000 |
commit | 36e4151d009b1ae6274f5af9449e49f3b6e2198f (patch) | |
tree | be96c516fc90ce183cc1671bd670e35dc89ccb42 /ash | |
parent | 557d199404f668006ab48a4ecc1f8e7f3cc2d2ed (diff) | |
download | chromium_src-36e4151d009b1ae6274f5af9449e49f3b6e2198f.zip chromium_src-36e4151d009b1ae6274f5af9449e49f3b6e2198f.tar.gz chromium_src-36e4151d009b1ae6274f5af9449e49f3b6e2198f.tar.bz2 |
aura::Window only supports void* and int values for custom properties, which must be cast to and from the correct type at each use point. This CL introduces typed properties and templated aura::Window::[GS]etProperty methods that enforce the use of the declared type. Only pointer types and integral types that fits in intptr_t are supported, and ownership behavior is the same as before. This CL also adds support for default property values other than NULL/0.
BUG=none
TEST=updated unit tests
Review URL: http://codereview.chromium.org/8533025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
37 files changed, 218 insertions, 181 deletions
diff --git a/ash/ime/input_method_event_filter.cc b/ash/ime/input_method_event_filter.cc index d9c8e9c..5e45d3e 100644 --- a/ash/ime/input_method_event_filter.cc +++ b/ash/ime/input_method_event_filter.cc @@ -25,7 +25,7 @@ InputMethodEventFilter::InputMethodEventFilter() // result to Init(). input_method_->Init(true); aura::RootWindow::GetInstance()->SetProperty( - aura::client::kRootWindowInputMethod, + aura::client::kRootWindowInputMethodKey, input_method_.get()); } diff --git a/ash/ime/input_method_event_filter_unittest.cc b/ash/ime/input_method_event_filter_unittest.cc index 83fe1fd..432d742 100644 --- a/ash/ime/input_method_event_filter_unittest.cc +++ b/ash/ime/input_method_event_filter_unittest.cc @@ -36,10 +36,12 @@ TEST_F(InputMethodEventFilterTestWithoutShell, TestInputMethodProperty) { aura::RootWindow* root_window = aura::RootWindow::GetInstance(); scoped_ptr<internal::RootWindowEventFilter> root_filter( new internal::RootWindowEventFilter); - EXPECT_FALSE(root_window->GetProperty(aura::client::kRootWindowInputMethod)); + EXPECT_FALSE( + root_window->GetProperty(aura::client::kRootWindowInputMethodKey)); internal::InputMethodEventFilter ime_filter; root_filter->AddFilter(&ime_filter); - EXPECT_TRUE(root_window->GetProperty(aura::client::kRootWindowInputMethod)); + EXPECT_TRUE( + root_window->GetProperty(aura::client::kRootWindowInputMethodKey)); root_filter->RemoveFilter(&ime_filter); } diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc index 837fa4b..747d90a 100644 --- a/ash/wm/activation_controller.cc +++ b/ash/wm/activation_controller.cc @@ -53,7 +53,7 @@ bool CanActivateWindow(aura::Window* window) { // to the front. This function must be called before the modal transient is // stacked at the top to ensure correct stacking order. void StackTransientParentsBelowModalWindow(aura::Window* window) { - if (window->GetIntProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) + if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) return; aura::Window* transient_parent = window->transient_parent(); @@ -135,7 +135,7 @@ void ActivationController::ActivateWindow(aura::Window* window) { if (!window->Contains(window->GetFocusManager()->GetFocusedWindow())) window->GetFocusManager()->SetFocusedWindow(window); aura::RootWindow::GetInstance()->SetProperty( - aura::client::kRootWindowActiveWindow, + aura::client::kRootWindowActiveWindowKey, window); // Invoke OnLostActive after we've changed the active window. That way if the // delegate queries for active state it doesn't think the window is still @@ -157,9 +157,8 @@ void ActivationController::DeactivateWindow(aura::Window* window) { } aura::Window* ActivationController::GetActiveWindow() { - return reinterpret_cast<aura::Window*>( - aura::RootWindow::GetInstance()->GetProperty( - aura::client::kRootWindowActiveWindow)); + return aura::RootWindow::GetInstance()->GetProperty( + aura::client::kRootWindowActiveWindowKey); } bool ActivationController::CanFocusWindow(aura::Window* window) const { @@ -180,9 +179,8 @@ void ActivationController::OnWindowDestroying(aura::Window* window) { // Clear the property before activating something else, since // ActivateWindow() will attempt to notify the window stored in this value // otherwise. - aura::RootWindow::GetInstance()->SetProperty( - aura::client::kRootWindowActiveWindow, - NULL); + aura::RootWindow::GetInstance()->ClearProperty( + aura::client::kRootWindowActiveWindowKey); ActivateWindow(GetTopmostWindowToActivate(window)); } window->RemoveObserver(this); diff --git a/ash/wm/always_on_top_controller.cc b/ash/wm/always_on_top_controller.cc index da0b2c6d..2c9e920 100644 --- a/ash/wm/always_on_top_controller.cc +++ b/ash/wm/always_on_top_controller.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -57,9 +57,9 @@ void AlwaysOnTopController::OnWillRemoveWindow(aura::Window* child) { } void AlwaysOnTopController::OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) { - if (name == aura::client::kAlwaysOnTopKey) { + const void* key, + intptr_t old) { + if (key == aura::client::kAlwaysOnTopKey) { DCHECK(window->type() == aura::client::WINDOW_TYPE_NORMAL || window->type() == aura::client::WINDOW_TYPE_POPUP); aura::Window* container = GetContainer(window); diff --git a/ash/wm/always_on_top_controller.h b/ash/wm/always_on_top_controller.h index f74dc63..de4666e 100644 --- a/ash/wm/always_on_top_controller.h +++ b/ash/wm/always_on_top_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -38,8 +38,8 @@ class AlwaysOnTopController : public aura::WindowObserver { virtual void OnWindowAdded(aura::Window* child) OVERRIDE; virtual void OnWillRemoveWindow(aura::Window* child) OVERRIDE; virtual void OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) OVERRIDE; + const void* key, + intptr_t old) OVERRIDE; virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; aura::Window* default_container_; diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc index 588c7b5..07897bc 100644 --- a/ash/wm/base_layout_manager.cc +++ b/ash/wm/base_layout_manager.cc @@ -37,9 +37,8 @@ void BaseLayoutManager::OnWindowResized() { void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) { windows_.insert(child); child->AddObserver(this); - if (child->GetProperty(aura::client::kShowStateKey)) { + if (child->GetProperty(aura::client::kShowStateKey)) UpdateBoundsFromShowState(child); - } } void BaseLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { @@ -88,23 +87,22 @@ void BaseLayoutManager::OnRootWindowResized(const gfx::Size& new_size) { // BaseLayoutManager, WindowObserver overrides: void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) { - if (name == aura::client::kShowStateKey) { + const void* key, + intptr_t old) { + if (key == aura::client::kShowStateKey) UpdateBoundsFromShowState(window); - } } ////////////////////////////////////////////////////////////////////////////// // BaseLayoutManager, private: void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) { - switch (window->GetIntProperty(aura::client::kShowStateKey)) { + switch (window->GetProperty(aura::client::kShowStateKey)) { case ui::SHOW_STATE_NORMAL: { // Bounds rect object is owned by the window property dictionary, // so ensure we release it when we're done restoring. scoped_ptr<const gfx::Rect> restore(GetRestoreBounds(window)); - window->SetProperty(aura::client::kRestoreBoundsKey, NULL); + window->ClearProperty(aura::client::kRestoreBoundsKey); if (restore.get()) window->SetBounds(*restore); break; diff --git a/ash/wm/base_layout_manager.h b/ash/wm/base_layout_manager.h index 53f2c7e..624874b 100644 --- a/ash/wm/base_layout_manager.h +++ b/ash/wm/base_layout_manager.h @@ -52,8 +52,8 @@ class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, // WindowObserver overrides: virtual void OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) OVERRIDE; + const void* key, + intptr_t old) OVERRIDE; private: // Update window bounds based on a change in show state. diff --git a/ash/wm/base_layout_manager_unittest.cc b/ash/wm/base_layout_manager_unittest.cc index a21d6f5..a355347 100644 --- a/ash/wm/base_layout_manager_unittest.cc +++ b/ash/wm/base_layout_manager_unittest.cc @@ -48,11 +48,11 @@ class BaseLayoutManagerTest : public aura::test::AuraTestBase { TEST_F(BaseLayoutManagerTest, Maximize) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); // Maximized window fills the work area, not the whole monitor. EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), window->bounds()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_EQ(bounds, window->bounds()); } @@ -60,7 +60,7 @@ TEST_F(BaseLayoutManagerTest, Maximize) { TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), window->bounds()); // Enlarge the root window. We should still match the work area size. @@ -73,12 +73,11 @@ TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) { TEST_F(BaseLayoutManagerTest, Fullscreen) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); - window->SetIntProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_FULLSCREEN); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); // Fullscreen window fills the whole monitor. EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), window->bounds()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_EQ(bounds, window->bounds()); } @@ -87,8 +86,7 @@ TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); // Fullscreen window fills the whole monitor. - window->SetIntProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_FULLSCREEN); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), window->bounds()); // Enlarge the root window. We should still match the monitor size. diff --git a/ash/wm/compact_layout_manager.cc b/ash/wm/compact_layout_manager.cc index 11a5d5f..9cbff21 100644 --- a/ash/wm/compact_layout_manager.cc +++ b/ash/wm/compact_layout_manager.cc @@ -66,7 +66,7 @@ CompactLayoutManager::~CompactLayoutManager() { void CompactLayoutManager::OnWindowAddedToLayout(aura::Window* child) { // Windows added to this container does not need extra animation. if (child->type() == aura::client::WINDOW_TYPE_NORMAL) - child->SetIntProperty(aura::client::kAnimationsDisabledKey, 1); + child->SetProperty(aura::client::kAnimationsDisabledKey, true); BaseLayoutManager::OnWindowAddedToLayout(child); UpdateStatusAreaVisibility(); if (windows().size() > 1 && @@ -89,7 +89,7 @@ void CompactLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { } // Allow window to be animated by others. if (child->type() == aura::client::WINDOW_TYPE_NORMAL) - child->SetIntProperty(aura::client::kAnimationsDisabledKey, 0); + child->SetProperty(aura::client::kAnimationsDisabledKey, false); } void CompactLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, @@ -128,10 +128,10 @@ void CompactLayoutManager::SetChildBounds(aura::Window* child, // CompactLayoutManager, aura::WindowObserver overrides: void CompactLayoutManager::OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) { - BaseLayoutManager::OnWindowPropertyChanged(window, name, old); - if (name == aura::client::kShowStateKey) + const void* key, + intptr_t old) { + BaseLayoutManager::OnWindowPropertyChanged(window, key, old); + if (key == aura::client::kShowStateKey) UpdateStatusAreaVisibility(); } diff --git a/ash/wm/compact_layout_manager.h b/ash/wm/compact_layout_manager.h index 42c33e6..4d713b6 100644 --- a/ash/wm/compact_layout_manager.h +++ b/ash/wm/compact_layout_manager.h @@ -44,8 +44,8 @@ class ASH_EXPORT CompactLayoutManager : public BaseLayoutManager, // aura::WindowObserver overrides: virtual void OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) OVERRIDE; + const void* key, + intptr_t old) OVERRIDE; virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE; // ui::LayerAnimationObserver overrides: diff --git a/ash/wm/compact_layout_manager_unittest.cc b/ash/wm/compact_layout_manager_unittest.cc index 4a15a91..f2768c9e 100644 --- a/ash/wm/compact_layout_manager_unittest.cc +++ b/ash/wm/compact_layout_manager_unittest.cc @@ -114,14 +114,13 @@ TEST_F(CompactLayoutManagerTest, StatusAreaVisibility) { views::Widget* widget = CreateTestWidget(); layout_manager()->set_status_area_widget(widget); EXPECT_TRUE(widget->IsVisible()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); EXPECT_TRUE(widget->IsVisible()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_TRUE(widget->IsVisible()); - window->SetIntProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_FULLSCREEN); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); EXPECT_FALSE(widget->IsVisible()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_TRUE(widget->IsVisible()); } diff --git a/ash/wm/property_util.cc b/ash/wm/property_util.cc index eaac484..4975f35 100644 --- a/ash/wm/property_util.cc +++ b/ash/wm/property_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -22,13 +22,12 @@ void SetRestoreBoundsIfNotSet(aura::Window* window) { } const gfx::Rect* GetRestoreBounds(aura::Window* window) { - return reinterpret_cast<gfx::Rect*>( - window->GetProperty(aura::client::kRestoreBoundsKey)); + return window->GetProperty(aura::client::kRestoreBoundsKey); } void ClearRestoreBounds(aura::Window* window) { delete GetRestoreBounds(window); - window->SetProperty(aura::client::kRestoreBoundsKey, NULL); + window->ClearProperty(aura::client::kRestoreBoundsKey); } } diff --git a/ash/wm/shadow_controller.cc b/ash/wm/shadow_controller.cc index 9403cbb..2f75453 100644 --- a/ash/wm/shadow_controller.cc +++ b/ash/wm/shadow_controller.cc @@ -64,9 +64,9 @@ void ShadowController::OnWindowInitialized(aura::Window* window) { } void ShadowController::OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) { - if (name == kShadowTypeKey) + const void* key, + intptr_t old) { + if (key == kShadowTypeKey) HandlePossibleShadowVisibilityChange(window); } diff --git a/ash/wm/shadow_controller.h b/ash/wm/shadow_controller.h index a8194bc..b1c7e7a 100644 --- a/ash/wm/shadow_controller.h +++ b/ash/wm/shadow_controller.h @@ -55,7 +55,7 @@ class ASH_EXPORT ShadowController : public aura::EnvObserver, // aura::WindowObserver overrides: virtual void OnWindowPropertyChanged( - aura::Window* window, const char* name, void* old) OVERRIDE; + aura::Window* window, const void* key, intptr_t old) OVERRIDE; virtual void OnWindowBoundsChanged( aura::Window* window, const gfx::Rect& bounds) OVERRIDE; virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; diff --git a/ash/wm/shadow_types.cc b/ash/wm/shadow_types.cc index 346a1e8..296986a 100644 --- a/ash/wm/shadow_types.cc +++ b/ash/wm/shadow_types.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -11,11 +11,11 @@ namespace ash { namespace internal { void SetShadowType(aura::Window* window, ShadowType shadow_type) { - window->SetIntProperty(kShadowTypeKey, shadow_type); + window->SetProperty(kShadowTypeKey, shadow_type); } ShadowType GetShadowType(aura::Window* window) { - return static_cast<ShadowType>(window->GetIntProperty(kShadowTypeKey)); + return window->GetProperty(kShadowTypeKey); } } // namespace internal diff --git a/ash/wm/stacking_controller.cc b/ash/wm/stacking_controller.cc index 31c48e9..88499e5 100644 --- a/ash/wm/stacking_controller.cc +++ b/ash/wm/stacking_controller.cc @@ -22,7 +22,7 @@ aura::Window* GetContainer(int id) { bool IsSystemModal(aura::Window* window) { return window->transient_parent() && - window->GetIntProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; + window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; } } // namespace diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc index 0d96b94..b96fb04 100644 --- a/ash/wm/system_modal_container_layout_manager.cc +++ b/ash/wm/system_modal_container_layout_manager.cc @@ -82,14 +82,14 @@ void SystemModalContainerLayoutManager::OnWindowAddedToLayout( child->type() == aura::client::WINDOW_TYPE_NORMAL || child->type() == aura::client::WINDOW_TYPE_POPUP); child->AddObserver(this); - if (child->GetIntProperty(aura::client::kModalKey)) + if (child->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_NONE) AddModalWindow(child); } void SystemModalContainerLayoutManager::OnWillRemoveWindowFromLayout( aura::Window* child) { child->RemoveObserver(this); - if (child->GetIntProperty(aura::client::kModalKey)) + if (child->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_NONE) RemoveModalWindow(child); } @@ -109,14 +109,14 @@ void SystemModalContainerLayoutManager::SetChildBounds( void SystemModalContainerLayoutManager::OnWindowPropertyChanged( aura::Window* window, - const char* key, - void* old) { + const void* key, + intptr_t old) { if (key != aura::client::kModalKey) return; - if (window->GetIntProperty(aura::client::kModalKey)) { + if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_NONE) { AddModalWindow(window); - } else if (static_cast<int>(reinterpret_cast<intptr_t>(old))) { + } else if (static_cast<ui::ModalType>(old) != ui::MODAL_TYPE_NONE) { RemoveModalWindow(window); } } diff --git a/ash/wm/system_modal_container_layout_manager.h b/ash/wm/system_modal_container_layout_manager.h index 309d0f07..3a0a029 100644 --- a/ash/wm/system_modal_container_layout_manager.h +++ b/ash/wm/system_modal_container_layout_manager.h @@ -52,8 +52,8 @@ class ASH_EXPORT SystemModalContainerLayoutManager // Overridden from aura::WindowObserver: virtual void OnWindowPropertyChanged(aura::Window* window, - const char* key, - void* old) OVERRIDE; + const void* key, + intptr_t old) OVERRIDE; // Overridden from ui::ImplicitAnimationObserver: virtual void OnImplicitAnimationsCompleted() OVERRIDE; diff --git a/ash/wm/toplevel_layout_manager.cc b/ash/wm/toplevel_layout_manager.cc index 64302d2..7f86202 100644 --- a/ash/wm/toplevel_layout_manager.cc +++ b/ash/wm/toplevel_layout_manager.cc @@ -81,10 +81,10 @@ void ToplevelLayoutManager::SetChildBounds(aura::Window* child, // ToplevelLayoutManager, WindowObserver overrides: void ToplevelLayoutManager::OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) { - BaseLayoutManager::OnWindowPropertyChanged(window, name, old); - if (name == aura::client::kShowStateKey) + const void* key, + intptr_t old) { + BaseLayoutManager::OnWindowPropertyChanged(window, key, old); + if (key == aura::client::kShowStateKey) UpdateShelfVisibility(); } diff --git a/ash/wm/toplevel_layout_manager.h b/ash/wm/toplevel_layout_manager.h index fd12958..a459ccc 100644 --- a/ash/wm/toplevel_layout_manager.h +++ b/ash/wm/toplevel_layout_manager.h @@ -40,8 +40,8 @@ class ASH_EXPORT ToplevelLayoutManager : public BaseLayoutManager { // WindowObserver overrides: virtual void OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) OVERRIDE; + const void* key, + intptr_t old) OVERRIDE; private: // Updates the visibility of the shelf based on if there are any full screen diff --git a/ash/wm/toplevel_layout_manager_unittest.cc b/ash/wm/toplevel_layout_manager_unittest.cc index 5e06f68..52d4c61 100644 --- a/ash/wm/toplevel_layout_manager_unittest.cc +++ b/ash/wm/toplevel_layout_manager_unittest.cc @@ -68,11 +68,11 @@ class ToplevelLayoutManagerTest : public aura::test::AuraTestBase { TEST_F(ToplevelLayoutManagerTest, Maximize) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); // Maximized window fills the work area, not the whole monitor. EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), window->bounds()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_EQ(bounds, window->bounds()); } @@ -80,7 +80,7 @@ TEST_F(ToplevelLayoutManagerTest, Maximize) { TEST_F(ToplevelLayoutManagerTest, MaximizeRootWindowResize) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), window->bounds()); // Enlarge the root window. We should still match the work area size. @@ -93,12 +93,11 @@ TEST_F(ToplevelLayoutManagerTest, MaximizeRootWindowResize) { TEST_F(ToplevelLayoutManagerTest, Fullscreen) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); - window->SetIntProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_FULLSCREEN); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); // Fullscreen window fills the whole monitor. EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), window->bounds()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_EQ(bounds, window->bounds()); } @@ -107,8 +106,7 @@ TEST_F(ToplevelLayoutManagerTest, FullscreenRootWindowResize) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); // Fullscreen window fills the whole monitor. - window->SetIntProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_FULLSCREEN); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), window->bounds()); // Enlarge the root window. We should still match the monitor size. @@ -193,14 +191,13 @@ TEST_F(ToplevelLayoutManagerTest, ShelfVisibility) { new internal::ShelfLayoutManager(launcher, status)); layout_manager()->set_shelf(shelf_layout_manager.get()); EXPECT_TRUE(shelf_layout_manager.get()->visible()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); EXPECT_TRUE(shelf_layout_manager.get()->visible()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_TRUE(shelf_layout_manager.get()->visible()); - window->SetIntProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_FULLSCREEN); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); EXPECT_FALSE(shelf_layout_manager.get()->visible()); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_TRUE(shelf_layout_manager.get()->visible()); // Window depends on layout manager for cleanup. window.reset(); diff --git a/ash/wm/toplevel_window_event_filter.cc b/ash/wm/toplevel_window_event_filter.cc index 1015721..88f0307 100644 --- a/ash/wm/toplevel_window_event_filter.cc +++ b/ash/wm/toplevel_window_event_filter.cc @@ -129,9 +129,9 @@ bool IsBottomEdge(int window_component) { } void ToggleMaximizedState(aura::Window* window) { - window->SetIntProperty(aura::client::kShowStateKey, - window_util::IsWindowMaximized(window) ? - ui::SHOW_STATE_NORMAL : ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, + window_util::IsWindowMaximized(window) ? + ui::SHOW_STATE_NORMAL : ui::SHOW_STATE_MAXIMIZED); } // Returns a location >= |location| that is aligned to fall on increments of @@ -314,10 +314,8 @@ bool ToplevelWindowEventFilter::HandleDrag(aura::Window* target, return false; // Only a normal/default window can be moved/resized. - if (target->GetIntProperty(aura::client::kShowStateKey) != - ui::SHOW_STATE_NORMAL && - target->GetIntProperty(aura::client::kShowStateKey) != - ui::SHOW_STATE_DEFAULT) + ui::WindowShowState state = target->GetProperty(aura::client::kShowStateKey); + if (state != ui::SHOW_STATE_NORMAL && state != ui::SHOW_STATE_DEFAULT) return false; // Dragging a window moves the local coordinate frame, so do arithmetic diff --git a/ash/wm/visibility_controller.cc b/ash/wm/visibility_controller.cc index 6473982..94b9397 100644 --- a/ash/wm/visibility_controller.cc +++ b/ash/wm/visibility_controller.cc @@ -6,20 +6,26 @@ #include "ash/wm/window_animations.h" #include "ui/aura/window.h" +#include "ui/aura/window_property.h" + +DECLARE_WINDOW_PROPERTY_TYPE(bool) namespace ash { namespace internal { namespace { // Property set on all windows whose child windows' visibility changes are -// animated. The type of the value is bool. -const char kChildWindowVisibilityChangesAnimated[] = - "ash/wm/ChildWindowVisibilityChangesAnimated"; +// animated. +const aura::WindowProperty<bool> + kChildWindowVisibilityChangesAnimatedProp = {false}; +const aura::WindowProperty<bool>* const + kChildWindowVisibilityChangesAnimatedKey = + &kChildWindowVisibilityChangesAnimatedProp; bool GetChildWindowVisibilityChangesAnimated(aura::Window* window) { if (!window) return false; - return window->GetIntProperty(kChildWindowVisibilityChangesAnimated) != 0; + return window->GetProperty(kChildWindowVisibilityChangesAnimatedKey); } } // namespace @@ -56,7 +62,7 @@ void VisibilityController::UpdateLayerVisibility(aura::Window* window, } // namespace internal void SetChildWindowVisibilityChangesAnimated(aura::Window* window) { - window->SetIntProperty(internal::kChildWindowVisibilityChangesAnimated, 1); + window->SetProperty(internal::kChildWindowVisibilityChangesAnimatedKey, true); } } // namespace ash diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc index c2deef2..10abe20 100644 --- a/ash/wm/window_animations.cc +++ b/ash/wm/window_animations.cc @@ -14,45 +14,61 @@ #include "ui/aura/client/aura_constants.h" #include "ui/aura/window.h" #include "ui/aura/window_observer.h" +#include "ui/aura/window_property.h" #include "ui/gfx/compositor/layer_animation_observer.h" #include "ui/gfx/compositor/scoped_layer_animation_settings.h" +DECLARE_WINDOW_PROPERTY_TYPE(int) +DECLARE_WINDOW_PROPERTY_TYPE(ash::WindowVisibilityAnimationType) +DECLARE_WINDOW_PROPERTY_TYPE(ash::WindowVisibilityAnimationTransition) + namespace ash { namespace internal { -const char kWindowVisibilityAnimationTypeKey[] = - "WindowVisibilityAnimationType"; +namespace { + +const aura::WindowProperty<WindowVisibilityAnimationType> + kWindowVisibilityAnimationTypeProp = + {WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT}; +const aura::WindowProperty<int> kWindowVisibilityAnimationDurationProp = {0}; +const aura::WindowProperty<WindowVisibilityAnimationTransition> + kWindowVisibilityAnimationTransitionProp = {ANIMATE_BOTH}; + +} // namespace -const char kWindowVisibilityAnimationDurationKey[] = - "WindowVisibilityAnimationDuration"; +const aura::WindowProperty<WindowVisibilityAnimationType>* const + kWindowVisibilityAnimationTypeKey = &kWindowVisibilityAnimationTypeProp; +const aura::WindowProperty<int>* const kWindowVisibilityAnimationDurationKey = + &kWindowVisibilityAnimationDurationProp; +const aura::WindowProperty<WindowVisibilityAnimationTransition>* const + kWindowVisibilityAnimationTransitionKey = + &kWindowVisibilityAnimationTransitionProp; -const char kWindowVisibilityAnimationTransitionKey[] = - "WindowVisibilityAnimationTransition"; } // namespace internal void SetWindowVisibilityAnimationType(aura::Window* window, WindowVisibilityAnimationType type) { - window->SetIntProperty(internal::kWindowVisibilityAnimationTypeKey, type); + window->SetProperty(internal::kWindowVisibilityAnimationTypeKey, type); } void SetWindowVisibilityAnimationTransition( aura::Window* window, WindowVisibilityAnimationTransition transition) { - window->SetIntProperty(internal::kWindowVisibilityAnimationTransitionKey, - transition); + window->SetProperty(internal::kWindowVisibilityAnimationTransitionKey, + transition); } void SetWindowVisibilityAnimationDuration(aura::Window* window, const base::TimeDelta& duration) { - window->SetIntProperty(internal::kWindowVisibilityAnimationDurationKey, - static_cast<int>(duration.ToInternalValue())); + window->SetProperty(internal::kWindowVisibilityAnimationDurationKey, + static_cast<int>(duration.ToInternalValue())); } bool HasWindowVisibilityAnimationTransition( aura::Window* window, WindowVisibilityAnimationTransition transition) { - int prop = window->GetIntProperty( + WindowVisibilityAnimationTransition prop = window->GetProperty( internal::kWindowVisibilityAnimationTransitionKey); - return !prop || (prop & transition) != 0; + return (prop & transition) != 0; } namespace internal { @@ -69,8 +85,7 @@ const float kWindowAnimation_Vertical_TranslateY = 15.f; WindowVisibilityAnimationType GetWindowVisibilityAnimationType( aura::Window* window) { WindowVisibilityAnimationType type = - static_cast<WindowVisibilityAnimationType>( - window->GetIntProperty(kWindowVisibilityAnimationTypeKey)); + window->GetProperty(kWindowVisibilityAnimationTypeKey); if (type == WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT) { return window->type() == aura::client::WINDOW_TYPE_MENU ? WINDOW_VISIBILITY_ANIMATION_TYPE_FADE : @@ -154,7 +169,7 @@ void AnimateShowWindowCommon(aura::Window* window, // Property sets within this scope will be implicitly animated. ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); int duration = - window->GetIntProperty(internal::kWindowVisibilityAnimationDurationKey); + window->GetProperty(internal::kWindowVisibilityAnimationDurationKey); if (duration > 0) { settings.SetTransitionDuration( base::TimeDelta::FromInternalValue(duration)); @@ -176,7 +191,7 @@ void AnimateHideWindowCommon(aura::Window* window, settings.AddObserver(new HidingWindowAnimationObserver(window)); int duration = - window->GetIntProperty(internal::kWindowVisibilityAnimationDurationKey); + window->GetProperty(internal::kWindowVisibilityAnimationDurationKey); if (duration > 0) { settings.SetTransitionDuration( base::TimeDelta::FromInternalValue(duration)); @@ -275,7 +290,7 @@ bool AnimateHideWindow(aura::Window* window) { // WindowAnimation, public: bool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible) { - if (window->GetIntProperty(aura::client::kAnimationsDisabledKey) == 1 || + if (window->GetProperty(aura::client::kAnimationsDisabledKey) || CommandLine::ForCurrentProcess()->HasSwitch( switches::kAuraWindowAnimationsDisabled)) { return false; diff --git a/ash/wm/window_frame.cc b/ash/wm/window_frame.cc index 4f46571..4d17f7b 100644 --- a/ash/wm/window_frame.cc +++ b/ash/wm/window_frame.cc @@ -1,11 +1,21 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/wm/window_frame.h" +#include "ui/aura/window_property.h" + +DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, ash::WindowFrame*) + namespace ash { +namespace { + +const aura::WindowProperty<WindowFrame*> kWindowFrameProp = {NULL}; + +} // namespace -const char* const kWindowFrameKey = "WindowFrameKey"; +const aura::WindowProperty<WindowFrame*>* const + kWindowFrameKey = &kWindowFrameProp; -} +} // namespace ash diff --git a/ash/wm/window_frame.h b/ash/wm/window_frame.h index 228e1fd..85be38d 100644 --- a/ash/wm/window_frame.h +++ b/ash/wm/window_frame.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -7,12 +7,10 @@ #pragma once #include "ash/ash_export.h" +#include "ui/aura/window.h" namespace ash { -// aura::Window property name for a pointer to the WindowFrame interface. -ASH_EXPORT extern const char* const kWindowFrameKey; - // Interface for clients implementing a window frame. Implementors should // add a pointer to this interface to each aura::Window, using the key above. class ASH_EXPORT WindowFrame { @@ -23,6 +21,10 @@ class ASH_EXPORT WindowFrame { virtual void OnWindowHoverChanged(bool hovered) = 0; }; +// aura::Window property name for a pointer to the WindowFrame interface. +ASH_EXPORT extern const aura::WindowProperty<WindowFrame*>* const + kWindowFrameKey; + } // namespace ash #endif // ASH_WM_WINDOW_FRAME_H_ diff --git a/ash/wm/window_modality_controller.cc b/ash/wm/window_modality_controller.cc index b3daff1..f459cf3 100644 --- a/ash/wm/window_modality_controller.cc +++ b/ash/wm/window_modality_controller.cc @@ -16,8 +16,7 @@ namespace internal { namespace { bool TransientChildIsWindowModal(aura::Window* window) { - return window->GetIntProperty(aura::client::kModalKey) == - ui::MODAL_TYPE_WINDOW; + return window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_WINDOW; } } diff --git a/ash/wm/window_modality_controller_unittest.cc b/ash/wm/window_modality_controller_unittest.cc index e33e551..c1eb06a 100644 --- a/ash/wm/window_modality_controller_unittest.cc +++ b/ash/wm/window_modality_controller_unittest.cc @@ -51,7 +51,7 @@ TEST_F(WindowModalityControllerTest, BasicActivation) { ActivateWindow(w11.get()); EXPECT_TRUE(IsActiveWindow(w11.get())); - w12->SetIntProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); + w12->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); w1->AddTransientChild(w12.get()); ActivateWindow(w12.get()); EXPECT_TRUE(IsActiveWindow(w12.get())); @@ -101,8 +101,8 @@ TEST_F(WindowModalityControllerTest, NestedModals) { EXPECT_TRUE(IsActiveWindow(w2.get())); // Set up modality. - w11->SetIntProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); - w111->SetIntProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); + w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); + w111->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); ActivateWindow(w1.get()); EXPECT_TRUE(IsActiveWindow(w111.get())); @@ -155,8 +155,8 @@ TEST_F(WindowModalityControllerTest, NestedModalsOuterClosed) { EXPECT_TRUE(IsActiveWindow(w2.get())); // Set up modality. - w11->SetIntProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); - w111->SetIntProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); + w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); + w111->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); ActivateWindow(w1.get()); EXPECT_TRUE(IsActiveWindow(w111)); @@ -182,7 +182,7 @@ TEST_F(WindowModalityControllerTest, Events) { EXPECT_TRUE(IsActiveWindow(w1.get())); } - w11->SetIntProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); + w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); { // Clicking a point within w1 should activate w11. diff --git a/ash/wm/window_properties.cc b/ash/wm/window_properties.cc index c1c33f0..04ecfd1 100644 --- a/ash/wm/window_properties.cc +++ b/ash/wm/window_properties.cc @@ -1,17 +1,28 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/wm/window_properties.h" +#include "ash/wm/shadow_types.h" +#include "ui/aura/window_property.h" + +DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::ShadowType) + namespace ash { namespace internal { +namespace { + // Alphabetical sort. -const char kShadowTypeKey[] = "ShadowType"; +const aura::WindowProperty<ShadowType> kShadowTypeProp = {SHADOW_TYPE_NONE}; + +} // namespace // Alphabetical sort. +const aura::WindowProperty<ShadowType>* const kShadowTypeKey = &kShadowTypeProp; + } // namespace internal } // namespace ash diff --git a/ash/wm/window_properties.h b/ash/wm/window_properties.h index a090c35..a2edb8a 100644 --- a/ash/wm/window_properties.h +++ b/ash/wm/window_properties.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -6,6 +6,9 @@ #define ASH_WM_WINDOW_PROPERTIES_H_ #pragma once +#include "ash/wm/shadow_types.h" +#include "ui/aura/window.h" + namespace ash { namespace internal { @@ -13,9 +16,9 @@ namespace internal { // Alphabetical sort. -// A property key for a value from ShadowType describing the drop shadow that -// should be displayed under the window. If unset, no shadow is displayed. -extern const char kShadowTypeKey[]; +// A property key describing the drop shadow that should be displayed under the +// window. If unset, no shadow is displayed. +extern const aura::WindowProperty<ShadowType>* const kShadowTypeKey; // Alphabetical sort. diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc index 055244d..5571464 100644 --- a/ash/wm/window_util.cc +++ b/ash/wm/window_util.cc @@ -9,14 +9,19 @@ #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" +#include "ui/aura/window_property.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/screen.h" +DECLARE_WINDOW_PROPERTY_TYPE(bool) + namespace ash { namespace { -const char kOpenWindowSplitKey[] = "OpenWindowSplit"; +const aura::WindowProperty<bool> kOpenWindowSplitProp = {false}; +const aura::WindowProperty<bool>* const + kOpenWindowSplitKey = &kOpenWindowSplitProp; } // namespace @@ -43,26 +48,26 @@ aura::Window* GetActivatableWindow(aura::Window* window) { namespace window_util { bool IsWindowMaximized(aura::Window* window) { - return window->GetIntProperty(aura::client::kShowStateKey) == + return window->GetProperty(aura::client::kShowStateKey) == ui::SHOW_STATE_MAXIMIZED; } bool IsWindowFullscreen(aura::Window* window) { - return window->GetIntProperty(aura::client::kShowStateKey) == + return window->GetProperty(aura::client::kShowStateKey) == ui::SHOW_STATE_FULLSCREEN; } void MaximizeWindow(aura::Window* window) { - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); } void RestoreWindow(aura::Window* window) { - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); } bool HasFullscreenWindow(const WindowSet& windows) { for (WindowSet::const_iterator i = windows.begin(); i != windows.end(); ++i) { - if ((*i)->GetIntProperty(aura::client::kShowStateKey) + if ((*i)->GetProperty(aura::client::kShowStateKey) == ui::SHOW_STATE_FULLSCREEN) { return true; } @@ -71,11 +76,11 @@ bool HasFullscreenWindow(const WindowSet& windows) { } void SetOpenWindowSplit(aura::Window* window, bool value) { - window->SetIntProperty(kOpenWindowSplitKey, value ? 1 : 0); + window->SetProperty(kOpenWindowSplitKey, value); } bool GetOpenWindowSplit(aura::Window* window) { - return window->GetIntProperty(kOpenWindowSplitKey) == 1; + return window->GetProperty(kOpenWindowSplitKey); } } // namespace window_util diff --git a/ash/wm/workspace/workspace_event_filter.cc b/ash/wm/workspace/workspace_event_filter.cc index 0988e2b..ef6949e 100644 --- a/ash/wm/workspace/workspace_event_filter.cc +++ b/ash/wm/workspace/workspace_event_filter.cc @@ -18,9 +18,7 @@ namespace { void WindowHoverChanged(aura::Window* window, bool hovered) { if (!window) return; - ash::WindowFrame* window_frame = - static_cast<ash::WindowFrame*>( - window->GetProperty(ash::kWindowFrameKey)); + ash::WindowFrame* window_frame = window->GetProperty(ash::kWindowFrameKey); if (!window_frame) return; window_frame->OnWindowHoverChanged(hovered); diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc index 3be76c8..6e225f6 100644 --- a/ash/wm/workspace/workspace_manager.cc +++ b/ash/wm/workspace/workspace_manager.cc @@ -122,11 +122,10 @@ void WorkspaceManager::AddWindow(aura::Window* window) { if (!window->GetProperty(aura::client::kShowStateKey)) { if (ShouldMaximize(window)) { - window->SetIntProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_MAXIMIZED); + window->SetProperty(aura::client::kShowStateKey, + ui::SHOW_STATE_MAXIMIZED); } else { - window->SetIntProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); } } @@ -203,12 +202,12 @@ gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { } void WorkspaceManager::OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) { + const void* key, + intptr_t old) { if (!IsManagedWindow(window)) return; - if (name != aura::client::kShowStateKey) + if (key != aura::client::kShowStateKey) return; DCHECK(FindBy(window)); diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h index 5f72bc6..5c25fff 100644 --- a/ash/wm/workspace/workspace_manager.h +++ b/ash/wm/workspace/workspace_manager.h @@ -94,8 +94,8 @@ class ASH_EXPORT WorkspaceManager : public aura::WindowObserver{ // Overriden from aura::WindowObserver: virtual void OnWindowPropertyChanged(aura::Window* window, - const char* name, - void* old) OVERRIDE; + const void* key, + intptr_t old) OVERRIDE; private: friend class Workspace; diff --git a/ash/wm/workspace/workspace_manager_unittest.cc b/ash/wm/workspace/workspace_manager_unittest.cc index e6eff25..a7ba3be 100644 --- a/ash/wm/workspace/workspace_manager_unittest.cc +++ b/ash/wm/workspace/workspace_manager_unittest.cc @@ -48,7 +48,7 @@ class WorkspaceManagerTest : public aura::test::AuraTestBase { aura::Window* CreateTestWindowUnparented() { aura::Window* window = new aura::Window(NULL); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); window->SetType(aura::client::WINDOW_TYPE_NORMAL); window->Init(ui::Layer::LAYER_TEXTURED); return window; @@ -56,7 +56,7 @@ class WorkspaceManagerTest : public aura::test::AuraTestBase { aura::Window* CreateTestWindow() { aura::Window* window = new aura::Window(NULL); - window->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); window->SetType(aura::client::WINDOW_TYPE_NORMAL); window->Init(ui::Layer::LAYER_TEXTURED); window->SetParent(viewport()); @@ -137,7 +137,7 @@ TEST_F(WorkspaceManagerTest, SingleMaximizeWindow) { EXPECT_EQ(251, w1->bounds().height()); // Maximize the window. - w1->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); // Should be 1 workspace, TYPE_MAXIMIZED with w1. ASSERT_EQ(1u, workspaces().size()); @@ -148,7 +148,7 @@ TEST_F(WorkspaceManagerTest, SingleMaximizeWindow) { EXPECT_EQ(GetWorkAreaBounds().height(), w1->bounds().height()); // Restore the window. - w1->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); // Should be 1 workspace, TYPE_NORMAL with w1. ASSERT_EQ(1u, workspaces().size()); @@ -165,7 +165,7 @@ TEST_F(WorkspaceManagerTest, CloseLastWindowInWorkspace) { scoped_ptr<Window> w2(CreateTestWindow()); w1->SetBounds(gfx::Rect(0, 0, 250, 251)); w1->Show(); - w2->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); w2->Show(); // Should be 2 workspaces, TYPE_NORMAL with w1, and TYPE_MAXIMIZED with w2. @@ -197,7 +197,7 @@ TEST_F(WorkspaceManagerTest, CloseLastWindowInWorkspace) { TEST_F(WorkspaceManagerTest, AddMaximizedWindowWhenEmpty) { scoped_ptr<Window> w1(CreateTestWindow()); w1->SetBounds(gfx::Rect(0, 0, 250, 251)); - w1->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); w1->Show(); ASSERT_TRUE(w1->layer() != NULL); @@ -225,7 +225,7 @@ TEST_F(WorkspaceManagerTest, MaximizeWithNormalWindow) { EXPECT_TRUE(w1->layer()->visible()); w2->SetBounds(gfx::Rect(0, 0, 50, 51)); - w2->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); w2->Show(); // Should now be two workspaces. @@ -247,7 +247,7 @@ TEST_F(WorkspaceManagerTest, MaximizeWithNormalWindow) { EXPECT_EQ(work_area.height(), w2->bounds().height()); // Restore w2, which should then go back to one workspace. - w2->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); ASSERT_EQ(1u, workspaces().size()); EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type()); ASSERT_EQ(2u, workspaces()[0]->windows().size()); @@ -267,10 +267,10 @@ TEST_F(WorkspaceManagerTest, TwoMaximized) { scoped_ptr<Window> w2(CreateTestWindow()); w1->SetBounds(gfx::Rect(0, 0, 250, 251)); w1->Show(); - w1->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); w2->SetBounds(gfx::Rect(0, 0, 50, 51)); - w2->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); w2->Show(); // Should now be two workspaces. @@ -307,7 +307,7 @@ TEST_F(WorkspaceManagerTest, OpenNewWindowsMaximized) { // Default is true for open new windows maximized. EXPECT_TRUE(manager_->open_new_windows_maximized()); // SHOW_STATE_DEFAULT should end up maximized. - w1->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); + w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); w1->SetBounds(gfx::Rect(50, 51, 52, 53)); w1->SetParent(viewport()); // Maximized state and bounds should be set as soon as w1 is added to the @@ -329,7 +329,7 @@ TEST_F(WorkspaceManagerTest, OpenNewWindowsMaximized) { w2->Show(); EXPECT_EQ(gfx::Rect(60, 61, 62, 63), w2->bounds()); EXPECT_EQ(ui::SHOW_STATE_NORMAL, - w2->GetIntProperty(aura::client::kShowStateKey)); + w2->GetProperty(aura::client::kShowStateKey)); // If open news windows maximized is false, SHOW_STATE_DEFAULT should end as // SHOW_STATE_NORMAL. @@ -337,13 +337,13 @@ TEST_F(WorkspaceManagerTest, OpenNewWindowsMaximized) { scoped_ptr<Window> w3(CreateTestWindowUnparented()); // Show state default should end up normal when open new windows maximized is // false. - w3->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); + w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); w3->SetBounds(gfx::Rect(70, 71, 72, 73)); w3->SetParent(viewport()); w3->Show(); EXPECT_EQ(gfx::Rect(70, 71, 72, 73), w3->bounds()); EXPECT_EQ(ui::SHOW_STATE_NORMAL, - w3->GetIntProperty(aura::client::kShowStateKey)); + w3->GetProperty(aura::client::kShowStateKey)); } // Assertions around grid size. @@ -367,7 +367,7 @@ TEST_F(WorkspaceManagerTest, SingleFullscreenWindow) { scoped_ptr<Window> w1(CreateTestWindow()); w1->SetBounds(gfx::Rect(0, 0, 250, 251)); // Make the window fullscreen. - w1->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); + w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); w1->Show(); // Should be 1 workspace, TYPE_MAXIMIZED with w1. @@ -379,7 +379,7 @@ TEST_F(WorkspaceManagerTest, SingleFullscreenWindow) { EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); // Restore the window. - w1->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); // Should be 1 workspace, TYPE_NORMAL with w1. ASSERT_EQ(1u, workspaces().size()); @@ -390,7 +390,7 @@ TEST_F(WorkspaceManagerTest, SingleFullscreenWindow) { EXPECT_EQ(251, w1->bounds().height()); // Back to fullscreen. - w1->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); + w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); ASSERT_EQ(1u, workspaces().size()); EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[0]->type()); ASSERT_EQ(1u, workspaces()[0]->windows().size()); diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc index 6b2a3fc..e7bba9a 100644 --- a/ash/wm/workspace_controller.cc +++ b/ash/wm/workspace_controller.cc @@ -76,9 +76,9 @@ void WorkspaceController::OnRootWindowResized(const gfx::Size& new_size) { } void WorkspaceController::OnWindowPropertyChanged(aura::Window* window, - const char* key, - void* old) { - if (key == aura::client::kRootWindowActiveWindow) + const void* key, + intptr_t old) { + if (key == aura::client::kRootWindowActiveWindowKey) workspace_manager_->SetActiveWorkspaceByWindow(GetActiveWindow()); } diff --git a/ash/wm/workspace_controller.h b/ash/wm/workspace_controller.h index b6998c5..7ea212b 100644 --- a/ash/wm/workspace_controller.h +++ b/ash/wm/workspace_controller.h @@ -60,8 +60,8 @@ class ASH_EXPORT WorkspaceController : // aura::WindowObserver overrides: virtual void OnWindowPropertyChanged(aura::Window* window, - const char* key, - void* old) OVERRIDE; + const void* key, + intptr_t old) OVERRIDE; // ui::SimpleMenuModel::Delegate overrides: virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |