Commit 81d573f7 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Add drag status type for gesture from home to overview

Currently, drag and hold gesture for transition from home to overview is
handled by SwipeHomeToOverviewController owned by
HomeLauncherGestureHandler, which means that shelf layout manager's
drag_status_ indicates app list drag while the home-to-overview drag is
in progress.
This causes hotseat not to change its state while the
drag is handled, the behavior which is suboptimal given that home screen
can transition to overview while the gesture pointers are still down
(the shelf should update to reflect the state change immediately).

This cl introduces new drag status type, that enables the shelf layout
manager to treat shelf updates differently while home to overview
gesture is active than when app list drag is active.

BUG=1005366

Change-Id: I555b344a57df0830b5380d48ce98237673aad2d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894136
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711514}
parent 81b32206
...@@ -598,7 +598,8 @@ bool ShelfLayoutManager::ProcessGestureEvent( ...@@ -598,7 +598,8 @@ bool ShelfLayoutManager::ProcessGestureEvent(
return StartGestureDrag(event_in_screen); return StartGestureDrag(event_in_screen);
if (drag_status_ != kDragInProgress && if (drag_status_ != kDragInProgress &&
drag_status_ != kDragAppListInProgress) { drag_status_ != kDragAppListInProgress &&
drag_status_ != kDragHomeToOverviewInProgress) {
return false; return false;
} }
...@@ -613,10 +614,12 @@ bool ShelfLayoutManager::ProcessGestureEvent( ...@@ -613,10 +614,12 @@ bool ShelfLayoutManager::ProcessGestureEvent(
last_drag_velocity_ = last_drag_velocity_ =
event_in_screen.AsGestureEvent()->details().velocity_y(); event_in_screen.AsGestureEvent()->details().velocity_y();
} }
if (drag_status_ == kDragAppListInProgress) if (drag_status_ == kDragAppListInProgress ||
drag_status_ == kDragHomeToOverviewInProgress) {
CompleteAppListDrag(event_in_screen); CompleteAppListDrag(event_in_screen);
else } else {
CompleteDrag(event_in_screen); CompleteDrag(event_in_screen);
}
return true; return true;
} }
...@@ -747,8 +750,11 @@ bool ShelfLayoutManager::HasVisibleWindow() const { ...@@ -747,8 +750,11 @@ bool ShelfLayoutManager::HasVisibleWindow() const {
} }
void ShelfLayoutManager::CancelDragOnShelfIfInProgress() { void ShelfLayoutManager::CancelDragOnShelfIfInProgress() {
if (drag_status_ == kDragInProgress || drag_status_ == kDragAppListInProgress) if (drag_status_ == kDragInProgress ||
drag_status_ == kDragAppListInProgress ||
drag_status_ == kDragHomeToOverviewInProgress) {
CancelDrag(); CancelDrag();
}
} }
void ShelfLayoutManager::SuspendVisibilityUpdate() { void ShelfLayoutManager::SuspendVisibilityUpdate() {
...@@ -1064,7 +1070,8 @@ HotseatState ShelfLayoutManager::CalculateHotseatState( ...@@ -1064,7 +1070,8 @@ HotseatState ShelfLayoutManager::CalculateHotseatState(
split_view_controller && split_view_controller->InSplitViewMode(); split_view_controller && split_view_controller->InSplitViewMode();
} }
switch (drag_status_) { switch (drag_status_) {
case kDragNone: { case kDragNone:
case kDragHomeToOverviewInProgress: {
switch (app_list_controller->home_launcher_animation_state()) { switch (app_list_controller->home_launcher_animation_state()) {
case AppListControllerImpl::HomeLauncherAnimationState::kShowing: case AppListControllerImpl::HomeLauncherAnimationState::kShowing:
return HotseatState::kShown; return HotseatState::kShown;
...@@ -1757,8 +1764,10 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( ...@@ -1757,8 +1764,10 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
return SHELF_AUTO_HIDE_SHOWN; return SHELF_AUTO_HIDE_SHOWN;
} }
if (drag_status_ == kDragAppListInProgress) if (drag_status_ == kDragAppListInProgress ||
drag_status_ == kDragHomeToOverviewInProgress) {
return SHELF_AUTO_HIDE_SHOWN; return SHELF_AUTO_HIDE_SHOWN;
}
if (drag_status_ == kDragCompleteInProgress || if (drag_status_ == kDragCompleteInProgress ||
drag_status_ == kDragCancelInProgress) { drag_status_ == kDragCancelInProgress) {
...@@ -1927,8 +1936,10 @@ bool ShelfLayoutManager::ShouldHomeGestureHandleEvent(float scroll_y) const { ...@@ -1927,8 +1936,10 @@ bool ShelfLayoutManager::ShouldHomeGestureHandleEvent(float scroll_y) const {
// Scroll down events should never be handled, unless they are currently being // Scroll down events should never be handled, unless they are currently being
// handled // handled
if (scroll_y >= 0 && drag_status_ != kDragAppListInProgress) if (scroll_y >= 0 && drag_status_ != kDragAppListInProgress &&
drag_status_ != kDragHomeToOverviewInProgress) {
return false; return false;
}
return true; return true;
} }
...@@ -1946,12 +1957,16 @@ bool ShelfLayoutManager::StartGestureDrag( ...@@ -1946,12 +1957,16 @@ bool ShelfLayoutManager::StartGestureDrag(
if (ShouldHomeGestureHandleEvent(scroll_y_hint)) { if (ShouldHomeGestureHandleEvent(scroll_y_hint)) {
DragStatus previous_drag_status = drag_status_; DragStatus previous_drag_status = drag_status_;
drag_status_ = kDragAppListInProgress;
HomeLauncherGestureHandler* home_launcher_handler = HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->home_screen_controller()->home_launcher_gesture_handler(); Shell::Get()->home_screen_controller()->home_launcher_gesture_handler();
if (home_launcher_handler->OnPressEvent( const HomeLauncherGestureHandler::Mode target_mode =
GetHomeLauncherGestureHandlerModeForDrag(), GetHomeLauncherGestureHandlerModeForDrag();
gesture_in_screen.location())) { drag_status_ =
target_mode == HomeLauncherGestureHandler::Mode::kSwipeHomeToOverview
? kDragHomeToOverviewInProgress
: kDragAppListInProgress;
if (home_launcher_handler->OnPressEvent(target_mode,
gesture_in_screen.location())) {
return true; return true;
} }
drag_status_ = previous_drag_status; drag_status_ = previous_drag_status;
...@@ -2003,7 +2018,8 @@ void ShelfLayoutManager::UpdateMouseDrag( ...@@ -2003,7 +2018,8 @@ void ShelfLayoutManager::UpdateMouseDrag(
return; return;
DCHECK(drag_status_ == kDragAttempt || drag_status_ == kDragInProgress || DCHECK(drag_status_ == kDragAttempt || drag_status_ == kDragInProgress ||
drag_status_ == kDragAppListInProgress); drag_status_ == kDragAppListInProgress ||
drag_status_ == kDragHomeToOverviewInProgress);
if (drag_status_ == kDragAttempt) { if (drag_status_ == kDragAttempt) {
// Do not start drag for the small offset. // Do not start drag for the small offset.
...@@ -2032,6 +2048,7 @@ void ShelfLayoutManager::ReleaseMouseDrag( ...@@ -2032,6 +2048,7 @@ void ShelfLayoutManager::ReleaseMouseDrag(
DCHECK(drag_status_ == kDragAttempt || DCHECK(drag_status_ == kDragAttempt ||
drag_status_ == kDragAppListInProgress || drag_status_ == kDragAppListInProgress ||
drag_status_ == kDragHomeToOverviewInProgress ||
drag_status_ == kDragInProgress); drag_status_ == kDragInProgress);
switch (drag_status_) { switch (drag_status_) {
...@@ -2039,6 +2056,7 @@ void ShelfLayoutManager::ReleaseMouseDrag( ...@@ -2039,6 +2056,7 @@ void ShelfLayoutManager::ReleaseMouseDrag(
drag_status_ = kDragNone; drag_status_ = kDragNone;
break; break;
case kDragAppListInProgress: case kDragAppListInProgress:
case kDragHomeToOverviewInProgress:
CompleteAppListDrag(mouse_in_screen); CompleteAppListDrag(mouse_in_screen);
break; break;
case kDragInProgress: case kDragInProgress:
...@@ -2248,7 +2266,8 @@ void ShelfLayoutManager::CompleteAppListDrag( ...@@ -2248,7 +2266,8 @@ void ShelfLayoutManager::CompleteAppListDrag(
} }
void ShelfLayoutManager::CancelDrag() { void ShelfLayoutManager::CancelDrag() {
if (drag_status_ == kDragAppListInProgress) { if (drag_status_ == kDragAppListInProgress ||
drag_status_ == kDragHomeToOverviewInProgress) {
HomeLauncherGestureHandler* home_launcher_handler = HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->home_screen_controller()->home_launcher_gesture_handler(); Shell::Get()->home_screen_controller()->home_launcher_gesture_handler();
DCHECK(home_launcher_handler); DCHECK(home_launcher_handler);
......
...@@ -548,6 +548,7 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -548,6 +548,7 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
kDragCancelInProgress, kDragCancelInProgress,
kDragCompleteInProgress, kDragCompleteInProgress,
kDragAppListInProgress, kDragAppListInProgress,
kDragHomeToOverviewInProgress,
}; };
DragStatus drag_status_ = kDragNone; DragStatus drag_status_ = kDragNone;
......
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