Commit 315b3895 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

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: I82624e44024e273a343c20e3707cb1d97e31d594
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864026Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706548}
parent ac627a3b
...@@ -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,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#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"
...@@ -2790,6 +2791,46 @@ TEST_P(OverviewSessionTest, ShelfAlignmentChangeWhileInOverview) { ...@@ -2790,6 +2791,46 @@ 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.
GetEventGenerator()->GestureTapAt(gfx::Point(10, 10));
base::RunLoop().RunUntilIdle();
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 +5292,8 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -5251,5 +5292,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