Commit 104b5d40 authored by Min Chen's avatar Min Chen Committed by Commit Bot

Tab dragging: None snap position if dragged window can't be snapped.

Should consider whether the dragged window can be snapped when trying
to get the snap position on the drag position. Then in multi-tabs drag,
drag one tab out of the source window will not put the source window to
the snapped window's position during drag. Note, browser window may
can't be snapped on different display bounds or scales.

Bug: 905924
Change-Id: I9166092af4252ca44b221da082be1fdb0297f034
Reviewed-on: https://chromium-review.googlesource.com/c/1345425Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610987}
parent 20109128
...@@ -2124,10 +2124,9 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) { ...@@ -2124,10 +2124,9 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
// When the drag starts, the source window's bounds are the same with the // When the drag starts, the source window's bounds are the same with the
// work area's bounds. // work area's bounds.
const gfx::Rect work_area_bounds = const display::Display display =
display::Screen::GetScreen() display::Screen::GetScreen()->GetDisplayNearestWindow(window1.get());
->GetDisplayNearestWindow(window1.get()) const gfx::Rect work_area_bounds = display.work_area();
.work_area();
EXPECT_EQ(window2->GetBoundsInScreen(), work_area_bounds); EXPECT_EQ(window2->GetBoundsInScreen(), work_area_bounds);
EXPECT_TRUE(window1->GetProperty(kCanAttachToAnotherWindowKey)); EXPECT_TRUE(window1->GetProperty(kCanAttachToAnotherWindowKey));
...@@ -2199,6 +2198,30 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) { ...@@ -2199,6 +2198,30 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
EXPECT_FALSE(split_view_controller()->IsSplitViewModeActive()); EXPECT_FALSE(split_view_controller()->IsSplitViewModeActive());
EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
EXPECT_TRUE(wm::GetWindowState(window2.get())->IsMaximized()); EXPECT_TRUE(wm::GetWindowState(window2.get())->IsMaximized());
// 4. If the dragged window can't be snapped, then the source window should
// not be put to the snapped position during drag.
const gfx::Rect display_bounds = display.bounds();
window1 = std::unique_ptr<aura::Window>(
CreateWindowWithType(bounds, AppType::BROWSER));
aura::test::TestWindowDelegate* delegate =
static_cast<aura::test::TestWindowDelegate*>(window1->delegate());
delegate->set_minimum_size(
gfx::Size(display_bounds.width() * 0.67f, display_bounds.height()));
EXPECT_FALSE(split_view_controller()->CanSnap(window1.get()));
resizer = StartDrag(window1.get(), window2.get());
EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
DragWindowTo(resizer.get(),
gfx::Point(0, GetIndicatorsThreshold(window1.get()) + 10));
EXPECT_EQ(GetIndicatorState(resizer.get()), IndicatorState::kCannotSnap);
// The souce window should has been scaled but not put to the right snapped
// window's position.
EXPECT_NE(window2->GetBoundsInScreen(), work_area_bounds);
EXPECT_NE(window2->GetBoundsInScreen(),
split_view_controller()->GetSnappedWindowBoundsInScreen(
window2.get(), SplitViewController::RIGHT));
CompleteDrag(std::move(resizer));
EXPECT_FALSE(split_view_controller()->IsSplitViewModeActive());
} }
// Test the functionalities that are related to dragging a snapped window in // Test the functionalities that are related to dragging a snapped window in
......
...@@ -271,6 +271,9 @@ int TabletModeWindowDragDelegate::GetIndicatorsVerticalThreshold( ...@@ -271,6 +271,9 @@ int TabletModeWindowDragDelegate::GetIndicatorsVerticalThreshold(
SplitViewController::SnapPosition TabletModeWindowDragDelegate::GetSnapPosition( SplitViewController::SnapPosition TabletModeWindowDragDelegate::GetSnapPosition(
const gfx::Point& location_in_screen) const { const gfx::Point& location_in_screen) const {
if (!split_view_controller_->CanSnap(dragged_window_))
return SplitViewController::NONE;
// If split view mode is active during dragging, the dragged window will be // If split view mode is active during dragging, the dragged window will be
// either snapped left or right (if it's not merged into overview window), // either snapped left or right (if it's not merged into overview window),
// depending on the relative position of |location_in_screen| and the current // depending on the relative position of |location_in_screen| and the current
......
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