Commit f341c9f7 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

app list: Reset tracked last fling velocity when drag ends

AppListView::last_fling_velocity_ is used to decide whether app list
should be dismissed when swipe occurs, but it's not reset once the
gesture ends, which means the last recorded value will influence
reseults of subsequent drags (if they do not generate
ET_GESTURE_SCROLL_UPDATE event which updates the cached velocity value;
e.g. for mouse drags)

BUG=1008702

Change-Id: I3e55b05321388c39f354bf78e6a70e78370544d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1828498
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700844}
parent 1165da6c
...@@ -1451,6 +1451,51 @@ TEST_P(AppListPresenterDelegateTest, ...@@ -1451,6 +1451,51 @@ TEST_P(AppListPresenterDelegateTest,
GetAppListTestHelper()->CheckVisibility(false); GetAppListTestHelper()->CheckVisibility(false);
} }
// Tests that drag using a mouse does not always close the app list if the app
// list was previously closed using a fling gesture.
TEST_P(AppListPresenterDelegateTest, MouseDragAfterDownwardFliing) {
const bool test_fullscreen = GetParam();
GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId());
app_list::AppListView* view = GetAppListView();
const gfx::Point expand_arrow_point = view->app_list_main_view()
->contents_view()
->expand_arrow_view()
->GetBoundsInScreen()
.CenterPoint();
if (test_fullscreen)
GetEventGenerator()->GestureTapAt(expand_arrow_point);
GetAppListTestHelper()->CheckState(test_fullscreen
? AppListViewState::kFullscreenAllApps
: AppListViewState::kPeeking);
// Fling down, the app list should close.
FlingUpOrDown(GetEventGenerator(), view, false /* down */);
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckState(AppListViewState::kClosed);
// Show the app list again, and perform mouse drag that ends up at the same
// position.
GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId());
if (test_fullscreen)
GetEventGenerator()->GestureTapAt(expand_arrow_point);
GetAppListTestHelper()->CheckState(test_fullscreen
? AppListViewState::kFullscreenAllApps
: AppListViewState::kPeeking);
GetEventGenerator()->MoveMouseTo(GetPointOutsideSearchbox());
GetEventGenerator()->PressLeftButton();
GetEventGenerator()->MoveMouseBy(0, -10);
GetEventGenerator()->MoveMouseBy(0, 10);
GetEventGenerator()->ReleaseLeftButton();
// Verify the app list state has not changed.
GetAppListTestHelper()->CheckState(test_fullscreen
? AppListViewState::kFullscreenAllApps
: AppListViewState::kPeeking);
}
TEST_F(AppListPresenterDelegateTest, TEST_F(AppListPresenterDelegateTest,
MouseWheelFromAppListPresenterImplTransitionsAppListState) { MouseWheelFromAppListPresenterImplTransitionsAppListState) {
GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId());
......
...@@ -932,16 +932,18 @@ void AppListView::EndDrag(const gfx::Point& location) { ...@@ -932,16 +932,18 @@ void AppListView::EndDrag(const gfx::Point& location) {
return; return;
} }
// Remember the last fling velocity, as the value gets reset in SetIsInDrag.
const int last_fling_velocity = last_fling_velocity_;
SetIsInDrag(false); SetIsInDrag(false);
// Change the app list state based on where the drag ended. If fling velocity // Change the app list state based on where the drag ended. If fling velocity
// was over the threshold, snap to the next state in the direction of the // was over the threshold, snap to the next state in the direction of the
// fling. // fling.
if (std::abs(last_fling_velocity_) >= kDragVelocityThreshold) { if (std::abs(last_fling_velocity) >= kDragVelocityThreshold) {
// If the user releases drag with velocity over the threshold, snap to // If the user releases drag with velocity over the threshold, snap to
// the next state, ignoring the drag release position. // the next state, ignoring the drag release position.
if (last_fling_velocity_ > 0) { if (last_fling_velocity > 0) {
switch (app_list_state_) { switch (app_list_state_) {
case ash::AppListViewState::kPeeking: case ash::AppListViewState::kPeeking:
case ash::AppListViewState::kHalf: case ash::AppListViewState::kHalf:
...@@ -1785,6 +1787,10 @@ void AppListView::SetIsInDrag(bool is_in_drag) { ...@@ -1785,6 +1787,10 @@ void AppListView::SetIsInDrag(bool is_in_drag) {
if (is_in_drag == is_in_drag_) if (is_in_drag == is_in_drag_)
return; return;
// Reset |last_fling_velocity_| if it was set during the drag.
if (!is_in_drag)
last_fling_velocity_ = 0;
// Don't allow dragging to interrupt the close animation, it probably is not // Don't allow dragging to interrupt the close animation, it probably is not
// intentional. // intentional.
if (app_list_state_ == ash::AppListViewState::kClosed) if (app_list_state_ == ash::AppListViewState::kClosed)
......
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