Commit c91a28d3 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

overview: Fix OverviewWindowDragController::GetSnapPosition

OverviewWindowDragController::GetSnapPosition uses the split view
divider position as though it is relative to the whole screen. It is
actually relative to the work area.

Test: ash_unittests SplitViewOverviewSessionInClamshellTestMultiDisplayOnly.Dragging
Bug: 1019219
Change-Id: I8530e53f70f5b5c62c5c4cbedd078abd835ceb16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1887653Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710452}
parent bcc7f1b6
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/core/cursor_manager.h"
#include "ui/wm/core/shadow_controller.h" #include "ui/wm/core/shadow_controller.h"
#include "ui/wm/core/window_util.h" #include "ui/wm/core/window_util.h"
...@@ -5435,6 +5436,56 @@ TEST_P(SplitViewOverviewSessionInClamshellTestMultiDisplayOnly, ...@@ -5435,6 +5436,56 @@ TEST_P(SplitViewOverviewSessionInClamshellTestMultiDisplayOnly,
EXPECT_FALSE(InOverviewSession()); EXPECT_FALSE(InOverviewSession());
} }
// Test dragging to snap an overview item on an external display.
TEST_P(SplitViewOverviewSessionInClamshellTestMultiDisplayOnly, Dragging) {
UpdateDisplay("800x600,800x600");
aura::Window::Windows root_windows = Shell::GetAllRootWindows();
ASSERT_EQ(2u, root_windows.size());
const gfx::Rect bounds_within_root2(800, 0, 400, 400);
std::unique_ptr<aura::Window> window1 = CreateTestWindow(bounds_within_root2);
std::unique_ptr<aura::Window> window2 = CreateTestWindow(bounds_within_root2);
ToggleOverview();
OverviewItem* item1 = GetOverviewItemForWindow(window1.get());
OverviewItem* item2 = GetOverviewItemForWindow(window2.get());
SplitViewController* split_view_controller =
SplitViewController::Get(root_windows[1]);
SplitViewDragIndicators* indicators =
overview_session()->split_view_drag_indicators();
Shell::Get()->cursor_manager()->SetDisplay(
display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
overview_session()->InitiateDrag(item1, item1->target_bounds().CenterPoint(),
/*is_touch_dragging=*/false);
const gfx::PointF right_snap_point(1599.f, 300.f);
overview_session()->Drag(item1, right_snap_point);
EXPECT_EQ(IndicatorState::kPreviewAreaRight,
indicators->current_indicator_state());
overview_session()->CompleteDrag(item1, right_snap_point);
EXPECT_EQ(SplitViewController::State::kRightSnapped,
split_view_controller->state());
EXPECT_EQ(window1.get(), split_view_controller->right_window());
overview_session()->InitiateDrag(item2, item2->target_bounds().CenterPoint(),
/*is_touch_dragging=*/false);
const gfx::PointF left_of_middle(1150.f, 300.f);
overview_session()->Drag(item2, left_of_middle);
EXPECT_EQ(IndicatorState::kDragArea, indicators->current_indicator_state());
overview_session()->CompleteDrag(item2, left_of_middle);
EXPECT_EQ(SplitViewController::State::kRightSnapped,
split_view_controller->state());
EXPECT_EQ(window1.get(), split_view_controller->right_window());
overview_session()->InitiateDrag(item2, item2->target_bounds().CenterPoint(),
/*is_touch_dragging=*/false);
const gfx::PointF left_snap_point(810.f, 300.f);
overview_session()->Drag(item2, left_snap_point);
EXPECT_EQ(IndicatorState::kPreviewAreaLeft,
indicators->current_indicator_state());
overview_session()->CompleteDrag(item2, left_snap_point);
EXPECT_EQ(SplitViewController::State::kNoSnap,
split_view_controller->state());
}
// Verify that when in overview mode, the selector items unsnappable indicator // Verify that when in overview mode, the selector items unsnappable indicator
// shows up when expected. // shows up when expected.
TEST_P(SplitViewOverviewSessionInClamshellTestMultiDisplayOnly, TEST_P(SplitViewOverviewSessionInClamshellTestMultiDisplayOnly,
......
...@@ -677,8 +677,9 @@ SplitViewController::SnapPosition OverviewWindowDragController::GetSnapPosition( ...@@ -677,8 +677,9 @@ SplitViewController::SnapPosition OverviewWindowDragController::GetSnapPosition(
SplitViewController* split_view_controller = SplitViewController* split_view_controller =
GetSplitViewControllerForDisplayBeingDraggedIn(); GetSplitViewControllerForDisplayBeingDraggedIn();
if (split_view_controller->InSplitViewMode()) { if (split_view_controller->InSplitViewMode()) {
const int position = gfx::ToRoundedInt( const int position =
is_landscape ? location_in_screen.x() : location_in_screen.y()); gfx::ToRoundedInt(is_landscape ? location_in_screen.x() - area.x()
: location_in_screen.y() - area.y());
SplitViewController::SnapPosition default_snap_position = SplitViewController::SnapPosition default_snap_position =
split_view_controller->default_snap_position(); split_view_controller->default_snap_position();
// If we're trying to snap to a position that already has a snapped window: // If we're trying to snap to a position that already has a snapped window:
......
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