Commit 129b9edb authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Fix freezing app list after duplicate swipe from bezel

Background:
Two times of continuous swipe up from bezel breaks scroll event in app
list because second scroll begin event will be consumed by shelf layout
manager, which makes subsequent scroll events go into shelf layout
manager instead of app list.

Changes:
Avoid consuming the scroll event when launcher is visible.

Bug: 896934
Change-Id: I46c9ad8f43a15160b890e5a6d4485dbb3e6bed3d
Reviewed-on: https://chromium-review.googlesource.com/c/1291788Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601237}
parent 64646172
...@@ -386,10 +386,8 @@ bool ShelfLayoutManager::ProcessGestureEvent( ...@@ -386,10 +386,8 @@ bool ShelfLayoutManager::ProcessGestureEvent(
if (IsShelfHiddenForFullscreen()) if (IsShelfHiddenForFullscreen())
return false; return false;
if (event_in_screen.type() == ui::ET_GESTURE_SCROLL_BEGIN) { if (event_in_screen.type() == ui::ET_GESTURE_SCROLL_BEGIN)
StartGestureDrag(event_in_screen); return StartGestureDrag(event_in_screen);
return true;
}
if (gesture_drag_status_ != GESTURE_DRAG_IN_PROGRESS && if (gesture_drag_status_ != GESTURE_DRAG_IN_PROGRESS &&
gesture_drag_status_ != GESTURE_DRAG_APPLIST_IN_PROGRESS) { gesture_drag_status_ != GESTURE_DRAG_APPLIST_IN_PROGRESS) {
...@@ -1191,7 +1189,7 @@ bool ShelfLayoutManager::ShouldBlurShelfBackground() { ...@@ -1191,7 +1189,7 @@ bool ShelfLayoutManager::ShouldBlurShelfBackground() {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// ShelfLayoutManager, Gesture functions: // ShelfLayoutManager, Gesture functions:
void ShelfLayoutManager::StartGestureDrag( bool ShelfLayoutManager::StartGestureDrag(
const ui::GestureEvent& gesture_in_screen) { const ui::GestureEvent& gesture_in_screen) {
if (CanStartFullscreenAppListDrag( if (CanStartFullscreenAppListDrag(
gesture_in_screen.details().scroll_y_hint())) { gesture_in_screen.details().scroll_y_hint())) {
...@@ -1207,28 +1205,30 @@ void ShelfLayoutManager::StartGestureDrag( ...@@ -1207,28 +1205,30 @@ void ShelfLayoutManager::StartGestureDrag(
shelf_bounds.y(), GetAppListBackgroundOpacityOnShelfOpacity()); shelf_bounds.y(), GetAppListBackgroundOpacityOnShelfOpacity());
launcher_above_shelf_bottom_amount_ = launcher_above_shelf_bottom_amount_ =
shelf_bounds.bottom() - gesture_in_screen.location().y(); shelf_bounds.bottom() - gesture_in_screen.location().y();
} else { return true;
HomeLauncherGestureHandler* home_launcher_handler = }
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
if (home_launcher_handler && IsVisible() &&
home_launcher_handler->OnPressEvent(
HomeLauncherGestureHandler::Mode::kSlideUpToShow,
gesture_in_screen.location())) {
gesture_drag_status_ = GESTURE_DRAG_APPLIST_IN_PROGRESS;
return;
}
// Disable the shelf dragging if the fullscreen app list is opened.
if (is_app_list_visible_ && !IsHomeLauncherEnabledInTabletMode())
return;
gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; HomeLauncherGestureHandler* home_launcher_handler =
gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
? auto_hide_state() if (home_launcher_handler && IsVisible() &&
: SHELF_AUTO_HIDE_SHOWN; home_launcher_handler->OnPressEvent(
MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE); HomeLauncherGestureHandler::Mode::kSlideUpToShow,
gesture_drag_amount_ = 0.f; gesture_in_screen.location())) {
gesture_drag_status_ = GESTURE_DRAG_APPLIST_IN_PROGRESS;
return true;
} }
// Disable the shelf dragging if the fullscreen app list is opened.
if (is_app_list_visible_ && !IsHomeLauncherEnabledInTabletMode())
return false;
gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS;
gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE
? auto_hide_state()
: SHELF_AUTO_HIDE_SHOWN;
MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE);
gesture_drag_amount_ = 0.f;
return true;
} }
void ShelfLayoutManager::UpdateGestureDrag( void ShelfLayoutManager::UpdateGestureDrag(
......
...@@ -333,7 +333,7 @@ class ASH_EXPORT ShelfLayoutManager ...@@ -333,7 +333,7 @@ class ASH_EXPORT ShelfLayoutManager
bool IsShelfAutoHideForFullscreenMaximized() const; bool IsShelfAutoHideForFullscreenMaximized() const;
// Gesture related functions: // Gesture related functions:
void StartGestureDrag(const ui::GestureEvent& gesture_in_screen); bool StartGestureDrag(const ui::GestureEvent& gesture_in_screen);
void UpdateGestureDrag(const ui::GestureEvent& gesture_in_screen); void UpdateGestureDrag(const ui::GestureEvent& gesture_in_screen);
void CompleteGestureDrag(const ui::GestureEvent& gesture_in_screen); void CompleteGestureDrag(const ui::GestureEvent& gesture_in_screen);
void CompleteAppListDrag(const ui::GestureEvent& gesture_in_screen); void CompleteAppListDrag(const ui::GestureEvent& gesture_in_screen);
......
...@@ -1587,6 +1587,50 @@ TEST_F(ShelfLayoutManagerTest, FlingUpOnShelfForFullscreenAppList) { ...@@ -1587,6 +1587,50 @@ TEST_F(ShelfLayoutManagerTest, FlingUpOnShelfForFullscreenAppList) {
GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING);
} }
// Tests that duplicate swipe up from bottom bezel should not make app list
// undraggable. (See https://crbug.com/896934)
TEST_F(ShelfLayoutManagerTest, DuplicateDragUpFromBezel) {
GetAppListTestHelper()->CheckVisibility(false);
GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED);
// Start the drag from the bottom bezel to the area that snaps to fullscreen
// state.
gfx::Rect shelf_widget_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
gfx::Point start =
gfx::Point(shelf_widget_bounds.x() + shelf_widget_bounds.width() / 2,
shelf_widget_bounds.bottom() + 1);
gfx::Point end = gfx::Point(
start.x(), shelf_widget_bounds.bottom() -
ShelfLayoutManager::kAppListDragSnapToPeekingThreshold -
10);
ui::test::EventGenerator* generator = GetEventGenerator();
constexpr base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100);
constexpr int kNumScrollSteps = 4;
generator->GestureScrollSequence(start, end, kTimeDelta, kNumScrollSteps);
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckVisibility(true);
GetAppListTestHelper()->CheckState(
app_list::AppListViewState::FULLSCREEN_ALL_APPS);
// Start the same drag event from bezel.
generator->GestureScrollSequence(start, end, kTimeDelta, kNumScrollSteps);
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckVisibility(true);
GetAppListTestHelper()->CheckState(
app_list::AppListViewState::FULLSCREEN_ALL_APPS);
// Start the drag from top screen to the area that snaps to closed state. (The
// launcher is still draggable now.)
start.set_y(
display::Screen::GetScreen()->GetPrimaryDisplay().work_area().y());
end.set_y(shelf_widget_bounds.bottom() -
ShelfLayoutManager::kAppListDragSnapToClosedThreshold + 10);
generator->GestureScrollSequence(start, end, kTimeDelta, kNumScrollSteps);
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckVisibility(false);
GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED);
}
// Change the shelf alignment during dragging should dismiss the app list. // Change the shelf alignment during dragging should dismiss the app list.
TEST_F(ShelfLayoutManagerTest, ChangeShelfAlignmentDuringAppListDragging) { TEST_F(ShelfLayoutManagerTest, ChangeShelfAlignmentDuringAppListDragging) {
Shelf* shelf = GetPrimaryShelf(); Shelf* shelf = GetPrimaryShelf();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment