Commit 82f9896f authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

[reland] In tablet mode, tap on overview background should go to home screen.

Clamshell mode behavior will remain the same, i.e., tapping on the
overview background will return to its previous state, it can either be
in-app or home screen.

Bug: 997885

Change-Id: I2dae82657d4d92876c834c78dd62d53830fbe6cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865264
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707036}
parent 948e8c21
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "ash/wm/overview/overview_grid_event_handler.h" #include "ash/wm/overview/overview_grid_event_handler.h"
#include "ash/home_screen/home_screen_controller.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wallpaper/wallpaper_view.h" #include "ash/wallpaper/wallpaper_view.h"
...@@ -12,6 +14,7 @@ ...@@ -12,6 +14,7 @@
#include "ash/wm/overview/overview_grid.h" #include "ash/wm/overview/overview_grid.h"
#include "ash/wm/overview/overview_utils.h" #include "ash/wm/overview/overview_utils.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/display/screen.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/gestures/fling_curve.h" #include "ui/events/gestures/fling_curve.h"
...@@ -128,8 +131,20 @@ void OverviewGridEventHandler::HandleClickOrTap(ui::Event* event) { ...@@ -128,8 +131,20 @@ void OverviewGridEventHandler::HandleClickOrTap(ui::Event* event) {
CHECK_EQ(ui::EP_PRETARGET, event->phase()); CHECK_EQ(ui::EP_PRETARGET, event->phase());
// Events that happen while app list is sliding out during overview should // Events that happen while app list is sliding out during overview should
// be ignored to prevent overview from disappearing out from under the user. // be ignored to prevent overview from disappearing out from under the user.
if (!IsSlidingOutOverviewFromShelf()) if (!IsSlidingOutOverviewFromShelf()) {
Shell::Get()->overview_controller()->EndOverview(); if (Shell::Get()->tablet_mode_controller()->InTabletMode() &&
features::IsDragFromShelfToHomeOrOverviewEnabled()) {
// In tablet mode, clicking on tapping on the wallpaper background will
// always head back to home launcher screen.
int64_t display_id = display::Screen::GetScreen()
->GetDisplayNearestWindow(
static_cast<aura::Window*>(event->target()))
.id();
Shell::Get()->home_screen_controller()->GoHome(display_id);
} else {
Shell::Get()->overview_controller()->EndOverview();
}
}
event->StopPropagation(); event->StopPropagation();
} }
......
...@@ -17,11 +17,13 @@ ...@@ -17,11 +17,13 @@
#include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller.h"
#include "ash/display/screen_orientation_controller_test_api.h" #include "ash/display/screen_orientation_controller_test_api.h"
#include "ash/drag_drop/drag_drop_controller.h" #include "ash/drag_drop/drag_drop_controller.h"
#include "ash/home_screen/home_screen_controller.h"
#include "ash/magnifier/docked_magnifier_controller_impl.h" #include "ash/magnifier/docked_magnifier_controller_impl.h"
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/fps_counter.h" #include "ash/public/cpp/fps_counter.h"
#include "ash/public/cpp/shelf_config.h" #include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
...@@ -2790,6 +2792,50 @@ TEST_P(OverviewSessionTest, ShelfAlignmentChangeWhileInOverview) { ...@@ -2790,6 +2792,50 @@ TEST_P(OverviewSessionTest, ShelfAlignmentChangeWhileInOverview) {
EXPECT_FALSE(InOverviewSession()); EXPECT_FALSE(InOverviewSession());
} }
// The class to test overview behavior with kDragFromShelfToHomeOrOverview flag
// enabled.
class OverviewSessionWithDragFromShelfFeatureTest : public OverviewSessionTest {
public:
OverviewSessionWithDragFromShelfFeatureTest() = default;
~OverviewSessionWithDragFromShelfFeatureTest() override = default;
void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(
features::kDragFromShelfToHomeOrOverview);
OverviewSessionTest::SetUp();
EnterTabletMode();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(OverviewSessionWithDragFromShelfFeatureTest);
};
// Tests that in tablet mode, tapping on the background will always go to home
// screen.
TEST_P(OverviewSessionWithDragFromShelfFeatureTest, TapOnBackgroundGoToHome) {
UpdateDisplay("800x600");
std::unique_ptr<aura::Window> window(CreateTestWindow());
WindowState* window_state = WindowState::Get(window.get());
EXPECT_FALSE(window_state->IsMinimized());
EXPECT_FALSE(Shell::Get()->home_screen_controller()->IsHomeScreenVisible());
ToggleOverview();
EXPECT_TRUE(InOverviewSession());
// Tap on the background.
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
GetEventGenerator()->GestureTapAt(gfx::Point(10, 10));
ShellTestApi().WaitForOverviewAnimationState(
OverviewAnimationState::kExitAnimationComplete);
EXPECT_FALSE(InOverviewSession());
EXPECT_TRUE(window_state->IsMinimized());
EXPECT_TRUE(Shell::Get()->home_screen_controller()->IsHomeScreenVisible());
}
// TODO(sammiequon): Merge this into SplitViewOverviewSessionTest and rename // TODO(sammiequon): Merge this into SplitViewOverviewSessionTest and rename
// that to TabletModeOverviewSessionTest. // that to TabletModeOverviewSessionTest.
class OverviewSessionNewLayoutTest : public OverviewSessionTest { class OverviewSessionNewLayoutTest : public OverviewSessionTest {
...@@ -5251,5 +5297,8 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -5251,5 +5297,8 @@ INSTANTIATE_TEST_SUITE_P(
, ,
SplitViewOverviewSessionInClamshellTestMultiDisplayOnly, SplitViewOverviewSessionInClamshellTestMultiDisplayOnly,
testing::Values(true)); testing::Values(true));
INSTANTIATE_TEST_SUITE_P(,
OverviewSessionWithDragFromShelfFeatureTest,
testing::Bool());
} // namespace ash } // namespace ash
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