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

back_gesture: Filter the cases that should not show affordance.

Do not go back and show the back gesture affordance while in overview
mode, home screen or not in an ACTIVE session.

Bug: 1002733
Change-Id: Id01ac4fe02fefd94423924ea4871428c29aee497
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1854792Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705759}
parent e43337d5
......@@ -1499,4 +1499,8 @@ void AppListControllerImpl::NotifyHomeLauncherAnimationTransition(
CalculateAnimationTransitionForMetrics(trigger, launcher_will_show));
}
bool AppListControllerImpl::IsHomeScreenVisible() {
return IsVisible();
}
} // namespace ash
......@@ -272,6 +272,7 @@ class ASH_EXPORT AppListControllerImpl
base::Optional<base::TimeDelta> GetOptionalAnimationDuration() override;
void NotifyHomeLauncherAnimationTransition(AnimationTrigger trigger,
bool launcher_will_show) override;
bool IsHomeScreenVisible() override;
bool onscreen_keyboard_shown() const { return onscreen_keyboard_shown_; }
......
......@@ -114,6 +114,10 @@ void HomeScreenController::OnWindowDragEnded() {
UpdateVisibility();
}
bool HomeScreenController::IsHomeScreenVisible() const {
return delegate_->IsHomeScreenVisible();
}
void HomeScreenController::OnOverviewModeStarting() {
// Only animate the home screen when overview mode is using slide animation.
bool animate = Shell::Get()
......
......@@ -43,6 +43,9 @@ class ASH_EXPORT HomeScreenController : public OverviewObserver,
void OnWindowDragStarted();
void OnWindowDragEnded();
// True if home screen is visible.
bool IsHomeScreenVisible() const;
HomeLauncherGestureHandler* home_launcher_gesture_handler() {
return home_launcher_gesture_handler_.get();
}
......
......@@ -61,6 +61,9 @@ class HomeScreenDelegate {
// the transition animation if provided.
virtual base::Optional<base::TimeDelta> GetOptionalAnimationDuration() = 0;
// True if home screen is visible.
virtual bool IsHomeScreenVisible() = 0;
// Triggered when dragging launcher in tablet mode starts/proceeds/ends. They
// cover both dragging launcher to show and hide.
virtual void OnHomeLauncherDragStart() {}
......
......@@ -4,10 +4,13 @@
#include "ash/wm/toplevel_window_event_handler.h"
#include "ash/home_screen/home_screen_controller.h"
#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/wm/back_gesture_affordance.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/resize_shadow_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_resizer.h"
......@@ -105,7 +108,26 @@ bool CanStartGoingBack() {
if (!features::IsSwipingFromLeftEdgeToGoBackEnabled())
return false;
if (!Shell::Get()->tablet_mode_controller()->InTabletMode())
Shell* shell = Shell::Get();
if (!shell->tablet_mode_controller()->InTabletMode())
return false;
// Do not enable back gesture if it is not in an ACTIVE session. e.g, login
// screen, lock screen.
if (shell->session_controller()->GetSessionState() !=
session_manager::SessionState::ACTIVE) {
return false;
}
// Do not enable back gesture while overview mode is active but splitview is
// not active.
if (shell->overview_controller()->InOverviewSession() &&
!SplitViewController::Get()->InSplitViewMode()) {
return false;
}
// Do not enable back gesture if home screen is visible.
if (shell->home_screen_controller()->IsHomeScreenVisible())
return false;
return true;
......
......@@ -7,10 +7,12 @@
#include "ash/accelerators/accelerator_controller_impl.h"
#include "ash/display/screen_orientation_controller.h"
#include "ash/display/screen_orientation_controller_test_api.h"
#include "ash/home_screen/home_screen_controller.h"
#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/system/overview/overview_button_tray.h"
#include "ash/system/status_area_widget.h"
......@@ -1122,6 +1124,57 @@ TEST_F(ToplevelWindowEventHandlerBackGestureTest, FlingFromLeftEdgeToGoBack) {
EXPECT_EQ(1, target_back_release.accelerator_count());
}
TEST_F(ToplevelWindowEventHandlerBackGestureTest, DonotStartGoingBack) {
ui::TestAcceleratorTarget target_back_press, target_back_release;
RegisterBackPressAndRelease(&target_back_press, &target_back_release);
auto* shell = Shell::Get();
ui::test::EventGenerator* generator = GetEventGenerator();
const gfx::Point start(0, 100);
// Should not go back if it is not in ACTIVE session.
ASSERT_FALSE(shell->overview_controller()->InOverviewSession());
ASSERT_FALSE(shell->home_screen_controller()->IsHomeScreenVisible());
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::LOCKED);
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 while in overview mode but splitview is not active.
ASSERT_FALSE(SplitViewController::Get()->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 not visible.
shell->overview_controller()->EndOverview();
ASSERT_FALSE(shell->overview_controller()->InOverviewSession());
shell->home_screen_controller()->GoHome(GetPrimaryDisplay().id());
ASSERT_TRUE(shell->home_screen_controller()->IsHomeScreenVisible());
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());
}
namespace {
void SendMouseReleaseAndReleaseCapture(ui::test::EventGenerator* generator,
......
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