summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorjonross@chromium.org <jonross@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 20:36:10 +0000
committerjonross@chromium.org <jonross@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 20:36:10 +0000
commit87b83ec128a9f3b2c69fb0254332d39ee92c2e70 (patch)
tree00e9e0025ee10b4be2205df121367b86d66f47aa /ash
parent229094b938e29f8b7118cfb949112575295cd92d (diff)
downloadchromium_src-87b83ec128a9f3b2c69fb0254332d39ee92c2e70.zip
chromium_src-87b83ec128a9f3b2c69fb0254332d39ee92c2e70.tar.gz
chromium_src-87b83ec128a9f3b2c69fb0254332d39ee92c2e70.tar.bz2
Enable Shelf Auto-Hide in TouchView
Re-enable the shelf auto-hide feature, and the supporting gestures, while in touchview mode. This effectively reverts the portions of the following reviews which impact the shelf and the launcher context menu. https://codereview.chromium.org/205603003/ https://codereview.chromium.org/247363005/ TEST=ShelfLayoutManagerTest, LauncherContextMenuTest BUG=370985 Review URL: https://codereview.chromium.org/305003002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275236 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/shelf/shelf_layout_manager.cc41
-rw-r--r--ash/shelf/shelf_layout_manager.h8
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc111
3 files changed, 25 insertions, 135 deletions
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index fce6b9e..4f5358f 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -189,8 +189,6 @@ class ShelfLayoutManager::UpdateShelfObserver
ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf)
: root_window_(shelf->GetNativeView()->GetRootWindow()),
updating_bounds_(false),
- force_shelf_always_visibile_(
- Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled()),
auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER),
alignment_(SHELF_ALIGNMENT_BOTTOM),
shelf_(shelf),
@@ -314,8 +312,7 @@ void ShelfLayoutManager::UpdateVisibilityState() {
if (!workspace_controller_)
return;
- if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked() ||
- IsShelfForcedToBeVisible()) {
+ if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) {
SetState(SHELF_VISIBLE);
} else {
// TODO(zelidrag): Verify shelf drag animation still shows on the device
@@ -390,9 +387,6 @@ void ShelfLayoutManager::RemoveObserver(ShelfLayoutManagerObserver* observer) {
// ShelfLayoutManager, Gesture functions:
void ShelfLayoutManager::OnGestureEdgeSwipe(const ui::GestureEvent& gesture) {
- if (IsShelfForcedToBeVisible())
- return;
-
if (visibility_state() == SHELF_AUTO_HIDE) {
gesture_drag_auto_hide_state_ = SHELF_AUTO_HIDE_SHOWN;
gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
@@ -402,8 +396,6 @@ void ShelfLayoutManager::OnGestureEdgeSwipe(const ui::GestureEvent& gesture) {
}
void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
- if (IsShelfForcedToBeVisible())
- return;
gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS;
gesture_drag_amount_ = 0.f;
gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ?
@@ -413,8 +405,6 @@ void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag(
const ui::GestureEvent& gesture) {
- if (IsShelfForcedToBeVisible())
- return DRAG_SHELF;
bool horizontal = IsHorizontalAlignment();
gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() :
gesture.details().scroll_x();
@@ -439,8 +429,6 @@ ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag(
}
void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
- if (IsShelfForcedToBeVisible())
- return;
bool horizontal = IsHorizontalAlignment();
bool should_change = false;
if (gesture.type() == ui::ET_GESTURE_SCROLL_END) {
@@ -562,18 +550,7 @@ void ShelfLayoutManager::OnLockStateChanged(bool locked) {
}
void ShelfLayoutManager::OnMaximizeModeStarted() {
- DCHECK(!force_shelf_always_visibile_);
- force_shelf_always_visibile_ = true;
- UpdateVisibilityState();
-}
-
-void ShelfLayoutManager::OnMaximizeModeEnded() {
- DCHECK(force_shelf_always_visibile_);
- // Note: At this time Ash::Shell::IsMaximizeModeWindowManagerEnabled() will
- // report true, even though it is in progress of shut down. To address this
- // |force_shelf_always_visibile_| will be read.
- force_shelf_always_visibile_ = false;
- UpdateVisibilityState();
+ SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
}
void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active,
@@ -1024,9 +1001,6 @@ gfx::Rect ShelfLayoutManager::GetAutoHideShowShelfRegionInScreen() const {
ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
ShelfVisibilityState visibility_state) const {
- if (IsShelfForcedToBeVisible())
- return SHELF_AUTO_HIDE_SHOWN;
-
if (visibility_state != SHELF_AUTO_HIDE || !shelf_)
return SHELF_AUTO_HIDE_HIDDEN;
@@ -1139,17 +1113,6 @@ int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const {
return 0;
}
-bool ShelfLayoutManager::IsShelfForcedToBeVisible() const {
- // Bail out early when there is no |workspace_controller_|, which happens
- // during shutdown after PrepareForShutdown.
- if (!workspace_controller_)
- return force_shelf_always_visibile_;
-
- return force_shelf_always_visibile_ &&
- workspace_controller_->GetWindowState() !=
- WORKSPACE_WINDOW_STATE_FULL_SCREEN;
-}
-
void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
bool keyboard_is_about_to_hide = false;
if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty())
diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h
index f0acb42..b411f51 100644
--- a/ash/shelf/shelf_layout_manager.h
+++ b/ash/shelf/shelf_layout_manager.h
@@ -176,7 +176,6 @@ class ASH_EXPORT ShelfLayoutManager :
// Overridden from ash::ShellObserver:
virtual void OnLockStateChanged(bool locked) OVERRIDE;
virtual void OnMaximizeModeStarted() OVERRIDE;
- virtual void OnMaximizeModeEnded() OVERRIDE;
// Overriden from aura::client::ActivationChangeObserver:
virtual void OnWindowActivated(aura::Window* gained_active,
@@ -321,9 +320,6 @@ class ASH_EXPORT ShelfLayoutManager :
int GetWorkAreaSize(const State& state, int size) const;
- // Returns true if the shelf should be forced to be visible.
- bool IsShelfForcedToBeVisible() const;
-
// Overridden from keyboard::KeyboardControllerObserver:
virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE;
@@ -341,10 +337,6 @@ class ASH_EXPORT ShelfLayoutManager :
// UpdateBoundsAndOpacity() again from SetChildBounds().
bool updating_bounds_;
- // If true, the shelf gets forced (e.g. by the maximize mode) to be always
- // visible.
- bool force_shelf_always_visibile_;
-
// See description above setter.
ShelfAutoHideBehavior auto_hide_behavior_;
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index dd5a35d..de47fa9 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -889,38 +889,6 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) {
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
}
-// Check that swipes and mouse interactions do have no impact in Maximize mode.
-TEST_F(ShelfLayoutManagerTest, MaximizeModePreventsMouseHide) {
- aura::Window* root = Shell::GetPrimaryRootWindow();
- aura::test::EventGenerator generator(root, root);
- generator.MoveMouseTo(0, 0);
-
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- views::Widget* widget = new views::Widget;
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
- params.bounds = gfx::Rect(0, 0, 200, 200);
- params.context = CurrentContext();
- // Widget is now owned by the parent window.
- widget->Init(params);
- widget->Maximize();
- widget->Show();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
-
- shelf->OnMaximizeModeStarted();
- // LayoutShelf() forces the animation to completion.
- shelf->LayoutShelf();
-
- // Drag mouse to bottom of screen. In contrast to normal operation the shelf
- // should remain visible.
- generator.MoveMouseTo(0, 0);
- generator.PressLeftButton();
- generator.MoveMouseTo(0, root->bounds().bottom() - 1);
- UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
-}
-
// Test the behavior of the shelf when it is auto hidden and it is on the
// boundary between the primary and the secondary display.
TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) {
@@ -1633,34 +1601,6 @@ TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipeInMaximizeMode) {
EXPECT_TRUE(widget->IsFullscreen());
}
-// Check that in maximize mode gesture swipes on the shelf have no effect.
-TEST_F(ShelfLayoutManagerTest, MaximizeModeGestureEdgeSwipe) {
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
- views::Widget* widget = new views::Widget;
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
- params.bounds = gfx::Rect(0, 0, 200, 200);
- params.context = CurrentContext();
- widget->Init(params);
- widget->Show();
- widget->Maximize();
-
- shelf->LayoutShelf();
-
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- shelf->LayoutShelf();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
-
- shelf->OnMaximizeModeStarted();
- shelf->LayoutShelf();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
-
- aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
- generator.GestureEdgeSwipe();
-
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
-}
-
#if defined(OS_WIN)
// RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962
#define MAYBE_GestureDrag DISABLED_GestureDrag
@@ -2053,34 +1993,6 @@ TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
}
-// Verify that setting the shelf's auto hide mode in maximize mode does not
-// hide.
-TEST_F(ShelfLayoutManagerTest, DoesNotHideInMaximizeMode) {
- EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
-
- GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- scoped_ptr<aura::Window> w1(CreateTestWindow());
- w1->Show();
- ShelfLayoutManager* shelf = GetShelfLayoutManager();
-
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
-
- GetShelfLayoutManager()->OnMaximizeModeStarted();
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
-
- // Setting the state again should have no impact.
- GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
-
- GetShelfLayoutManager()->OnMaximizeModeEnded();
- EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
-}
-
#if defined(OS_CHROMEOS)
#define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge
#else
@@ -2121,4 +2033,27 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) {
EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
}
+// Tests that entering maximize mode resets auto-hide behaviour to be off by
+// default.
+TEST_F(ShelfLayoutManagerTest, MaximizeModeResetsAutohide) {
+ ShelfLayoutManager* shelf = GetShelfLayoutManager();
+ shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.bounds = gfx::Rect(0, 0, 200, 200);
+ params.context = CurrentContext();
+ // Widget is now owned by the parent window.
+ widget->Init(params);
+ widget->Maximize();
+ widget->Show();
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+
+ shelf->OnMaximizeModeStarted();
+ // LayoutShelf() forces the animation to completion
+ shelf->LayoutShelf();
+ EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
+}
+
} // namespace ash