Commit e3c2a99e authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Update grid bounds when dragged window is deleted.

Test: manual, added test
Change-Id: Id7b6cf15b0efcbfcf714f63146c99695956d4e0a
Fixed: 1020343
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898748Reviewed-by: default avatarAvery Musbach <amusbach@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712757}
parent 1f623f5f
......@@ -661,8 +661,26 @@ void OverviewGrid::RemoveItem(OverviewItem* overview_item,
return;
}
if (reposition)
PositionWindows(/*animate=*/true);
if (reposition) {
// Update the grid bounds if needed and reposition the windows minus the
// currently overview dragged window, if there is one. Note: this does not
// update the grid bounds if the window being dragged from the top or shelf,
// the former being handled in TabletModeWindowDragDelegate's destructor.
base::flat_set<OverviewItem*> ignored_items;
if (overview_session_->window_drag_controller() &&
overview_session_->window_drag_controller()->item()) {
ignored_items.insert(overview_session_->window_drag_controller()->item());
}
auto* split_view_drag_indicators =
overview_session_->split_view_drag_indicators();
const gfx::Rect grid_bounds = GetGridBoundsInScreenForSplitview(
root_window_,
split_view_drag_indicators
? base::make_optional(
split_view_drag_indicators->current_window_dragging_state())
: base::nullopt);
SetBoundsAndUpdatePositions(grid_bounds, ignored_items, /*animate=*/true);
}
}
void OverviewGrid::AddDropTargetForDraggingFromOverview(
......
......@@ -5201,6 +5201,31 @@ TEST_P(SplitViewOverviewSessionTest,
EXPECT_FALSE(overview_item->IsDragItem());
}
// Tests that a window which is dragged to a splitview zone is destroyed, the
// grid bounds return to a non-splitview bounds.
TEST_P(SplitViewOverviewSessionTest, GridBoundsAfterWindowDestroyed) {
// Create two windows otherwise we exit overview after one window is
// destroyed.
std::unique_ptr<aura::Window> window1 = CreateTestWindow();
std::unique_ptr<aura::Window> window2 = CreateTestWindow();
ToggleOverview();
const gfx::Rect grid_bounds = GetGridBounds();
// Drag the item such that the splitview preview area shows up and the grid
// bounds shrink.
OverviewItem* overview_item = GetOverviewItemForWindow(window1.get());
overview_session()->InitiateDrag(overview_item,
overview_item->target_bounds().CenterPoint(),
/*is_touch_dragging=*/true);
overview_session()->Drag(overview_item, gfx::PointF(1.f, 1.f));
EXPECT_NE(grid_bounds, GetGridBounds());
// Tests that when the dragged window is destroyed, the grid bounds return to
// their normal size.
window1.reset();
EXPECT_EQ(grid_bounds, GetGridBounds());
}
// Test the split view and overview functionalities in clamshell mode. Split
// view is only active when overview is active in clamshell mode.
class SplitViewOverviewSessionInClamshellTest
......
......@@ -105,7 +105,10 @@ TabletModeWindowDragDelegate::~TabletModeWindowDragDelegate() {
OverviewGrid* overview_grid = GetOverviewGrid(dragged_window_);
if (overview_grid) {
overview_grid->RemoveDropTarget();
overview_grid->PositionWindows(/*animate=*/true);
const gfx::Rect grid_bounds =
GetGridBoundsInScreenForSplitview(dragged_window_, base::nullopt);
overview_grid->SetBoundsAndUpdatePositions(
grid_bounds, /*ignored_items=*/{}, /*animate=*/true);
}
}
......
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