Commit 0131ff8c authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

home_screen: Clean up last_event_location_ usage in gesture handler

The HomeLauncherGestureHandler does not use last_event_location_ and
last_scroll_y_ in  kDragWindowToHomeOrOverview and  kSwipeHomeToOverview
mode except for derermining:
*   whether drag is in progress
*   the final state for slide up/down in OnTabletModeEnded

For the first usage, checking the mode_ value should provide the same
information.
In the second case, finalizing slide up/down state is not the intended
behavior - requesting drag mode controllers to cancel current drag
operation would be more suitable course of action.

BUG=1005366

Change-Id: I4ec543ae24c854edd681716aa784fe2925554679
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872302
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708431}
parent 64b7ec1a
......@@ -347,7 +347,10 @@ bool HomeLauncherGestureHandler::OnPressEvent(Mode mode,
return false;
mode_ = mode;
last_event_location_ = base::make_optional(location);
if (mode_ != Mode::kDragWindowToHomeOrOverview &&
mode_ != Mode::kSwipeHomeToOverview) {
last_event_location_ = base::make_optional(location);
}
OnDragStarted(location);
return true;
......@@ -362,8 +365,11 @@ bool HomeLauncherGestureHandler::OnScrollEvent(const gfx::Point& location,
if (!IsDragInProgress())
return false;
last_event_location_ = base::make_optional(location);
last_scroll_y_ = scroll_y;
if (mode_ != Mode::kDragWindowToHomeOrOverview &&
mode_ != Mode::kSwipeHomeToOverview) {
last_event_location_ = base::make_optional(location);
last_scroll_y_ = scroll_y;
}
DCHECK(display_.is_valid());
......@@ -442,6 +448,10 @@ aura::Window* HomeLauncherGestureHandler::GetSecondaryWindow() {
return secondary_window_->window();
}
bool HomeLauncherGestureHandler::IsDragInProgress() const {
return mode_ != Mode::kNone;
}
void HomeLauncherGestureHandler::AddObserver(
HomeLauncherGestureHandlerObserver* observer) {
observers_.AddObserver(observer);
......@@ -496,13 +506,23 @@ void HomeLauncherGestureHandler::OnTabletModeEnded() {
// When leaving tablet mode advance to the end of the in progress scroll
// session or animation.
StopObservingImplicitAnimations();
if (active_window_)
active_window_->StopAnimating();
if (secondary_window_)
secondary_window_->StopAnimating();
UpdateWindowsForSlideUpOrDown(IsFinalStateShow() ? 1.0 : 0.0,
/*animate=*/false);
OnImplicitAnimationsCompleted();
if (mode_ == Mode::kDragWindowToHomeOrOverview) {
window_drag_controller_->CancelDrag();
RemoveObserversAndStopTracking();
} else if (mode_ == Mode::kSwipeHomeToOverview) {
swipe_home_to_overview_controller_->CancelDrag();
RemoveObserversAndStopTracking();
} else {
if (active_window_)
active_window_->StopAnimating();
if (secondary_window_)
secondary_window_->StopAnimating();
UpdateWindowsForSlideUpOrDown(/*progress=*/IsFinalStateShow() ? 1.0 : 0.0,
/*animate=*/false);
OnImplicitAnimationsCompleted();
}
}
void HomeLauncherGestureHandler::OnImplicitAnimationsCompleted() {
......@@ -1005,8 +1025,6 @@ void HomeLauncherGestureHandler::OnDragContinued(const gfx::Point& location,
bool HomeLauncherGestureHandler::OnDragEnded(const gfx::Point& location,
base::Optional<float> velocity_y) {
if (mode_ == Mode::kDragWindowToHomeOrOverview) {
last_event_location_ = base::make_optional(location);
window_drag_controller_->EndDrag(location, velocity_y);
RemoveObserversAndStopTracking();
} else if (mode_ == Mode::kSwipeHomeToOverview) {
......
......@@ -84,7 +84,7 @@ class ASH_EXPORT HomeLauncherGestureHandler
aura::Window* GetActiveWindow();
aura::Window* GetSecondaryWindow();
bool IsDragInProgress() const { return last_event_location_.has_value(); }
bool IsDragInProgress() const;
void AddObserver(HomeLauncherGestureHandlerObserver* observer);
void RemoveObserver(HomeLauncherGestureHandlerObserver* obsever);
......
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