Commit 50f93245 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

overview gesture: do not start drag if swiping down on hotseat or shelf.

Bug: 997885
Change-Id: I1683b06cc4fd46cdfa46c681cf725157c0fb07f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1912884
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714757}
parent 8296d47e
...@@ -2194,7 +2194,7 @@ bool ShelfLayoutManager::StartShelfDrag( ...@@ -2194,7 +2194,7 @@ bool ShelfLayoutManager::StartShelfDrag(
drag_amount_ = 0.f; drag_amount_ = 0.f;
} }
MaybeStartDragWindowFromShelf(event_in_screen); MaybeStartDragWindowFromShelf(event_in_screen, /*scroll_y=*/base::nullopt);
return true; return true;
} }
...@@ -2433,7 +2433,8 @@ void ShelfLayoutManager::SendA11yAlertForFullscreenWorkspaceState( ...@@ -2433,7 +2433,8 @@ void ShelfLayoutManager::SendA11yAlertForFullscreenWorkspaceState(
} }
bool ShelfLayoutManager::MaybeStartDragWindowFromShelf( bool ShelfLayoutManager::MaybeStartDragWindowFromShelf(
const ui::LocatedEvent& event_in_screen) { const ui::LocatedEvent& event_in_screen,
base::Optional<float> scroll_y) {
if (!features::IsDragFromShelfToHomeOrOverviewEnabled()) if (!features::IsDragFromShelfToHomeOrOverviewEnabled())
return false; return false;
if (!IsTabletModeEnabled()) if (!IsTabletModeEnabled())
...@@ -2467,6 +2468,9 @@ bool ShelfLayoutManager::MaybeStartDragWindowFromShelf( ...@@ -2467,6 +2468,9 @@ bool ShelfLayoutManager::MaybeStartDragWindowFromShelf(
const gfx::Rect shelf_bounds = GetVisibleShelfBounds(); const gfx::Rect shelf_bounds = GetVisibleShelfBounds();
if (event_in_screen.location().y() < shelf_bounds.y()) if (event_in_screen.location().y() < shelf_bounds.y())
return false; return false;
// Do not start drag if it's a downward update event.
if (scroll_y.has_value() && *scroll_y > 0)
return false;
} }
// Do not allow window drag if the previous dragged window is still animating. // Do not allow window drag if the previous dragged window is still animating.
...@@ -2490,7 +2494,8 @@ void ShelfLayoutManager::MaybeUpdateWindowDrag( ...@@ -2490,7 +2494,8 @@ void ShelfLayoutManager::MaybeUpdateWindowDrag(
float scroll_x, float scroll_x,
float scroll_y) { float scroll_y) {
if (!IsWindowDragInProgress() && if (!IsWindowDragInProgress() &&
!MaybeStartDragWindowFromShelf(event_in_screen)) { !MaybeStartDragWindowFromShelf(event_in_screen,
base::make_optional(scroll_y))) {
return; return;
} }
......
...@@ -513,7 +513,8 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -513,7 +513,8 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
WorkspaceWindowState current_workspace_window_state); WorkspaceWindowState current_workspace_window_state);
// Maybe start/update/end the window drag when swiping up from the shelf. // Maybe start/update/end the window drag when swiping up from the shelf.
bool MaybeStartDragWindowFromShelf(const ui::LocatedEvent& event_in_screen); bool MaybeStartDragWindowFromShelf(const ui::LocatedEvent& event_in_screen,
base::Optional<float> scroll_y);
void MaybeUpdateWindowDrag(const ui::LocatedEvent& event_in_screen, void MaybeUpdateWindowDrag(const ui::LocatedEvent& event_in_screen,
float scroll_x, float scroll_x,
float scroll_y); float scroll_y);
......
...@@ -4494,6 +4494,28 @@ TEST_F(ShelfLayoutManagerWindowDraggingTest, StartsDragAfterHotseatIsUp) { ...@@ -4494,6 +4494,28 @@ TEST_F(ShelfLayoutManagerWindowDraggingTest, StartsDragAfterHotseatIsUp) {
EndScroll(/*is_fling=*/false, 0.f); EndScroll(/*is_fling=*/false, 0.f);
} }
TEST_F(ShelfLayoutManagerWindowDraggingTest, NoDragForDownwardEvent) {
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
Shelf* shelf = GetPrimaryShelf();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
SwipeUpOnShelf();
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
EXPECT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
// Start drag on the extended hotseat.
const int hotseat_padding_size = ShelfConfig::Get()->hotseat_bottom_padding();
gfx::Rect hotseat_bounds =
GetShelfWidget()->hotseat_widget()->GetWindowBoundsInScreen();
StartScroll(hotseat_bounds.CenterPoint());
EXPECT_FALSE(IsWindowDragInProgress());
UpdateScroll(hotseat_bounds.height() + hotseat_padding_size);
EXPECT_FALSE(IsWindowDragInProgress());
EndScroll(/*is_fling=*/false, 0.f);
}
class ShelfLayoutManagerKeyboardTest : public AshTestBase { class ShelfLayoutManagerKeyboardTest : public AshTestBase {
public: public:
ShelfLayoutManagerKeyboardTest() = default; ShelfLayoutManagerKeyboardTest() = default;
......
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