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

Skip bounds change if app list view state changes during drag

Running animation while still in drag would cause the app list view
change to kHalf/kPeeking or fullscreen state, in addition to changing
the page shown in the app list view. Further more, moving mouse
(provided that the drag was not ended in the meantime) would cause the
view to jump back to the drag position.

To avoid this, do not change the app list view bounds to the preferred
bounds for the new state is drag is still in progress (the bounds will
be updated once the drag ends). For this to be possible, when ending
drag, the new drag state should be set before the new state. For code
that requires the new state to be known during the state change,
introduce ending_drag_ flag, that's set while state change caused by
drag ending is in progress.
(Currently, this is only used to determine whether animation to peeking
state should layout app list at each frame)

BUG=1004390

Change-Id: I080b47843576dec8b6fa8cecae4370c7959d9c38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1807064Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697112}
parent 551ac7e2
......@@ -526,7 +526,7 @@ class PeekingResetAnimation : public ui::LayerAnimationElement {
gfx::PointF(0, y_offset),
gfx::PointF())),
view_(view) {
DCHECK(view_->is_in_drag());
DCHECK(view_->ending_drag());
DCHECK_EQ(view_->app_list_state(), ash::AppListViewState::kPeeking);
DCHECK(!view_->is_tablet_mode());
}
......@@ -952,6 +952,9 @@ void AppListView::UpdateDrag(const gfx::Point& location) {
}
void AppListView::EndDrag(const gfx::Point& location) {
base::AutoReset<bool> auto_reset(&ending_drag_, true);
SetIsInDrag(false);
// 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
// fling.
......@@ -1065,7 +1068,6 @@ void AppListView::EndDrag(const gfx::Point& location) {
}
}
}
SetIsInDrag(false);
UpdateChildViewsYPositionAndOpacity();
initial_drag_point_ = gfx::Point();
}
......@@ -1450,6 +1452,8 @@ void AppListView::OnTabletModeChanged(bool started) {
->horizontal_page_container()
->OnTabletModeChanged(started);
base::AutoReset<bool> auto_reset(&ending_drag_, is_in_drag_);
if (is_in_drag_) {
SetIsInDrag(false);
UpdateChildViewsYPositionAndOpacity();
......@@ -1596,7 +1600,7 @@ void AppListView::ApplyBoundsAnimation(ash::AppListViewState target_state,
ui::ImplicitAnimationObserver* animation_observer =
delegate_->GetAnimationObserver(target_state);
if (is_side_shelf_) {
if (is_side_shelf_ || is_in_drag_) {
// There is no animation in side shelf.
OnBoundsAnimationCompleted();
UpdateAppListBackgroundYPosition(target_state);
......@@ -2262,7 +2266,7 @@ bool AppListView::ShouldUpdateChildViewsDuringAnimation(
if (is_tablet_mode_)
return false;
if (target_state != ash::AppListViewState::kPeeking || !is_in_drag_ ||
if (target_state != ash::AppListViewState::kPeeking || !ending_drag_ ||
app_list_state_ != target_state) {
return false;
}
......@@ -2282,13 +2286,15 @@ void AppListView::OnTabletModeAnimationTransitionNotified(
}
void AppListView::EndDragFromShelf(ash::AppListViewState app_list_state) {
base::AutoReset<bool> auto_reset(&ending_drag_, true);
SetIsInDrag(false);
if (app_list_state == ash::AppListViewState::kClosed ||
app_list_state_ == ash::AppListViewState::kClosed) {
Dismiss();
} else {
SetState(app_list_state);
}
SetIsInDrag(false);
UpdateChildViewsYPositionAndOpacity();
}
......
......@@ -320,6 +320,8 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
bool is_in_drag() const { return is_in_drag_; }
bool ending_drag() const { return ending_drag_; }
void set_onscreen_keyboard_shown(bool onscreen_keyboard_shown) {
onscreen_keyboard_shown_ = onscreen_keyboard_shown;
}
......@@ -474,6 +476,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// or dragging the app list from shelf.
bool is_in_drag_ = false;
// Whether the app list view is going through state change due to drag ending.
bool ending_drag_ = false;
// Whether the view is being built.
bool is_building_ = false;
......
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