Commit 5ff2e973 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

overview gesture: adjust the fling event.

For a fling event, if the hotseat was hidden when the drag started,
only if the fling event position exceeds the restore-to-maximized
threshold, the window will be taken back to home screen.

Also, remove the logic to decide if drag can be allowed from
DragWindowFromShelfController as ShelfLayoutManager already handled it.

Bug: 997885
Change-Id: I35b9c35df1477b92b5c01db49c9302b6f3bace60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902176
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713677}
parent 8ba9e7e0
......@@ -46,6 +46,12 @@ constexpr float kMinimumWindowScaleDuringDragging = 0.2f;
constexpr base::TimeDelta kShowOverviewTimeWhenDragSuspend =
base::TimeDelta::FromMilliseconds(40);
// The distance for the dragged window to pass over the bottom of the display
// so that it can be dragged into home launcher or overview. If not pass this
// value, the window will snap back to its original position.
constexpr float kReturnToMaximizedDenseThreshold = 152.f;
constexpr float kReturnToMaximizedStandardThreshold = 164.f;
} // namespace
// Hide all visible windows expect the dragged windows or the window showing in
......@@ -105,10 +111,20 @@ class DragWindowFromShelfController::WindowsHider
DISALLOW_COPY_AND_ASSIGN(WindowsHider);
};
// static
float DragWindowFromShelfController::GetReturnToMaximizedThreshold() {
return ShelfConfig::Get()->is_dense() ? kReturnToMaximizedDenseThreshold
: kReturnToMaximizedStandardThreshold;
}
DragWindowFromShelfController::DragWindowFromShelfController(
aura::Window* window)
: window_(window) {
aura::Window* window,
const gfx::Point& location_in_screen,
HotseatState hotseat_state)
: window_(window), hotseat_state_(hotseat_state) {
DCHECK_NE(hotseat_state, HotseatState::kShown);
window_->AddObserver(this);
OnDragStarted(location_in_screen);
}
DragWindowFromShelfController::~DragWindowFromShelfController() {
......@@ -124,17 +140,9 @@ void DragWindowFromShelfController::Drag(const gfx::Point& location_in_screen,
if (!window_)
return;
if (!drag_started_) {
// Do not start drag until the drag goes above the hotseat.
const gfx::Rect work_area =
screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer(
window_);
if (location_in_screen.y() >
work_area.bottom() - ShelfConfig::Get()->hotseat_size()) {
return;
}
OnDragStarted(location_in_screen);
}
// TODO(xdai): clean up |drag_started_| variable.
if (!drag_started_)
return;
UpdateDraggedWindow(location_in_screen);
......@@ -206,7 +214,7 @@ void DragWindowFromShelfController::EndDrag(
const bool in_overview = overview_controller->InOverviewSession();
const bool in_splitview = split_view_controller->InSplitViewMode();
if (ShouldGoToHomeScreen(velocity_y)) {
if (ShouldGoToHomeScreen(location_in_screen, velocity_y)) {
DCHECK(!in_splitview);
if (in_overview) {
overview_controller->EndOverview(
......@@ -397,7 +405,7 @@ SplitViewController::SnapPosition
DragWindowFromShelfController::GetSnapPosition(
const gfx::Point& location_in_screen) const {
// if |location_in_screen| is close to the bottom of the screen and is
// inside of kReturnToMaximizedThreshold threshold, we should not try to
// inside of GetReturnToMaximizedThreshold() threshold, we should not try to
// snap the window.
if (ShouldRestoreToOriginalBounds(location_in_screen))
return SplitViewController::NONE;
......@@ -423,15 +431,25 @@ DragWindowFromShelfController::GetSnapPosition(
bool DragWindowFromShelfController::ShouldRestoreToOriginalBounds(
const gfx::Point& location_in_screen) const {
const gfx::Rect work_area = display::Screen::GetScreen()
->GetDisplayNearestPoint(location_in_screen)
.work_area();
const gfx::Rect display_bounds =
display::Screen::GetScreen()
->GetDisplayNearestPoint(location_in_screen)
.bounds();
return location_in_screen.y() >
work_area.bottom() - kReturnToMaximizedThreshold;
display_bounds.bottom() - GetReturnToMaximizedThreshold();
}
bool DragWindowFromShelfController::ShouldGoToHomeScreen(
const gfx::Point& location_in_screen,
base::Optional<float> velocity_y) const {
// For a hidden hotseat, if the event end position does not exceed
// GetReturnToMaximizedThreshold(), it should restore back to the maximized
// bounds even though the velocity might be large.
if (hotseat_state_ == HotseatState::kHidden &&
ShouldRestoreToOriginalBounds(location_in_screen)) {
return false;
}
return velocity_y.has_value() && *velocity_y < 0 &&
std::abs(*velocity_y) >= kVelocityToHomeScreenThreshold &&
!SplitViewController::Get(Shell::GetPrimaryRootWindow())
......@@ -443,7 +461,7 @@ DragWindowFromShelfController::GetSnapPositionOnDragEnd(
const gfx::Point& location_in_screen,
base::Optional<float> velocity_y) const {
if (ShouldRestoreToOriginalBounds(location_in_screen) ||
ShouldGoToHomeScreen(velocity_y)) {
ShouldGoToHomeScreen(location_in_screen, velocity_y)) {
return SplitViewController::NONE;
}
......@@ -456,7 +474,7 @@ bool DragWindowFromShelfController::ShouldDropWindowInOverview(
if (!Shell::Get()->overview_controller()->InOverviewSession())
return false;
if (ShouldGoToHomeScreen(velocity_y))
if (ShouldGoToHomeScreen(location_in_screen, velocity_y))
return false;
const bool in_splitview =
......
......@@ -8,6 +8,7 @@
#include <vector>
#include "ash/ash_export.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "base/macros.h"
......@@ -26,11 +27,6 @@ namespace ash {
// swiping up from the shelf to homescreen, overview or splitview.
class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
public:
// The distance for the dragged window to pass over shelf so that it can be
// dragged into home launcher or overview. If not pass this value, the window
// will snap back to its original position.
static constexpr float kReturnToMaximizedThreshold = 116;
// The deceleration threshold to open overview behind the dragged window
// when swiping up from the shelf to drag the active window.
static constexpr float kOpenOverviewThreshold = 10.f;
......@@ -47,7 +43,15 @@ class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
// view is active during dragging.
static constexpr float kVelocityToOverviewThreshold = 1000.f;
explicit DragWindowFromShelfController(aura::Window* window);
// The distance for the dragged window to pass over the bottom of the display
// so that it can be dragged into home launcher or overview. If not pass this
// value, the window will snap back to its original position. The value is
// different for standard or dense shelf.
static float GetReturnToMaximizedThreshold();
DragWindowFromShelfController(aura::Window* window,
const gfx::Point& location_in_screen,
HotseatState hotseat_state);
~DragWindowFromShelfController() override;
// Called during swiping up on the shelf.
......@@ -81,7 +85,7 @@ class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
// Returns true if the dragged window should restore to its original bounds
// after drag ends. Happens when |location_in_screen| is within
// kReturnToMaximizedThreshold threshold.
// GetReturnToMaximizedThreshold() threshold.
bool ShouldRestoreToOriginalBounds(
const gfx::Point& location_in_screen) const;
......@@ -89,7 +93,8 @@ class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
// the upward vertical velocity is larger than kVelocityToHomeScreenThreshold
// and splitview is not active. Note when splitview is active, we do not allow
// to go to home screen by fling.
bool ShouldGoToHomeScreen(base::Optional<float> velocity_y) const;
bool ShouldGoToHomeScreen(const gfx::Point& location_in_screen,
base::Optional<float> velocity_y) const;
// Returns the desired snap position on |location_in_screen| when drag ends.
SplitViewController::SnapPosition GetSnapPositionOnDragEnd(
......@@ -125,6 +130,9 @@ class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
// Timer to show and update overview.
base::OneShotTimer show_overview_timer_;
// The hotseat state when drag starts.
const HotseatState hotseat_state_;
DISALLOW_COPY_AND_ASSIGN(DragWindowFromShelfController);
};
......
......@@ -35,9 +35,11 @@ class DragWindowFromShelfControllerTest : public AshTestBase {
base::RunLoop().RunUntilIdle();
}
void StartDrag(aura::Window* window) {
window_drag_controller_ =
std::make_unique<DragWindowFromShelfController>(window);
void StartDrag(aura::Window* window,
const gfx::Point& location_in_screen,
HotseatState hotseat_state) {
window_drag_controller_ = std::make_unique<DragWindowFromShelfController>(
window, location_in_screen, hotseat_state);
}
void Drag(const gfx::Point& location_in_screen,
float scroll_x,
......@@ -77,7 +79,7 @@ TEST_F(DragWindowFromShelfControllerTest, HideWindowDuringWindowDragging) {
EXPECT_TRUE(window2->IsVisible());
EXPECT_TRUE(window3->IsVisible());
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 1.f, 1.f);
EXPECT_TRUE(window1->IsVisible());
EXPECT_FALSE(window2->IsVisible());
......@@ -91,7 +93,7 @@ TEST_F(DragWindowFromShelfControllerTest, HideWindowDuringWindowDragging) {
split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT);
split_view_controller()->SnapWindow(window2.get(),
SplitViewController::RIGHT);
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.left_center(), HotseatState::kExtended);
Drag(gfx::Point(0, 200), 1.f, 1.f);
EXPECT_TRUE(window1->IsVisible());
EXPECT_TRUE(window2->IsVisible());
......@@ -101,7 +103,8 @@ TEST_F(DragWindowFromShelfControllerTest, HideWindowDuringWindowDragging) {
EXPECT_TRUE(window2->IsVisible());
EXPECT_TRUE(window3->IsVisible());
StartDrag(window2.get());
StartDrag(window2.get(), shelf_bounds.right_center(),
HotseatState::kExtended);
Drag(gfx::Point(400, 200), 1.f, 1.f);
EXPECT_TRUE(window1->IsVisible());
EXPECT_TRUE(window2->IsVisible());
......@@ -118,7 +121,7 @@ TEST_F(DragWindowFromShelfControllerTest, HideHomeLauncherDuringDraggingTest) {
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window = CreateTestWindow();
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(0, 200), 0.f, 1.f);
aura::Window* home_screen_window =
Shell::Get()->home_screen_controller()->delegate()->GetHomeScreenWindow();
......@@ -141,14 +144,14 @@ TEST_F(DragWindowFromShelfControllerTest, MayOrMayNotReShowHiddenWindows) {
// If the dragged window restores to its original position, reshow the hidden
// windows.
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.f, 1.f);
EXPECT_FALSE(window2->IsVisible());
EndDrag(shelf_bounds.CenterPoint(), base::nullopt);
EXPECT_TRUE(window2->IsVisible());
// If fling to homescreen, do not reshow the hidden windows.
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.f, 1.f);
EXPECT_FALSE(window2->IsVisible());
EndDrag(gfx::Point(200, 200),
......@@ -160,7 +163,7 @@ TEST_F(DragWindowFromShelfControllerTest, MayOrMayNotReShowHiddenWindows) {
// windows.
window2->Show();
window1->Show();
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.f, 1.f);
EXPECT_FALSE(window2->IsVisible());
OverviewController* overview_controller = Shell::Get()->overview_controller();
......@@ -176,7 +179,7 @@ TEST_F(DragWindowFromShelfControllerTest, MayOrMayNotReShowHiddenWindows) {
// showing in overview, do not reshow the hidden windows.
window2->Show();
window1->Show();
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.left_center(), HotseatState::kExtended);
Drag(gfx::Point(0, 200), 0.f, 1.f);
EXPECT_FALSE(window2->IsVisible());
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -191,14 +194,13 @@ TEST_F(DragWindowFromShelfControllerTest, MayOrMayNotReShowHiddenWindows) {
// show correctly in overview.
TEST_F(DragWindowFromShelfControllerTest, MinimizedWindowsShowInOverview) {
UpdateDisplay("400x400");
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window3 = CreateTestWindow();
auto window2 = CreateTestWindow();
auto window1 = CreateTestWindow();
StartDrag(window1.get());
EXPECT_TRUE(window1->IsVisible());
EXPECT_TRUE(window2->IsVisible());
EXPECT_TRUE(window3->IsVisible());
StartDrag(window1.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
// Drag it far enough so overview should be open behind the dragged window.
Drag(gfx::Point(200, 200), 0.f, 1.f);
OverviewController* overview_controller = Shell::Get()->overview_controller();
......@@ -224,9 +226,11 @@ TEST_F(DragWindowFromShelfControllerTest, MinimizedWindowsShowInOverview) {
// delta (velocity) decrease to kOpenOverviewThreshold or less.
TEST_F(DragWindowFromShelfControllerTest, OpenOverviewWhenHold) {
UpdateDisplay("400x400");
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window = CreateTestWindow();
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.f,
DragWindowFromShelfController::kOpenOverviewThreshold + 1);
OverviewController* overview_controller = Shell::Get()->overview_controller();
......@@ -241,13 +245,15 @@ TEST_F(DragWindowFromShelfControllerTest, OpenOverviewWhenHold) {
// kReturnToMaximizedThreshold, it will restore back to its original position.
TEST_F(DragWindowFromShelfControllerTest, RestoreWindowToOriginalBounds) {
UpdateDisplay("400x400");
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window = CreateTestWindow();
const gfx::Rect work_area = display::Screen::GetScreen()
->GetDisplayNearestWindow(window.get())
.work_area();
const gfx::Rect display_bounds = display::Screen::GetScreen()
->GetDisplayNearestWindow(window.get())
.bounds();
// Drag it for a small distance and then release.
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.f,
DragWindowFromShelfController::kShowOverviewThreshold + 1);
EXPECT_FALSE(window->layer()->GetTargetTransform().IsIdentity());
......@@ -258,15 +264,16 @@ TEST_F(DragWindowFromShelfControllerTest, RestoreWindowToOriginalBounds) {
EXPECT_TRUE(WindowState::Get(window.get())->IsMaximized());
// Drag it for a large distance and then drag back to release.
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.f, 1.f);
EXPECT_FALSE(window->layer()->GetTargetTransform().IsIdentity());
EXPECT_TRUE(overview_controller->InOverviewSession());
EndDrag(
gfx::Point(
200, work_area.bottom() -
DragWindowFromShelfController::kReturnToMaximizedThreshold +
1),
200,
display_bounds.bottom() -
DragWindowFromShelfController::GetReturnToMaximizedThreshold() +
1),
base::nullopt);
EXPECT_TRUE(window->layer()->GetTargetTransform().IsIdentity());
EXPECT_FALSE(overview_controller->InOverviewSession());
......@@ -277,7 +284,7 @@ TEST_F(DragWindowFromShelfControllerTest, RestoreWindowToOriginalBounds) {
split_view_controller()->SnapWindow(window.get(), SplitViewController::LEFT);
split_view_controller()->SnapWindow(window2.get(),
SplitViewController::RIGHT);
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.left_center(), HotseatState::kExtended);
Drag(gfx::Point(0, 200), 0.f, 1.f);
EXPECT_FALSE(window->layer()->GetTargetTransform().IsIdentity());
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -292,11 +299,13 @@ TEST_F(DragWindowFromShelfControllerTest, RestoreWindowToOriginalBounds) {
// TODO(https://crbug.com/1019080) This test is flaky.
TEST_F(DragWindowFromShelfControllerTest, DISABLED_FlingInOverview) {
UpdateDisplay("400x400");
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window = CreateTestWindow();
// If fling velocity is smaller than kVelocityToHomeScreenThreshold, decide
// where the window should go based on the release position.
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.f, 1.f);
OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -309,7 +318,7 @@ TEST_F(DragWindowFromShelfControllerTest, DISABLED_FlingInOverview) {
EXPECT_TRUE(WindowState::Get(window.get())->IsMaximized());
// If fling velocity is equal or larger than kVelocityToHomeScreenThreshold
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.f, 1.f);
EXPECT_TRUE(overview_controller->InOverviewSession());
EndDrag(gfx::Point(0, 350),
......@@ -323,6 +332,8 @@ TEST_F(DragWindowFromShelfControllerTest, DISABLED_FlingInOverview) {
// overview.
TEST_F(DragWindowFromShelfControllerTest, DragOrFlingInSplitView) {
UpdateDisplay("400x400");
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window1 = CreateTestWindow();
auto window2 = CreateTestWindow();
......@@ -333,7 +344,7 @@ TEST_F(DragWindowFromShelfControllerTest, DragOrFlingInSplitView) {
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
// If the window is only dragged for a small distance:
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.left_center(), HotseatState::kExtended);
Drag(gfx::Point(100, 200), 0.f, 1.f);
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -344,7 +355,7 @@ TEST_F(DragWindowFromShelfControllerTest, DragOrFlingInSplitView) {
EXPECT_TRUE(split_view_controller()->IsWindowInSplitView(window2.get()));
// If the window is dragged for a long distance:
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.left_center(), HotseatState::kExtended);
Drag(gfx::Point(100, 200), 0.f, 1.f);
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -358,7 +369,7 @@ TEST_F(DragWindowFromShelfControllerTest, DragOrFlingInSplitView) {
overview_controller->EndOverview();
// If the window is flung with a small velocity:
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.left_center(), HotseatState::kExtended);
Drag(gfx::Point(100, 200), 0.f, 1.f);
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -372,7 +383,7 @@ TEST_F(DragWindowFromShelfControllerTest, DragOrFlingInSplitView) {
EXPECT_TRUE(split_view_controller()->IsWindowInSplitView(window2.get()));
// If the window is flung with a large velocity:
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.left_center(), HotseatState::kExtended);
Drag(gfx::Point(100, 200), 0.f, 1.f);
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -396,7 +407,7 @@ TEST_F(DragWindowFromShelfControllerTest, WallpaperBlurDuringDragging) {
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window = CreateTestWindow();
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(0, 200), 0.f,
DragWindowFromShelfController::kShowOverviewThreshold + 1);
OverviewController* overview_controller = Shell::Get()->overview_controller();
......@@ -416,10 +427,12 @@ TEST_F(DragWindowFromShelfControllerTest, WallpaperBlurDuringDragging) {
// stops.
TEST_F(DragWindowFromShelfControllerTest, HideOverviewDuringDragging) {
UpdateDisplay("400x400");
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window2 = CreateTestWindow();
auto window1 = CreateTestWindow();
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.5f, 0.5f);
OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -456,7 +469,7 @@ TEST_F(DragWindowFromShelfControllerTest,
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window = CreateTestWindow();
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.5f, 0.5f);
OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -506,7 +519,7 @@ TEST_F(DragWindowFromShelfControllerTest, NoBackdropDuringWindowScaleDown) {
EXPECT_NE(window->GetProperty(kBackdropWindowMode),
BackdropWindowMode::kDisabled);
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.left_center(), HotseatState::kExtended);
Drag(gfx::Point(0, 200), 0.f, 10.f);
EndDrag(shelf_bounds.CenterPoint(),
base::make_optional(
......@@ -520,6 +533,8 @@ TEST_F(DragWindowFromShelfControllerTest, NoBackdropDuringWindowScaleDown) {
// hidden windows should restore to its previous visibility state.
// TODO(crbug.com/1022319): flaky.
TEST_F(DragWindowFromShelfControllerTest, DISABLED_CancelDragDismissOverview) {
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window3 = CreateTestWindow();
auto window2 = CreateTestWindow();
auto window1 = CreateTestWindow();
......@@ -527,7 +542,7 @@ TEST_F(DragWindowFromShelfControllerTest, DISABLED_CancelDragDismissOverview) {
EXPECT_TRUE(window2->IsVisible());
EXPECT_TRUE(window3->IsVisible());
StartDrag(window1.get());
StartDrag(window1.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.5f, 0.5f);
OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->InOverviewSession());
......@@ -545,8 +560,10 @@ TEST_F(DragWindowFromShelfControllerTest, DISABLED_CancelDragDismissOverview) {
// TODO(https://crbug.com/1018498) This test is flaky.
TEST_F(DragWindowFromShelfControllerTest,
DISABLED_CancelDragIfWindowDestroyed) {
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window = CreateTestWindow();
StartDrag(window.get());
StartDrag(window.get(), shelf_bounds.CenterPoint(), HotseatState::kExtended);
Drag(gfx::Point(200, 200), 0.5f, 0.5f);
EXPECT_EQ(window_drag_controller()->dragged_window(), window.get());
EXPECT_TRUE(window_drag_controller()->drag_started());
......@@ -558,4 +575,28 @@ TEST_F(DragWindowFromShelfControllerTest,
CancelDrag();
}
TEST_F(DragWindowFromShelfControllerTest, FlingWithHiddenHotseat) {
const gfx::Rect shelf_bounds =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())->GetIdealBounds();
auto window = CreateTestWindow();
gfx::Point start = shelf_bounds.CenterPoint();
StartDrag(window.get(), start, HotseatState::kHidden);
// Only drag for a small distance and then fling.
Drag(gfx::Point(start.x(), start.y() - 10), 0.5f, 0.5f);
EndDrag(gfx::Point(start.x(), start.y() - 10),
base::make_optional(
-DragWindowFromShelfController::kVelocityToHomeScreenThreshold));
// The window should restore back to its original position.
EXPECT_TRUE(WindowState::Get(window.get())->IsMaximized());
// Now a bigger distance to fling.
StartDrag(window.get(), start, HotseatState::kHidden);
Drag(gfx::Point(start.x(), start.y() - 200), 0.5f, 0.5f);
EndDrag(gfx::Point(start.x(), start.y() - 200),
base::make_optional(
-DragWindowFromShelfController::kVelocityToHomeScreenThreshold));
// The window should be minimized.
EXPECT_TRUE(WindowState::Get(window.get())->IsMinimized());
}
} // namespace ash
......@@ -141,6 +141,8 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
return mousewheel_scroll_offset_threshold_;
}
bool is_dense() const { return is_dense_; }
// Gets the current color for the shelf control buttons.
SkColor GetShelfControlButtonColor() const;
......
......@@ -2456,8 +2456,8 @@ bool ShelfLayoutManager::MaybeStartDragWindowFromShelf(
if (!window)
return false;
window_drag_controller_ =
std::make_unique<DragWindowFromShelfController>(window);
window_drag_controller_ = std::make_unique<DragWindowFromShelfController>(
window, event_in_screen.location(), hotseat_state());
return 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