Commit abdebf2d authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

overview gesture: Make it work with overview and splitview.

When swiping up from the shelf to drag the active window:
- The active window can be dragged to snap in splitview or be dropped
  in overview. Fling the active window can head to home launcher
  screen if the velocity is large enough.
- If overview is active and splitview is inactive, it's a no-op.
- If overview is active and splitview is active, swiping on the
  snapped window side will drag the snapped window around in overview,
  and swiping on the overview side is a no-op.
- If overview is inactive and splitview is active, swiping an snapped
  window will open overview behind the dragged window. Fling the
  snapped window can only drop the snapped window to overview, but
  can't head to home launcher screen.

Bug: 997885
Change-Id: I55d0e37dd2298c3b4906b53b3ee20038f9e886bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1830173
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703949}
parent 9293f8a0
...@@ -1084,7 +1084,9 @@ bool AppListControllerImpl::ProcessHomeLauncherGesture( ...@@ -1084,7 +1084,9 @@ bool AppListControllerImpl::ProcessHomeLauncherGesture(
return home_launcher_gesture_handler->OnScrollEvent( return home_launcher_gesture_handler->OnScrollEvent(
screen_location, event->details().scroll_y()); screen_location, event->details().scroll_y());
case ui::ET_GESTURE_END: case ui::ET_GESTURE_END:
return home_launcher_gesture_handler->OnReleaseEvent(screen_location); return home_launcher_gesture_handler->OnReleaseEvent(
screen_location,
/*velocity_y=*/base::nullopt);
default: default:
break; break;
} }
......
...@@ -36,6 +36,23 @@ class ASH_EXPORT HomeLauncherGestureHandler ...@@ -36,6 +36,23 @@ class ASH_EXPORT HomeLauncherGestureHandler
public TabletModeObserver, public TabletModeObserver,
public ui::ImplicitAnimationObserver { public ui::ImplicitAnimationObserver {
public: public:
// The distance for the dragged window to pass over shelf so that it can be
// dragged into home launcher or overview. If not pass this value, the window
// will snap back to its original position.
static constexpr float kReturnToMaximizedThreshold = 116;
// The deceleration threshold to show overview during window dragging when
// dragging a window up from the shelf.
static constexpr float kShowOverviewThreshold = 4.f;
// The upward velocity threshold to take the user to the home launcher screen
// when swiping up from the shelf. Can happen anytime during dragging.
static constexpr float kVelocityToHomeScreenThreshold = 1000.f;
// The upward velocity threshold to fling the window into overview when split
// view is active during dragging.
static constexpr float kVelocityToOverviewThreshold = 1000.f;
// Enum which tracks which mode the current scroll process is in. // Enum which tracks which mode the current scroll process is in.
enum class Mode { enum class Mode {
// There is no current scroll process. // There is no current scroll process.
...@@ -60,7 +77,8 @@ class ASH_EXPORT HomeLauncherGestureHandler ...@@ -60,7 +77,8 @@ class ASH_EXPORT HomeLauncherGestureHandler
// was not processed. // was not processed.
bool OnPressEvent(Mode mode, const gfx::Point& location); bool OnPressEvent(Mode mode, const gfx::Point& location);
bool OnScrollEvent(const gfx::Point& location, float scroll_y); bool OnScrollEvent(const gfx::Point& location, float scroll_y);
bool OnReleaseEvent(const gfx::Point& location); bool OnReleaseEvent(const gfx::Point& location,
base::Optional<float> velocity_y);
// Cancel a current drag and animates the items to their final state based on // Cancel a current drag and animates the items to their final state based on
// |last_event_location_|. // |last_event_location_|.
...@@ -157,8 +175,10 @@ class ASH_EXPORT HomeLauncherGestureHandler ...@@ -157,8 +175,10 @@ class ASH_EXPORT HomeLauncherGestureHandler
// Called by OnPress/Scroll/ReleaseEvent() when the drag from the shelf or // Called by OnPress/Scroll/ReleaseEvent() when the drag from the shelf or
// from the top starts/continues/ends. |location| is in screen coordinate. // from the top starts/continues/ends. |location| is in screen coordinate.
void OnDragStarted(const gfx::Point& location); void OnDragStarted(const gfx::Point& location);
void OnDragContinued(const gfx::Point& location); void OnDragContinued(const gfx::Point& location, float scroll_y);
bool OnDragEnded(const gfx::Point& location); bool OnDragEnded(const gfx::Point& location,
base::Optional<float> velocity_y);
void OnDragCancelled();
Mode mode_ = Mode::kNone; Mode mode_ = Mode::kNone;
......
...@@ -2106,7 +2106,13 @@ void ShelfLayoutManager::CompleteAppListDrag( ...@@ -2106,7 +2106,13 @@ void ShelfLayoutManager::CompleteAppListDrag(
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);
if (home_launcher_handler->OnReleaseEvent(event_in_screen.location())) { base::Optional<float> velocity_y;
if (event_in_screen.type() == ui::ET_SCROLL_FLING_START) {
velocity_y = base::make_optional(
event_in_screen.AsGestureEvent()->details().velocity_y());
}
if (home_launcher_handler->OnReleaseEvent(event_in_screen.location(),
velocity_y)) {
drag_status_ = kDragNone; drag_status_ = kDragNone;
return; return;
} }
......
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