Commit 104c81f5 authored by wutao's avatar wutao Committed by Commit Bot

cros: Reset should_animate_when_entering_ for overview animations

WindowGrid::PositionWindows is called at multiple places to animate
windows in overview mode. Reset the should_animate_when_entering_ flag
in order to animate in other situations.

Bug: 817888
Test: WindowSelectorTest.WindowItemCanAnimateOnDragRelease
Change-Id: I14a773033982c47823e6a0e331b7b8df4baa1791
Reviewed-on: https://chromium-review.googlesource.com/952671
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541689}
parent bd9af7f3
......@@ -729,6 +729,11 @@ void WindowGrid::SetWindowListAnimationStates(
}
}
void WindowGrid::ResetWindowListAnimationStates() {
for (const auto& selector_item : window_list_)
selector_item->ResetAnimationStates();
}
void WindowGrid::InitShieldWidget() {
// TODO(varkha): The code assumes that SHELF_BACKGROUND_MAXIMIZED is
// synonymous with a black shelf background. Update this code if that
......
......@@ -182,6 +182,10 @@ class ASH_EXPORT WindowGrid : public aura::WindowObserver,
WindowSelectorItem* selected_item,
WindowSelector::OverviewTransition transition);
// Reset |selector_item|'s |should_animate_when_entering_|,
// |should_animate_when_exiting_| and |should_be_observed_when_exiting_|.
void ResetWindowListAnimationStates();
private:
class ShieldView;
friend class WindowSelectorTest;
......
......@@ -308,6 +308,10 @@ void WindowSelector::Init(const WindowList& windows,
}
window_grid->PrepareForOverview();
window_grid->PositionWindows(/*animate=*/true);
// Reset |should_animate_when_entering_| in order to animate during
// overview mode, such as dragging animations.
if (IsNewOverviewAnimationsEnabled())
window_grid->ResetWindowListAnimationStates();
}
// Image used for text filter textfield.
......
......@@ -1010,6 +1010,12 @@ bool WindowSelectorItem::ShouldBeObservedWhenExiting() const {
return should_be_observed_when_exiting_;
}
void WindowSelectorItem::ResetAnimationStates() {
should_animate_when_entering_ = true;
should_animate_when_exiting_ = true;
should_be_observed_when_exiting_ = false;
}
OverviewAnimationType WindowSelectorItem::GetExitOverviewAnimationType() {
return ShouldAnimateWhenExiting()
? OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS
......
......@@ -198,6 +198,8 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
}
bool ShouldBeObservedWhenExiting() const;
void ResetAnimationStates();
OverviewAnimationType GetExitOverviewAnimationType();
OverviewAnimationType GetExitTransformAnimationType();
......
......@@ -2164,21 +2164,13 @@ TEST_F(WindowSelectorTest, SetWindowListAnimationStates) {
EXPECT_TRUE(wm::GetWindowState(window2.get())->IsFullscreen());
EXPECT_TRUE(wm::GetWindowState(window3.get())->IsFullscreen());
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// Enter overview.
ToggleOverview();
const int grid_index = 0;
WindowSelectorItem* selector_item1 =
GetWindowItemForWindow(grid_index, window1.get());
WindowSelectorItem* selector_item2 =
GetWindowItemForWindow(grid_index, window2.get());
WindowSelectorItem* selector_item3 =
GetWindowItemForWindow(grid_index, window3.get());
// All the animation states during entering overview are correctly updated.
EXPECT_TRUE(selector_item1->ShouldAnimateWhenEntering());
EXPECT_TRUE(selector_item2->ShouldAnimateWhenEntering());
EXPECT_FALSE(selector_item3->ShouldAnimateWhenEntering());
EXPECT_TRUE(window1->layer()->GetAnimator()->is_animating());
EXPECT_TRUE(window2->layer()->GetAnimator()->is_animating());
EXPECT_FALSE(window3->layer()->GetAnimator()->is_animating());
ToggleOverview();
}
......@@ -2515,6 +2507,36 @@ TEST_F(WindowSelectorTest, DISABLED_HandleAlwaysOnTopWindow) {
RunAllPendingInMessageLoop();
}
// Verify that the selector item can animate after the item is dragged and
// released.
TEST_F(WindowSelectorTest, WindowItemCanAnimateOnDragRelease) {
UpdateDisplay("400x400");
const gfx::Rect bounds(10, 10, 200, 200);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
wm::ActivateWindow(window2.get());
wm::ActivateWindow(window1.get());
// The item dragging is only allowed in tablet mode.
RunAllPendingInMessageLoop();
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
ToggleOverview();
WindowSelectorItem* item2 = GetWindowItemForWindow(0, window2.get());
// Drag |item2| in a way so that |window2| does not get activated.
GetEventGenerator().MoveMouseTo(item2->target_bounds().CenterPoint());
GetEventGenerator().PressLeftButton();
RunAllPendingInMessageLoop();
GetEventGenerator().MoveMouseTo(gfx::Point(200, 200));
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
GetEventGenerator().ReleaseLeftButton();
EXPECT_TRUE(window2->layer()->GetAnimator()->IsAnimatingProperty(
ui::LayerAnimationElement::AnimatableProperty::TRANSFORM));
RunAllPendingInMessageLoop();
}
// Verify that the window selector items titlebar and close button change
// visibility when a item is being dragged.
TEST_F(WindowSelectorTest, WindowItemTitleCloseVisibilityOnDrag) {
......
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