summaryrefslogtreecommitdiffstats
path: root/ash/shelf
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-17 05:08:58 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-17 05:08:58 +0000
commitc48f15005a7bc8b7bedb50f8268d74719aece4d0 (patch)
tree5cd2244825ff721ced92ca1ccd40a77ce172432d /ash/shelf
parent02ca9e0511f9bad20f16c0e3f52b3600676c02e8 (diff)
downloadchromium_src-c48f15005a7bc8b7bedb50f8268d74719aece4d0.zip
chromium_src-c48f15005a7bc8b7bedb50f8268d74719aece4d0.tar.gz
chromium_src-c48f15005a7bc8b7bedb50f8268d74719aece4d0.tar.bz2
Make the shelf stay revealed upon the first edge gesture in immersive fullscreen. This cleans up the code a bit wrt to gestures in immersive fullscreen.
This CL is the less ugly solution to an ugly problem In immersive fullscreen we want the following shelf auto hide behavior: - Set the shelf to auto hide for the duration of immersive fullscreen. - Restore the old auto hide behavior when exiting immersive fullscreen. (If the user changed the auto hide behavior via an edge gesture that sticks) Restoring the shelf auto hide behavior is super ugly, so we are left with not modifying the auto hide behavior when entering immersive fullscreen. We stick the visibility state to SHELF_AUTO_HIDE to get the auto hide behavior with the mouse. For gestures, we set gesture_drag_status_ to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto hide state. The gesture would not make the shelf stick on the first gesture after entering immersive fullscreen because the initial auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_NEVER and SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER) on line 469 in the old code would fail because the autohide behavior would not affect the visibility state in immersive fullscreen. BUG=248680 TEST=ShelfLayoutManagerTest.GestureDrag Review URL: https://chromiumcodereview.appspot.com/17076005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shelf')
-rw-r--r--ash/shelf/shelf_layout_manager.cc51
-rw-r--r--ash/shelf/shelf_layout_manager.h4
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc38
3 files changed, 53 insertions, 40 deletions
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index e50c6fb..d592a8c 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -287,26 +287,12 @@ ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() {
return SHELF_VISIBLE;
}
-ShelfVisibilityState
-ShelfLayoutManager::CalculateShelfVisibilityWhileDragging() {
- switch(auto_hide_behavior_) {
- case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
- case SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
- return SHELF_AUTO_HIDE;
- case SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
- return SHELF_HIDDEN;
- }
- return SHELF_VISIBLE;
-}
-
void ShelfLayoutManager::UpdateVisibilityState() {
if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) {
SetState(SHELF_VISIBLE);
- } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) {
+ } else {
// TODO(zelidrag): Verify shelf drag animation still shows on the device
// when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
- SetState(CalculateShelfVisibilityWhileDragging());
- } else {
WorkspaceWindowState window_state(workspace_controller_->GetWindowState());
switch (window_state) {
case WORKSPACE_WINDOW_STATE_FULL_SCREEN:
@@ -455,23 +441,20 @@ void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
gesture_drag_auto_hide_state_ =
gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ?
SHELF_AUTO_HIDE_HIDDEN : SHELF_AUTO_HIDE_SHOWN;
- if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN &&
- auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) {
- gesture_drag_status_ = GESTURE_DRAG_NONE;
- if (!FullscreenWithMinimalChrome()) {
- SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- } else {
- UpdateVisibilityState();
- }
- } else if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN &&
- auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_NEVER) {
- gesture_drag_status_ = GESTURE_DRAG_NONE;
- SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
- } else {
- gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
+ ShelfAutoHideBehavior new_auto_hide_behavior =
+ gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ?
+ SHELF_AUTO_HIDE_BEHAVIOR_NEVER : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+
+ // In fullscreen with minimal chrome, the auto hide behavior affects neither
+ // the visibility state nor the auto hide state. Set |gesture_drag_status_|
+ // to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto hide state to
+ // |gesture_drag_auto_hide_state_|.
+ gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
+ if (auto_hide_behavior_ != new_auto_hide_behavior)
+ SetAutoHideBehavior(new_auto_hide_behavior);
+ else
UpdateVisibilityState();
- gesture_drag_status_ = GESTURE_DRAG_NONE;
- }
+ gesture_drag_status_ = GESTURE_DRAG_NONE;
LayoutShelf();
}
@@ -752,7 +735,7 @@ void ShelfLayoutManager::CalculateTargetBounds(
}
target_bounds->opacity =
- (gesture_drag_status_ != GESTURE_DRAG_NONE ||
+ (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
state.visibility_state == SHELF_VISIBLE ||
state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f;
@@ -855,9 +838,9 @@ void ShelfLayoutManager::UpdateShelfBackground(
}
bool ShelfLayoutManager::GetLauncherPaintsBackground() const {
- return gesture_drag_status_ != GESTURE_DRAG_NONE ||
+ return gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
(!state_.is_screen_locked && window_overlaps_shelf_) ||
- (state_.visibility_state == SHELF_AUTO_HIDE) ;
+ (state_.visibility_state == SHELF_AUTO_HIDE);
}
void ShelfLayoutManager::UpdateAutoHideStateNow() {
diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h
index 070e6d5..e731cf1 100644
--- a/ash/shelf/shelf_layout_manager.h
+++ b/ash/shelf/shelf_layout_manager.h
@@ -108,10 +108,6 @@ class ASH_EXPORT ShelfLayoutManager :
// behavior setting.
ShelfVisibilityState CalculateShelfVisibility();
- // Returns shelf visibility state based on current value of auto hide
- // behavior setting.
- ShelfVisibilityState CalculateShelfVisibilityWhileDragging();
-
// Updates the visibility state.
void UpdateVisibilityState();
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 5aa5ba2..a0db945 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -22,6 +22,7 @@
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_item.h"
#include "ash/test/ash_test_base.h"
+#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
@@ -518,17 +519,50 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
EXPECT_EQ(shelf_hidden.ToString(),
GetShelfWidget()->GetWindowBoundsInScreen().ToString());
- // Make the window fullscreen.
+ // Enter into fullscreen with minimal chrome (immersive fullscreen).
widget->SetFullscreen(true);
+ window->SetProperty(ash::internal::kFullscreenUsesMinimalChromeKey, true);
+ shelf->UpdateVisibilityState();
+
gfx::Rect bounds_fullscreen = window->bounds();
EXPECT_TRUE(widget->IsFullscreen());
EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString());
+
+ // Swipe up. This should show the shelf.
+ end = below_start - delta;
+ generator.GestureScrollSequenceWithCallback(below_start, end,
+ base::TimeDelta::FromMilliseconds(10), kNumScrollSteps,
+ base::Bind(&ShelfDragCallback::ProcessScroll,
+ base::Unretained(&handler)));
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
+ EXPECT_EQ(shelf_shown.ToString(),
+ GetShelfWidget()->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString());
+
+ // Swipe up again. This should hide the shelf.
+ generator.GestureScrollSequenceWithCallback(below_start, end,
+ base::TimeDelta::FromMilliseconds(10), kNumScrollSteps,
+ base::Bind(&ShelfDragCallback::ProcessScroll,
+ base::Unretained(&handler)));
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
+ EXPECT_EQ(shelf_hidden.ToString(),
+ GetShelfWidget()->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString());
+
+ // Put the window into fullscreen without any chrome at all (eg tab
+ // fullscreen).
+ window->SetProperty(ash::internal::kFullscreenUsesMinimalChromeKey, false);
+ shelf->UpdateVisibilityState();
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
// Swipe-up. This should not change anything.
end = start - delta;
- generator.GestureScrollSequenceWithCallback(end, start,
+ generator.GestureScrollSequenceWithCallback(below_start, end,
base::TimeDelta::FromMilliseconds(10), kNumScrollSteps,
base::Bind(&ShelfDragCallback::ProcessScroll,
base::Unretained(&handler)));