Commit 72ed5aea authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Fast upward swipe should show hotseat

When deciding final hotseat position, give the last drag velocity
precedence over last hotseat position, so short upward flings (which are
not long enough to move hotseat up by half of its length) still move the
hotseat to the extended state.

This was previously flipped in CL:1870051 because last_drag_velocity_
had upward value while dragging down to the bezel - the likely cause of
this issue is last_drag_velocity_ not being reset when completing drag
handling, so in cases where drag handling does not encounter
ET_SCROLL_FLING_START (which might happen if drag exits the screen
bounds), last_drag_velocity_ from the previous drag would be used.
The described issue is fixed as part of this cl.

BUG=1035024

Change-Id: I246121d84820fd3c633753b1d4d01dad0e323ac3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1983268Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728215}
parent 6f8d9c12
......@@ -1340,23 +1340,24 @@ HotseatState ShelfLayoutManager::CalculateHotseatState(
const bool dragged_to_bezel =
std::ceil(end_of_drag_in_screen) >= screen_bottom;
if (dragged_to_bezel)
return HotseatState::kHidden;
if (std::abs(last_drag_velocity_) >= 120) {
if (last_drag_velocity_ > 0)
return HotseatState::kHidden;
return HotseatState::kExtended;
}
const int top_of_hotseat_to_screen_bottom =
screen_bottom -
shelf_widget_->hotseat_widget()->GetWindowBoundsInScreen().y();
const bool dragged_over_half_hotseat_size =
top_of_hotseat_to_screen_bottom <
ShelfConfig::Get()->hotseat_size() / 2;
// Drags to the bezel may have large velocities, even if the drag is slow.
// Decide the state based on position first, before checking
// |last_drag_velocity_|.
if (dragged_to_bezel || dragged_over_half_hotseat_size)
if (dragged_over_half_hotseat_size)
return HotseatState::kHidden;
if (std::abs(last_drag_velocity_) >= 120) {
if (last_drag_velocity_ > 0)
return HotseatState::kHidden;
return HotseatState::kExtended;
}
return HotseatState::kExtended;
}
case kDragAppListInProgress:
......@@ -2478,6 +2479,7 @@ void ShelfLayoutManager::CancelDrag() {
hotseat_is_in_drag_ = false;
drag_status_ = kDragNone;
drag_start_point_in_screen_ = gfx::Point();
last_drag_velocity_ = 0;
}
void ShelfLayoutManager::CompleteDragWithChangedVisibility() {
......@@ -2499,6 +2501,7 @@ void ShelfLayoutManager::CompleteDragWithChangedVisibility() {
if (hotseat_is_in_drag_)
hotseat_presentation_time_recorder_.reset();
hotseat_is_in_drag_ = false;
last_drag_velocity_ = 0;
}
float ShelfLayoutManager::GetAppListBackgroundOpacityOnShelfOpacity() {
......
......@@ -4210,8 +4210,44 @@ TEST_F(HotseatShelfLayoutManagerTest, HotseatHidesWhenSwipedToBezel) {
EXPECT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
}
// Tests that flinging up the in-app shelf should show the home launcher.
TEST_F(HotseatShelfLayoutManagerTest, FlingUpHotseat) {
// Tests that flinging up the in-app shelf should show the hotseat.
TEST_F(HotseatShelfLayoutManagerTest, FlingUpHotseatWithShortFling) {
TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
GetAppListTestHelper()->CheckVisibility(false);
base::HistogramTester histogram_tester;
histogram_tester.ExpectBucketCount(kHotseatGestureHistogramName,
InAppShelfGestures::kSwipeUpToShow, 0);
// Scrolls the hotseat by a distance not sufficuent to trigger the action of
// entering home screen from the in-app shelf.
gfx::Rect display_bounds =
display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
const gfx::Point start(display_bounds.bottom_center());
const gfx::Point end(start + gfx::Vector2d(0, -20));
const int fling_speed =
DragWindowFromShelfController::kVelocityToHomeScreenThreshold + 1;
const int scroll_steps = 20;
base::TimeDelta scroll_time =
GetEventGenerator()->CalculateScrollDurationForFlingVelocity(
start, end, fling_speed, scroll_steps);
GetEventGenerator()->GestureScrollSequence(start, end, scroll_time,
scroll_steps);
base::RunLoop().RunUntilIdle();
EXPECT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
GetAppListTestHelper()->CheckVisibility(false);
histogram_tester.ExpectBucketCount(kHotseatGestureHistogramName,
InAppShelfGestures::kSwipeUpToShow, 1);
}
// Tests that flinging up the in-app shelf should show the home launcher if the
// gesture distance is long enough.
TEST_F(HotseatShelfLayoutManagerTest, FlingUpHotseatWithLongFling) {
TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
......
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