diff options
author | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-22 21:53:25 +0000 |
---|---|---|
committer | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-22 21:53:25 +0000 |
commit | ca8f905b9e13d9698d5f6c38b805e1c390578c9d (patch) | |
tree | 10f1c58c2c5556bcc84fd2eaef1ecd90a2903590 | |
parent | 4f822e3150f526ae4734bbab2906d635d590e44c (diff) | |
download | chromium_src-ca8f905b9e13d9698d5f6c38b805e1c390578c9d.zip chromium_src-ca8f905b9e13d9698d5f6c38b805e1c390578c9d.tar.gz chromium_src-ca8f905b9e13d9698d5f6c38b805e1c390578c9d.tar.bz2 |
Disable auto hide behavior when there are no visible windows.
BUG=164262
Review URL: https://chromiumcodereview.appspot.com/11941008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178110 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/launcher/launcher_tooltip_manager_unittest.cc | 8 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager.cc | 20 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager_unittest.cc | 79 |
3 files changed, 99 insertions, 8 deletions
diff --git a/ash/launcher/launcher_tooltip_manager_unittest.cc b/ash/launcher/launcher_tooltip_manager_unittest.cc index 7cc972a..a4b50cd 100644 --- a/ash/launcher/launcher_tooltip_manager_unittest.cc +++ b/ash/launcher/launcher_tooltip_manager_unittest.cc @@ -142,6 +142,14 @@ TEST_F(LauncherTooltipManagerTest, HideWhenShelfIsHidden) { } TEST_F(LauncherTooltipManagerTest, HideWhenShelfIsAutoHide) { + // Create a visible window so auto-hide behavior is enforced. + views::Widget* dummy = new views::Widget; + views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); + params.bounds = gfx::Rect(0, 0, 200, 200); + params.context = CurrentContext(); + dummy->Init(params); + dummy->Show(); + ShowImmediately(); ASSERT_TRUE(TooltipIsVisible()); diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index 87c6370..52f6b03 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -16,6 +16,8 @@ #include "ash/shell_window_ids.h" #include "ash/system/status_area_widget.h" #include "ash/wm/property_util.h" +#include "ash/wm/window_cycle_controller.h" +#include "ash/wm/window_util.h" #include "ash/wm/workspace_controller.h" #include "ash/wm/workspace/workspace_animations.h" #include "base/auto_reset.h" @@ -858,8 +860,22 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( alignment_ == SHELF_ALIGNMENT_TOP ? -kNotificationBubbleGapHeight : 0); } - return shelf_region.Contains(Shell::GetScreen()->GetCursorScreenPoint()) ? - SHELF_AUTO_HIDE_SHOWN : SHELF_AUTO_HIDE_HIDDEN; + + if (shelf_region.Contains(Shell::GetScreen()->GetCursorScreenPoint())) + return SHELF_AUTO_HIDE_SHOWN; + + const std::vector<aura::Window*> windows = + ash::WindowCycleController::BuildWindowList(NULL); + + // Process the window list and check if there are any visible windows. + for (size_t i = 0; i < windows.size(); ++i) { + if (windows[i] && windows[i]->IsVisible() && + !ash::wm::IsWindowMinimized(windows[i])) + return SHELF_AUTO_HIDE_HIDDEN; + } + + // If there are no visible windows do not hide the shelf. + return SHELF_AUTO_HIDE_SHOWN; } void ShelfLayoutManager::UpdateHitTestBounds() { diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc index 1f8e3a6..51c2d16 100644 --- a/ash/wm/shelf_layout_manager_unittest.cc +++ b/ash/wm/shelf_layout_manager_unittest.cc @@ -176,6 +176,23 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase { return window; } + views::Widget* CreateTestWidgetWithParams( + const views::Widget::InitParams& params) { + views::Widget* out = new views::Widget; + out->Init(params); + out->Show(); + return out; + } + + // Create a simple widget attached to the current context (will + // delete on TearDown). + views::Widget* CreateTestWidget() { + views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); + params.bounds = gfx::Rect(0, 0, 200, 200); + params.context = CurrentContext(); + return CreateTestWidgetWithParams(params); + } + // Overridden from AshTestBase: virtual void SetUp() OVERRIDE { CommandLine::ForCurrentProcess()->AppendSwitch( @@ -807,6 +824,51 @@ TEST_F(ShelfLayoutManagerTest, GestureDrag) { EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); } +TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { + ShelfLayoutManager* shelf = GetShelfLayoutManager(); + shelf->LayoutShelf(); + shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); + + // Create a visible window so auto-hide behavior is enforced + views::Widget* dummy = CreateTestWidget(); + + // Window visible => auto hide behaves normally. + shelf->UpdateVisibilityState(); + EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); + + // Window minimized => auto hide disabled. + dummy->Minimize(); + shelf->UpdateVisibilityState(); + EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); + + // Window closed => auto hide disabled. + dummy->CloseNow(); + shelf->UpdateVisibilityState(); + EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); + + // Multiple window test + views::Widget* window1 = CreateTestWidget(); + views::Widget* window2 = CreateTestWidget(); + + // both visible => normal autohide + shelf->UpdateVisibilityState(); + EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); + + // either minimzed => normal autohide + window2->Minimize(); + shelf->UpdateVisibilityState(); + EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); + window2->Restore(); + window1->Minimize(); + shelf->UpdateVisibilityState(); + EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); + + // both minimzed => disable auto hide + window2->Minimize(); + shelf->UpdateVisibilityState(); + EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); +} + TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) { #if defined(OS_WIN) // This test seems to tickle a race condition on Metro/Ash causing the test @@ -818,6 +880,9 @@ TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) { ShelfLayoutManager* shelf = GetShelfLayoutManager(); shelf->LayoutShelf(); + // Create a visible window so auto-hide behavior is enforced. + CreateTestWidget(); + aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); SystemTray* tray = GetSystemTray(); @@ -866,6 +931,9 @@ TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { #endif ShelfLayoutManager* shelf = GetShelfLayoutManager(); + // Create a visible window so auto-hide behavior is enforced. + CreateTestWidget(); + // Turn on auto-hide for the shelf. shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); @@ -901,17 +969,13 @@ TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); shelf->LayoutShelf(); - views::Widget* widget_one = new views::Widget; views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); params.bounds = gfx::Rect(0, 0, 200, 200); params.context = CurrentContext(); - widget_one->Init(params); - widget_one->Show(); + views::Widget* widget_one = CreateTestWidgetWithParams(params); widget_one->Maximize(); - views::Widget* widget_two = new views::Widget; - widget_two->Init(params); - widget_two->Show(); + views::Widget* widget_two = CreateTestWidgetWithParams(params); widget_two->Maximize(); widget_two->Activate(); @@ -986,6 +1050,9 @@ TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { Shell::GetPrimaryRootWindowController()->status_area_widget(); SystemTray* tray = GetSystemTray(); + // Create a visible window so auto-hide behavior is enforced. + CreateTestWidget(); + shelf->LayoutShelf(); aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |