diff options
Diffstat (limited to 'ash/wm')
-rw-r--r-- | ash/wm/app_list_controller.cc | 18 | ||||
-rw-r--r-- | ash/wm/app_list_controller.h | 10 | ||||
-rw-r--r-- | ash/wm/panel_layout_manager.cc | 5 | ||||
-rw-r--r-- | ash/wm/panel_layout_manager.h | 4 | ||||
-rw-r--r-- | ash/wm/panel_layout_manager_unittest.cc | 21 |
5 files changed, 50 insertions, 8 deletions
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index 5ffc075..69b2ed7 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -5,6 +5,7 @@ #include "ash/wm/app_list_controller.h" #include "ash/ash_switches.h" +#include "ash/launcher/launcher.h" #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/shell_delegate.h" @@ -115,6 +116,7 @@ void AppListController::SetView(app_list::AppListView* view) { views::Widget* widget = view_->GetWidget(); widget->AddObserver(this); Shell::GetInstance()->AddEnvEventFilter(this); + Shell::GetInstance()->launcher()->AddIconObserver(this); widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this); widget->GetNativeView()->GetFocusManager()->AddObserver(this); widget->SetOpacity(0); @@ -134,6 +136,7 @@ void AppListController::ResetView() { widget->RemoveObserver(this); GetLayer(widget)->GetAnimator()->RemoveObserver(this); Shell::GetInstance()->RemoveEnvEventFilter(this); + Shell::GetInstance()->launcher()->RemoveIconObserver(this); widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this); widget->GetNativeView()->GetFocusManager()->RemoveObserver(this); view_ = NULL; @@ -168,6 +171,11 @@ void AppListController::ProcessLocatedEvent(const aura::LocatedEvent& event) { } } +void AppListController::UpdateBounds() { + if (view_ && is_visible_) + view_->UpdateBounds(); +} + //////////////////////////////////////////////////////////////////////////////// // AppListController, aura::EventFilter implementation: @@ -218,8 +226,7 @@ void AppListController::OnWindowFocused(aura::Window* window) { // AppListController, aura::RootWindowObserver implementation: void AppListController::OnRootWindowResized(const aura::RootWindow* root, const gfx::Size& old_size) { - if (view_ && is_visible_) - view_->UpdateBounds(); + UpdateBounds(); } //////////////////////////////////////////////////////////////////////////////// @@ -249,5 +256,12 @@ void AppListController::OnShelfAlignmentChanged() { view_->SetBubbleArrowLocation(GetBubbleArrowLocation()); } +//////////////////////////////////////////////////////////////////////////////// +// AppListController, LauncherIconObserver implementation: + +void AppListController::OnLauncherIconPositionsChanged() { + UpdateBounds(); +} + } // namespace internal } // namespace ash diff --git a/ash/wm/app_list_controller.h b/ash/wm/app_list_controller.h index 4031111..303326a 100644 --- a/ash/wm/app_list_controller.h +++ b/ash/wm/app_list_controller.h @@ -6,6 +6,7 @@ #define ASH_WM_APP_LIST_CONTROLLER_H_ #pragma once +#include "ash/launcher/launcher_icon_observer.h" #include "ash/shell_observer.h" #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -36,7 +37,8 @@ class AppListController : public aura::EventFilter, public aura::RootWindowObserver, public ui::ImplicitAnimationObserver, public views::Widget::Observer, - public ShellObserver { + public ShellObserver, + public LauncherIconObserver { public: AppListController(); virtual ~AppListController(); @@ -67,6 +69,9 @@ class AppListController : public aura::EventFilter, void ProcessLocatedEvent(const aura::LocatedEvent& event); + // Makes app list bubble update its bounds. + void UpdateBounds(); + // aura::EventFilter overrides: virtual bool PreHandleKeyEvent(aura::Window* target, aura::KeyEvent* event) OVERRIDE; @@ -94,6 +99,9 @@ class AppListController : public aura::EventFilter, // ShellObserver overrides: virtual void OnShelfAlignmentChanged() OVERRIDE; + // LauncherIconObserver overrides: + virtual void OnLauncherIconPositionsChanged() OVERRIDE; + // Whether we should show or hide app list widget. bool is_visible_; diff --git a/ash/wm/panel_layout_manager.cc b/ash/wm/panel_layout_manager.cc index 1a5d20d..b426c4e 100644 --- a/ash/wm/panel_layout_manager.cc +++ b/ash/wm/panel_layout_manager.cc @@ -5,6 +5,7 @@ #include "ash/wm/panel_layout_manager.h" #include <algorithm> +#include <map> #include "ash/launcher/launcher.h" #include "ash/shell.h" @@ -218,7 +219,11 @@ void PanelLayoutManager::SetChildBounds(aura::Window* child, //////////////////////////////////////////////////////////////////////////////// // PanelLayoutManager, ash::LauncherIconObserver implementation: + void PanelLayoutManager::OnLauncherIconPositionsChanged() { + // TODO: As this is called for every animation step now. Relayout needs to be + // updated to use current icon position instead of use the ideal bounds so + // that the panels slide with their icons instead of jumping. Relayout(); } diff --git a/ash/wm/panel_layout_manager.h b/ash/wm/panel_layout_manager.h index cb3c20c..652ed2e 100644 --- a/ash/wm/panel_layout_manager.h +++ b/ash/wm/panel_layout_manager.h @@ -43,8 +43,8 @@ namespace internal { // its layout manager to this instance, e.g.: // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); -class ASH_EXPORT PanelLayoutManager : - public aura::LayoutManager, +class ASH_EXPORT PanelLayoutManager + : public aura::LayoutManager, public ash::LauncherIconObserver, public aura::client::ActivationChangeObserver { public: diff --git a/ash/wm/panel_layout_manager_unittest.cc b/ash/wm/panel_layout_manager_unittest.cc index f1878ca..947a892 100644 --- a/ash/wm/panel_layout_manager_unittest.cc +++ b/ash/wm/panel_layout_manager_unittest.cc @@ -9,6 +9,7 @@ #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" +#include "ash/test/launcher_view_test_api.h" #include "ash/test/test_launcher_delegate.h" #include "ash/wm/window_util.h" #include "base/basictypes.h" @@ -19,7 +20,6 @@ #include "ui/views/widget/widget.h" namespace ash { - namespace internal { using aura::test::WindowIsAbove; @@ -33,6 +33,11 @@ class PanelLayoutManagerTest : public ash::test::AshTestBase { CommandLine::ForCurrentProcess()->AppendSwitch(switches::kAuraPanelManager); ash::test::AshTestBase::SetUp(); ASSERT_TRUE(ash::test::TestLauncherDelegate::instance()); + + Launcher* launcher = Shell::GetInstance()->launcher(); + launcher_view_test_.reset(new test::LauncherViewTestAPI( + launcher->GetLauncherViewForTest())); + launcher_view_test_->SetAnimationDuration(1); } aura::Window* CreateNormalWindow() { @@ -69,6 +74,9 @@ class PanelLayoutManagerTest : public ash::test::AshTestBase { // TODO(dcheng): This should be const, but GetScreenBoundsOfItemIconForWindow // takes a non-const Window. We can probably fix that. void IsPanelAboveLauncherIcon(aura::Window* panel) { + // Waits until all launcher view animations are done. + launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + Launcher* launcher = Shell::GetInstance()->launcher(); gfx::Rect icon_bounds = launcher->GetScreenBoundsOfItemIconForWindow(panel); ASSERT_FALSE(icon_bounds.IsEmpty()); @@ -104,7 +112,13 @@ class PanelLayoutManagerTest : public ash::test::AshTestBase { return widget->IsVisible(); } + test::LauncherViewTestAPI* launcher_view_test() { + return launcher_view_test_.get(); + } + private: + scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; + DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); }; @@ -147,10 +161,12 @@ TEST_F(PanelLayoutManagerTest, MultiplePanelStacking) { // Changing the active window should update the stacking order. wm::ActivateWindow(w1.get()); + launcher_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); wm::ActivateWindow(w2.get()); + launcher_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); @@ -179,7 +195,6 @@ TEST_F(PanelLayoutManagerTest, MultiplePanelCallout) { EXPECT_NO_FATAL_FAILURE(IsCalloutAbovePanel(w3.get())); w3.reset(); EXPECT_FALSE(IsCalloutVisible()); - } // Tests removing panels. @@ -191,6 +206,7 @@ TEST_F(PanelLayoutManagerTest, RemoveLeftPanel) { // At this point, windows should be stacked with 1 < 2 < 3 wm::ActivateWindow(w1.get()); + launcher_view_test()->RunMessageLoopUntilAnimationsDone(); // Now, windows should be stacked 1 > 2 > 3 w1.reset(); EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); @@ -244,5 +260,4 @@ TEST_F(PanelLayoutManagerTest, RemoveNonActivePanel) { } } // namespace internal - } // namespace ash |