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

Delay OnAppListVisibilityChanged if home launcher is transitioning

When starting animation to target drag state when sliding app window
into home screen, if target home visibility is shown,
HomeLauncherGestureHandler will hide and minimize the dragged window,
which might cause focus to move to app list, and app list visibility
to get updated before home gesture launcher animation is finished.
If the app list visibility is changed at this point, the observers
(notably shelf layout manager) will still think that the home state is
changing, and will update its state accordingly. The state would not
get updated when the animation finishes, given that another
AppListVisibilityChanged notification would be skipped after the
animation state is updated.

To avoid this, delay the AppListVisibiltiyChanged notification until
the home launcher finishes the transition.

BUG=1021253

Change-Id: I65d06cb88fd7042ca8df0a1a84d24109ccaa0e80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894750Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714722}
parent 17cdf326
...@@ -617,7 +617,6 @@ void AppListControllerImpl::OnOverviewModeStarting() { ...@@ -617,7 +617,6 @@ void AppListControllerImpl::OnOverviewModeStarting() {
if (IsTabletMode()) { if (IsTabletMode()) {
const int64_t display_id = last_visible_display_id_; const int64_t display_id = last_visible_display_id_;
OnHomeLauncherPositionChanged(false /* showing */, display_id); OnHomeLauncherPositionChanged(false /* showing */, display_id);
OnVisibilityWillChange(false /* visible */, display_id);
} else { } else {
DismissAppList(); DismissAppList();
} }
...@@ -638,7 +637,6 @@ void AppListControllerImpl::OnOverviewModeEnding(OverviewSession* session) { ...@@ -638,7 +637,6 @@ void AppListControllerImpl::OnOverviewModeEnding(OverviewSession* session) {
if (home_launcher_transition_state_ == HomeLauncherTransitionState::kFinished) if (home_launcher_transition_state_ == HomeLauncherTransitionState::kFinished)
target_visibility &= !HasVisibleWindows(); target_visibility &= !HasVisibleWindows();
OnHomeLauncherPositionChanged(target_visibility, display_id); OnHomeLauncherPositionChanged(target_visibility, display_id);
OnVisibilityWillChange(target_visibility, display_id);
} }
void AppListControllerImpl::OnOverviewModeEnded() { void AppListControllerImpl::OnOverviewModeEnded() {
...@@ -647,7 +645,6 @@ void AppListControllerImpl::OnOverviewModeEnded() { ...@@ -647,7 +645,6 @@ void AppListControllerImpl::OnOverviewModeEnded() {
const int64_t display_id = last_visible_display_id_; const int64_t display_id = last_visible_display_id_;
const bool app_list_visible = IsVisible(); const bool app_list_visible = IsVisible();
OnHomeLauncherAnimationComplete(app_list_visible, display_id); OnHomeLauncherAnimationComplete(app_list_visible, display_id);
OnVisibilityChanged(app_list_visible, display_id);
} }
void AppListControllerImpl::OnTabletModeStarted() { void AppListControllerImpl::OnTabletModeStarted() {
...@@ -1336,14 +1333,20 @@ void AppListControllerImpl::RemoveObserver( ...@@ -1336,14 +1333,20 @@ void AppListControllerImpl::RemoveObserver(
void AppListControllerImpl::OnVisibilityChanged(bool visible, void AppListControllerImpl::OnVisibilityChanged(bool visible,
int64_t display_id) { int64_t display_id) {
// Focus and app visibility changes while finishing home launcher state
// animation may cause OnVisibilityChanged() to be called before the home
// launcher state transition finished - delay the visibility change until the
// home launcher stops animating, so observers do not miss the animation state
// update.
if (home_launcher_transition_state_ != HomeLauncherTransitionState::kFinished)
return;
bool real_visibility = visible; bool real_visibility = visible;
// HomeLauncher is only visible when no other app windows are visible, // HomeLauncher is only visible when no other app windows are visible,
// unless we are in the process of animating to (or dragging) the home // unless we are in the process of animating to (or dragging) the home
// launcher. // launcher.
if (IsTabletMode() && home_launcher_transition_state_ == if (IsTabletMode())
HomeLauncherTransitionState::kFinished) {
real_visibility &= !HasVisibleWindows(); real_visibility &= !HasVisibleWindows();
}
DCHECK_EQ(last_target_visible_, real_visibility) DCHECK_EQ(last_target_visible_, real_visibility)
<< "Visibility notifications should follow target visibility " << "Visibility notifications should follow target visibility "
......
...@@ -3725,6 +3725,48 @@ TEST_P(HotseatShelfLayoutManagerTest, ExitingOvervieHidesHotseat) { ...@@ -3725,6 +3725,48 @@ TEST_P(HotseatShelfLayoutManagerTest, ExitingOvervieHidesHotseat) {
EXPECT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state()); EXPECT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
} }
// Tests that after dragging window from top of the home screen down, and back
// up again, the hotseat is shown on the home screen.
TEST_P(HotseatShelfLayoutManagerTest,
HomeToInAppAndBackHomeDragWithNoBackdrop) {
GetPrimaryShelf()->SetAutoHideBehavior(GetParam());
TabletModeControllerTestApi().EnterTabletMode();
// Create a test window, and press home button to go home.
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
PressHomeButton();
GetAppListTestHelper()->CheckVisibility(true);
EXPECT_EQ(HotseatState::kShown, GetShelfLayoutManager()->hotseat_state());
// Start downward drag from the top of the display.
ui::test::EventGenerator* generator = GetEventGenerator();
const gfx::Rect display_bounds =
display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
generator->MoveTouch(display_bounds.top_center());
generator->PressTouch();
// Move touch to the display center - verify that the active window was
// transformed.
EXPECT_TRUE(window->layer()->transform().IsIdentity());
generator->MoveTouchBy(0, 50);
EXPECT_TRUE(window->IsVisible());
EXPECT_FALSE(window->layer()->transform().IsIdentity());
// Move touch back to the top of display, and release touch.
generator->MoveTouch(display_bounds.top_center());
generator->ReleaseTouch();
// Verify that both home screen and hotseat are shown.
GetAppListTestHelper()->CheckVisibility(true);
EXPECT_EQ(HotseatState::kShown, GetShelfLayoutManager()->hotseat_state());
EXPECT_FALSE(window->IsVisible());
EXPECT_TRUE(window->layer()->transform().IsIdentity());
}
// Tests that swiping downward, towards the bezel, from a variety of points // Tests that swiping downward, towards the bezel, from a variety of points
// results in hiding the hotseat. // results in hiding the hotseat.
TEST_F(HotseatShelfLayoutManagerTest, HotseatHidesWhenSwipedToBezel) { TEST_F(HotseatShelfLayoutManagerTest, HotseatHidesWhenSwipedToBezel) {
......
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