Skip to content

Commit

Permalink
Cros splitscreen: in overview mode, if there is already a snapped win…
Browse files Browse the repository at this point in the history
…dow, do not allow another window snap to the same position.

Bug: 725683
Change-Id: Ica123477155a7a8d6f3f741c8cc645dfcc0eb812
Reviewed-on: https://chromium-review.googlesource.com/797413
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#527360}
  • Loading branch information
xdai authored and Commit Bot committed Jan 5, 2018
1 parent fb1967b commit bd9b8da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 13 additions & 1 deletion ash/wm/overview/overview_window_drag_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,21 @@ void OverviewWindowDragController::UpdatePhantomWindowAndWindowGrid(
SplitViewController::SnapPosition last_snap_position = snap_position_;
snap_position_ = GetSnapPosition(location_in_screen);

// If there is already a snapped window in |snap_position_|, do not allow
// another window snap in the same position.
SplitViewController::State snapped_state = split_view_controller_->state();
if ((snap_position_ == SplitViewController::LEFT &&
snapped_state == SplitViewController::LEFT_SNAPPED) ||
(snap_position_ == SplitViewController::RIGHT &&
snapped_state == SplitViewController::RIGHT_SNAPPED)) {
snap_position_ = SplitViewController::NONE;
phantom_window_controller_.reset();
return;
}

// If there is no current snapped window, update the window grid size if the
// dragged window can be snapped if dropped.
if (split_view_controller_->state() == SplitViewController::NO_SNAP &&
if (snapped_state == SplitViewController::NO_SNAP &&
snap_position_ != last_snap_position) {
// Do not reposition the item that is currently being dragged.
window_selector_->SetBoundsForWindowGridsInScreenIgnoringWindow(
Expand Down
5 changes: 3 additions & 2 deletions ash/wm/overview/window_selector_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2085,14 +2085,15 @@ TEST_F(SplitViewWindowSelectorTest, DragOverviewWindowToSnap) {
SplitViewController::LEFT_SNAPPED);
EXPECT_EQ(split_view_controller()->left_window(), window1.get());

// Drag |window2| selector item to snap to left.
// Drag |window2| selector item to attempt to snap to left. Since there is
// already one left snapped window, we do not allow |window2| snap to left.
WindowSelectorItem* selector_item2 =
GetWindowItemForWindow(grid_index, window2.get());
DragWindowTo(selector_item2, gfx::Point(0, 0));

EXPECT_EQ(split_view_controller()->state(),
SplitViewController::LEFT_SNAPPED);
EXPECT_EQ(split_view_controller()->left_window(), window2.get());
EXPECT_EQ(split_view_controller()->left_window(), window1.get());

// Drag |window3| selector item to snap to right.
WindowSelectorItem* selector_item3 =
Expand Down

0 comments on commit bd9b8da

Please sign in to comment.