Commit 946c2536 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview gesture: No animation when drop window back to maximize.

Skips the reposition if the window is not dropped into overview on
drag end.

Test: added test, manual
Change-Id: I80635aa657e8a2017b72b06992a1f98181754bed
Fixed: 1049206
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2496192
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823345}
parent 0b9bed6e
......@@ -397,9 +397,17 @@ void DragWindowFromShelfController::OnDragEnded(
OverviewSession* overview_session = overview_controller->overview_session();
overview_session->ResetSplitViewDragIndicatorsWindowDraggingStates();
// No need to reposition overview windows if we are not dropping the dragged
// window into overview. Overview will either be exited or unchanged, and
// the extra movement from existing window will just add unnecessary
// movement which will also slow down our dragged window animation.
if (!should_drop_window_in_overview)
overview_session->SuspendReposition();
overview_session->OnWindowDragEnded(
window_, location_in_screen, should_drop_window_in_overview,
/*snap=*/snap_position != SplitViewController::NONE);
overview_session->ResumeReposition();
}
SplitViewController* split_view_controller =
......
......@@ -1150,6 +1150,45 @@ TEST_F(DragWindowFromShelfControllerTest, DropsIntoOverviewAtCorrectPosition) {
parent));
}
// Test that when the dragged window is returned to maximized state, the
// overview grid does not animate as it can be jarring and use up unneeded
// resources. Regression test for http://crbug.com/1049206.
TEST_F(DragWindowFromShelfControllerTest, NoAnimationWhenReturnToMaximize) {
std::unique_ptr<aura::Window> window1 = CreateTestWindow();
std::unique_ptr<aura::Window> window2 = CreateTestWindow();
// Drag |window1| so that overview is shown.
const gfx::Point shelf_centerpoint =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())
->GetIdealBounds()
.CenterPoint();
StartDrag(window1.get(), shelf_centerpoint);
Drag(gfx::Point(200, 200), 1.f, 1.f);
DragWindowFromShelfControllerTestApi().WaitUntilOverviewIsShown(
window_drag_controller());
// Get the bounds and transform of the item associated with |item2|.
OverviewController* overview_controller = Shell::Get()->overview_controller();
ASSERT_TRUE(overview_controller->InOverviewSession());
OverviewItem* item = GetOverviewItemForWindow(window2.get());
ASSERT_TRUE(item);
aura::Window* item_window = item->item_widget()->GetNativeWindow();
const gfx::Rect pre_exit_bounds = item_window->bounds();
const gfx::Transform pre_exit_transform = item_window->transform();
// Drag back to the shelf, |window2|'s overview item should not move.
ui::ScopedAnimationDurationScaleMode non_zero_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
EndDrag(shelf_centerpoint, base::nullopt);
EXPECT_EQ(pre_exit_bounds, item_window->bounds());
EXPECT_EQ(pre_exit_transform, item_window->layer()->GetTargetTransform());
// Tests that the end drag actually exited and remaximized |window1|.
ShellTestApi().WaitForOverviewAnimationState(
OverviewAnimationState::kExitAnimationComplete);
EXPECT_TRUE(WindowState::Get(window1.get())->IsMaximized());
}
// Tests that when dragging a snapped window is cancelled, the window
// still keep at the original snap position.
TEST_F(DragWindowFromShelfControllerTest,
......
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