Commit ead7f9d3 authored by minch's avatar minch Committed by Commit Bot

back_gesture: Allowing go back in overview mode.

Bug: 1002733
Change-Id: I5fb541119dc56f98b70358fc68b70b5fe110a43b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1888102Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711315}
parent ca8e668c
...@@ -3132,9 +3132,15 @@ TEST_P(OverviewSessionNewLayoutTest, CheckOverviewItemScrollingBounds) { ...@@ -3132,9 +3132,15 @@ TEST_P(OverviewSessionNewLayoutTest, CheckOverviewItemScrollingBounds) {
// see if the item moved at all. // see if the item moved at all.
OverviewItem* leftmost_window = GetOverviewItemForWindow(windows[0].get()); OverviewItem* leftmost_window = GetOverviewItemForWindow(windows[0].get());
GenerateScrollSequence(gfx::Point(0, 50), gfx::Point(5000, 50)); GenerateScrollSequence(
gfx::Point(ToplevelWindowEventHandler::kStartGoingBackLeftEdgeInset + 5,
50),
gfx::Point(5000, 50));
const gfx::RectF left_bounds = leftmost_window->target_bounds(); const gfx::RectF left_bounds = leftmost_window->target_bounds();
GenerateScrollSequence(gfx::Point(0, 50), gfx::Point(5000, 50)); GenerateScrollSequence(
gfx::Point(ToplevelWindowEventHandler::kStartGoingBackLeftEdgeInset + 5,
50),
gfx::Point(5000, 50));
EXPECT_EQ(left_bounds, leftmost_window->target_bounds()); EXPECT_EQ(left_bounds, leftmost_window->target_bounds());
// Scroll an extreme amount to see if windows on the far right are still in // Scroll an extreme amount to see if windows on the far right are still in
......
...@@ -45,10 +45,6 @@ namespace { ...@@ -45,10 +45,6 @@ namespace {
// window from the top of the screen in tablet mode. // window from the top of the screen in tablet mode.
constexpr int kDragStartTopEdgeInset = 8; constexpr int kDragStartTopEdgeInset = 8;
// How many dips are reserved for gesture events to start swiping to previous
// page from the left edge of the screen in tablet mode.
constexpr int kStartGoingBackLeftEdgeInset = 16;
// Returns whether |window| can be moved via a two finger drag given // Returns whether |window| can be moved via a two finger drag given
// the hittest results of the two fingers. // the hittest results of the two fingers.
bool CanStartTwoFingerMove(aura::Window* window, bool CanStartTwoFingerMove(aura::Window* window,
...@@ -122,14 +118,6 @@ bool CanStartGoingBack(aura::Window* target) { ...@@ -122,14 +118,6 @@ bool CanStartGoingBack(aura::Window* target) {
return false; return false;
} }
// Do not enable back gesture while overview mode is active but splitview is
// not active.
if (shell->overview_controller()->InOverviewSession() &&
!SplitViewController::Get(Shell::GetPrimaryRootWindow())
->InSplitViewMode()) {
return false;
}
// Do not enable back gesture if home screen is visible but not in // Do not enable back gesture if home screen is visible but not in
// |kFullscreenSearch| state. // |kFullscreenSearch| state.
if (shell->home_screen_controller()->IsHomeScreenVisible() && if (shell->home_screen_controller()->IsHomeScreenVisible() &&
...@@ -167,7 +155,8 @@ bool StartedAwayFromLeftArea(ui::GestureEvent* event) { ...@@ -167,7 +155,8 @@ bool StartedAwayFromLeftArea(ui::GestureEvent* event) {
.work_area(); .work_area();
gfx::Rect hit_bounds_in_screen(work_area_bounds); gfx::Rect hit_bounds_in_screen(work_area_bounds);
hit_bounds_in_screen.set_width(kStartGoingBackLeftEdgeInset); hit_bounds_in_screen.set_width(
ToplevelWindowEventHandler::kStartGoingBackLeftEdgeInset);
return hit_bounds_in_screen.Contains(location_in_screen); return hit_bounds_in_screen.Contains(location_in_screen);
} }
......
...@@ -51,6 +51,10 @@ class ASH_EXPORT ToplevelWindowEventHandler ...@@ -51,6 +51,10 @@ class ASH_EXPORT ToplevelWindowEventHandler
// previous page. // previous page.
static constexpr int kFlingVelocityForGoingBack = 1000; static constexpr int kFlingVelocityForGoingBack = 1000;
// How many dips are reserved for gesture events to start swiping to previous
// page from the left edge of the screen in tablet mode.
static constexpr int kStartGoingBackLeftEdgeInset = 16;
// Describes what triggered ending the drag. // Describes what triggered ending the drag.
enum class DragResult { enum class DragResult {
// The drag successfully completed. // The drag successfully completed.
......
...@@ -1127,6 +1127,21 @@ TEST_F(ToplevelWindowEventHandlerBackGestureTest, FlingFromLeftEdgeToGoBack) { ...@@ -1127,6 +1127,21 @@ TEST_F(ToplevelWindowEventHandlerBackGestureTest, FlingFromLeftEdgeToGoBack) {
EXPECT_EQ(1, target_back_release.accelerator_count()); EXPECT_EQ(1, target_back_release.accelerator_count());
} }
TEST_F(ToplevelWindowEventHandlerBackGestureTest, GoBackInOverviewMode) {
ui::TestAcceleratorTarget target_back_press, target_back_release;
RegisterBackPressAndRelease(&target_back_press, &target_back_release);
auto* shell = Shell::Get();
shell->overview_controller()->StartOverview();
ASSERT_TRUE(shell->overview_controller()->InOverviewSession());
GetEventGenerator()->GestureScrollSequence(
gfx::Point(0, 100),
gfx::Point(ToplevelWindowEventHandler::kSwipingDistanceForGoingBack + 10,
100),
base::TimeDelta::FromMilliseconds(100), 3);
EXPECT_EQ(1, target_back_release.accelerator_count());
}
TEST_F(ToplevelWindowEventHandlerBackGestureTest, DonotStartGoingBack) { TEST_F(ToplevelWindowEventHandlerBackGestureTest, DonotStartGoingBack) {
ui::TestAcceleratorTarget target_back_press, target_back_release; ui::TestAcceleratorTarget target_back_press, target_back_release;
RegisterBackPressAndRelease(&target_back_press, &target_back_release); RegisterBackPressAndRelease(&target_back_press, &target_back_release);
...@@ -1148,27 +1163,10 @@ TEST_F(ToplevelWindowEventHandlerBackGestureTest, DonotStartGoingBack) { ...@@ -1148,27 +1163,10 @@ TEST_F(ToplevelWindowEventHandlerBackGestureTest, DonotStartGoingBack) {
EXPECT_EQ(0, target_back_press.accelerator_count()); EXPECT_EQ(0, target_back_press.accelerator_count());
EXPECT_EQ(0, target_back_release.accelerator_count()); EXPECT_EQ(0, target_back_release.accelerator_count());
// Should not go back while in overview mode but splitview is not active.
ASSERT_FALSE(SplitViewController::Get(Shell::GetPrimaryRootWindow())
->InSplitViewMode());
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::ACTIVE);
ASSERT_EQ(session_manager::SessionState::ACTIVE,
shell->session_controller()->GetSessionState());
shell->overview_controller()->StartOverview();
ASSERT_TRUE(shell->overview_controller()->InOverviewSession());
generator->GestureScrollSequence(
start,
gfx::Point(ToplevelWindowEventHandler::kSwipingDistanceForGoingBack + 10,
100),
base::TimeDelta::FromMilliseconds(100), 3);
EXPECT_EQ(0, target_back_press.accelerator_count());
EXPECT_EQ(0, target_back_release.accelerator_count());
// Should not go back if home screen is visible and in |kFullscreenAllApps| // Should not go back if home screen is visible and in |kFullscreenAllApps|
// state. // state.
shell->overview_controller()->EndOverview(); GetSessionControllerClient()->SetSessionState(
ASSERT_FALSE(shell->overview_controller()->InOverviewSession()); session_manager::SessionState::ACTIVE);
shell->home_screen_controller()->GoHome(GetPrimaryDisplay().id()); shell->home_screen_controller()->GoHome(GetPrimaryDisplay().id());
ASSERT_TRUE(shell->home_screen_controller()->IsHomeScreenVisible()); ASSERT_TRUE(shell->home_screen_controller()->IsHomeScreenVisible());
GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenAllApps); GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenAllApps);
......
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