diff options
author | jennyz@google.com <jennyz@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 21:58:34 +0000 |
---|---|---|
committer | jennyz@google.com <jennyz@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 21:58:34 +0000 |
commit | 7510d108021bc6b0efeb42ea18f29c266bf9e780 (patch) | |
tree | 5bb819c59ce26ce16e6c37642dded04912c3f56d /ash | |
parent | fbbdfde4a18779c48b73a729d1b744954b6b8ce8 (diff) | |
download | chromium_src-7510d108021bc6b0efeb42ea18f29c266bf9e780.zip chromium_src-7510d108021bc6b0efeb42ea18f29c266bf9e780.tar.gz chromium_src-7510d108021bc6b0efeb42ea18f29c266bf9e780.tar.bz2 |
Always show launcher and status if the app list is opened.
BUG=120230
TEST=The launcher and status should always be visible when app list is open.
Review URL: https://chromiumcodereview.appspot.com/9802041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/app_list/app_list.cc | 5 | ||||
-rw-r--r-- | ash/app_list/app_list.h | 4 | ||||
-rw-r--r-- | ash/app_list/app_list_view.cc | 8 | ||||
-rw-r--r-- | ash/shell.cc | 4 | ||||
-rw-r--r-- | ash/shell.h | 3 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager.cc | 3 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager_unittest.cc | 101 |
7 files changed, 126 insertions, 2 deletions
diff --git a/ash/app_list/app_list.cc b/ash/app_list/app_list.cc index 6972eb0..5d6aae1 100644 --- a/ash/app_list/app_list.cc +++ b/ash/app_list/app_list.cc @@ -8,6 +8,7 @@ #include "ash/shell_delegate.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" +#include "ash/wm/shelf_layout_manager.h" #include "ui/aura/event.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" @@ -58,6 +59,10 @@ void AppList::SetVisible(bool visible) { is_visible_ = visible; + // App list needs to know the new shelf layout in order to calculate its + // UI layout when AppListView visibility changes. + Shell::GetInstance()->shelf()->UpdateAutoHideState(); + if (view_) { ScheduleAnimation(); } else if (is_visible_) { diff --git a/ash/app_list/app_list.h b/ash/app_list/app_list.h index 04656bc..639d088 100644 --- a/ash/app_list/app_list.h +++ b/ash/app_list/app_list.h @@ -38,6 +38,10 @@ class AppList : public aura::EventFilter, // Whether app list window is visible (shown or being shown). bool IsVisible(); + // Returns target visibility. This differs from IsVisible() if an animation + // is ongoing. + bool GetTargetVisibility() const { return is_visible_; } + private: // Sets app list view. If we are in visible mode, start showing animation. // Otherwise, we just close it. diff --git a/ash/app_list/app_list_view.cc b/ash/app_list/app_list_view.cc index 26ca934..c3ed706 100644 --- a/ash/app_list/app_list_view.cc +++ b/ash/app_list/app_list_view.cc @@ -8,8 +8,10 @@ #include "ash/app_list/app_list_model.h" #include "ash/app_list/app_list_model_view.h" #include "ash/app_list/app_list_view_delegate.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" +#include "ash/wm/shelf_layout_manager.h" #include "ui/gfx/compositor/layer.h" #include "ui/gfx/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/screen.h" @@ -117,8 +119,10 @@ void AppListView::Layout() { return; // Gets work area rect, which is in screen coordinates. - gfx::Rect workarea = gfx::Screen::GetMonitorWorkAreaNearestWindow( - GetWidget()->GetNativeView()); + gfx::Rect workarea = Shell::GetInstance()->shelf()->IsVisible() ? + ScreenAsh::GetUnmaximizedWorkAreaBounds(GetWidget()->GetNativeView()) : + gfx::Screen::GetMonitorWorkAreaNearestWindow( + GetWidget()->GetNativeView()); // Converts |workarea| into view's coordinates. gfx::Point origin(workarea.origin()); diff --git a/ash/shell.cc b/ash/shell.cc index 2d1d8d4..21af31b 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -800,6 +800,10 @@ void Shell::ToggleAppList() { app_list_->SetVisible(!app_list_->IsVisible()); } +bool Shell::GetAppListTargetVisibility() const { + return app_list_.get() && app_list_->GetTargetVisibility(); +} + bool Shell::IsScreenLocked() const { return !delegate_.get() || delegate_->IsScreenLocked(); } diff --git a/ash/shell.h b/ash/shell.h index 2c864ad..fbf81b6 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -139,6 +139,9 @@ class ASH_EXPORT Shell { // Toggles app list. void ToggleAppList(); + // Returns app list target visibility. + bool GetAppListTargetVisibility() const; + // Returns true if the screen is locked. bool IsScreenLocked() const; diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index 275624e..0251f84 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -396,6 +396,9 @@ ShelfLayoutManager::AutoHideState ShelfLayoutManager::CalculateAutoHideState( return AUTO_HIDE_HIDDEN; Shell* shell = Shell::GetInstance(); + if (shell->GetAppListTargetVisibility()) + return AUTO_HIDE_SHOWN; + if (shell->tray() && shell->tray()->should_show_launcher()) return AUTO_HIDE_SHOWN; diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc index cfe606c..7ab0637 100644 --- a/ash/wm/shelf_layout_manager_unittest.cc +++ b/ash/wm/shelf_layout_manager_unittest.cc @@ -11,6 +11,7 @@ #include "ash/shell_delegate.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" +#include "ui/aura/client/aura_constants.h" #include "ui/aura/env.h" #include "ui/aura/monitor.h" #include "ui/aura/monitor_manager.h" @@ -52,6 +53,17 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase { shelf->SetState(state); } + aura::Window* CreateTestWindow() { + aura::Window* window = new aura::Window(NULL); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); + window->SetType(aura::client::WINDOW_TYPE_NORMAL); + window->Init(ui::LAYER_TEXTURED); + aura::Window* parent = Shell::GetInstance()->GetContainer( + internal::kShellWindowId_DefaultContainer); + window->SetParent(parent); + return window; + } + private: DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); }; @@ -351,5 +363,94 @@ TEST_F(ShelfLayoutManagerTest, VisibileWhenStatusOrLauncherFocused) { EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); } +// Makes sure shelf will be visible when app list opens as shelf is in VISIBLE +// state,and toggling app list won't change shelf visibility state. +TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { + Shell* shell = Shell::GetInstance(); + ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); + shelf->LayoutShelf(); + shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); + + // Create a normal unmaximized windowm shelf should be visible. + aura::Window* window = CreateTestWindow(); + window->SetBounds(gfx::Rect(0, 0, 100, 100)); + window->Show(); + EXPECT_FALSE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); + + // Toggle app list to show, and the shelf stays visible. + shell->ToggleAppList(); + EXPECT_TRUE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); + + // Toggle app list to hide, and the shelf stays visible. + shell->ToggleAppList(); + EXPECT_FALSE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); +} + +// Makes sure shelf will be shown with AUTO_HIDE_SHOWN state when app list opens +// as shelf is in AUTO_HIDE state, and toggling app list won't change shelf +// visibility state. +TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { + Shell* shell = Shell::GetInstance(); + ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); + shelf->LayoutShelf(); + shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); + + // Create a window and show it in maximized state. + aura::Window* window = CreateTestWindow(); + window->SetBounds(gfx::Rect(0, 0, 100, 100)); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); + window->Show(); + + EXPECT_FALSE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); + + // Toggle app list to show. + shell->ToggleAppList(); + // The shelf's auto hide state won't be changed until the timer fires, so + // calling shell->UpdateShelfVisibility() is kind of manually helping it to + // update the state. + shell->UpdateShelfVisibility(); + EXPECT_TRUE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); + EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); + + // Toggle app list to hide. + shell->ToggleAppList(); + EXPECT_FALSE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); +} + +// Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN +// state, and toggling app list won't change shelf visibility state. +TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { + Shell* shell = Shell::GetInstance(); + ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); + // For shelf to be visible, app list is not open in initial state. + shelf->LayoutShelf(); + + // Create a window and make it full screen. + aura::Window* window = CreateTestWindow(); + window->SetBounds(gfx::Rect(0, 0, 100, 100)); + window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); + window->Show(); + + // App list and shelf is not shown. + EXPECT_FALSE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); + + // Toggle app list to show. + shell->ToggleAppList(); + EXPECT_TRUE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); + + // Toggle app list to hide. + shell->ToggleAppList(); + EXPECT_FALSE(shell->GetAppListTargetVisibility()); + EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); +} + } // namespace internal } // namespace ash |