Commit bb7a604a authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

split view: Fix case with one tablet split view window and no overview

See the videos linked in https://crbug.com/1027179.

Fixed: 1027179
Change-Id: Ia4f4e112b02297f3d43da81935ee1e97215c3d85
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1979146Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729997}
parent a5e36b31
...@@ -82,7 +82,10 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver, ...@@ -82,7 +82,10 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver,
kSwipeFromShelf, kSwipeFromShelf,
// Used only when it's desired to enter overview mode immediately without // Used only when it's desired to enter overview mode immediately without
// animations. It's used when entering overview by dragging a window from // animations. It's used when entering overview by dragging a window from
// from the top of the screen. // the top of the screen or from the shelf. It's also used when entering
// overview to avoid the blatantly broken behaviors shown in the videos
// linked in https://crbug.com/1027179. This should not be used for exiting
// overview mode.
kImmediateEnter, kImmediateEnter,
// Used only when it's desired to exit overview mode immediately without // Used only when it's desired to exit overview mode immediately without
// animations. This is used when performing the desk switch animation when // animations. This is used when performing the desk switch animation when
......
...@@ -1124,6 +1124,21 @@ void SplitViewController::OnOverviewModeEnding( ...@@ -1124,6 +1124,21 @@ void SplitViewController::OnOverviewModeEnding(
ShowAppCannotSnapToast(); ShowAppCannotSnapToast();
} }
void SplitViewController::OnDisplayRemoved(
const display::Display& old_display) {
// Display removal always triggers a window activation which ends overview,
// and therefore ends clamshell split view, before |OnDisplayRemoved| is
// called. In clamshell mode, |OverviewController::CanEndOverview| always
// returns true, meaning that overview is guaranteed to end successfully.
DCHECK(!InClamshellSplitViewMode());
// If we are in tablet split view with only one snapped window, make sure we
// are in overview (see https://crbug.com/1027179).
if (state_ == State::kLeftSnapped || state_ == State::kRightSnapped) {
Shell::Get()->overview_controller()->StartOverview(
OverviewSession::EnterExitOverviewType::kImmediateEnter);
}
}
void SplitViewController::OnDisplayMetricsChanged( void SplitViewController::OnDisplayMetricsChanged(
const display::Display& display, const display::Display& display,
uint32_t metrics) { uint32_t metrics) {
......
...@@ -236,6 +236,7 @@ class ASH_EXPORT SplitViewController : public aura::WindowObserver, ...@@ -236,6 +236,7 @@ class ASH_EXPORT SplitViewController : public aura::WindowObserver,
void OnOverviewModeEnding(OverviewSession* overview_session) override; void OnOverviewModeEnding(OverviewSession* overview_session) override;
// display::DisplayObserver: // display::DisplayObserver:
void OnDisplayRemoved(const display::Display& old_display) override;
void OnDisplayMetricsChanged(const display::Display& display, void OnDisplayMetricsChanged(const display::Display& display,
uint32_t metrics) override; uint32_t metrics) override;
......
...@@ -1451,6 +1451,25 @@ TEST_P( ...@@ -1451,6 +1451,25 @@ TEST_P(
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
TEST_P(TabletModeControllerTest,
StartTabletActiveLeftSnapOnPrimaryDisplayPreviousOnSecondaryDisplay) {
UpdateDisplay("800x600,800x600");
std::unique_ptr<aura::Window> window1 =
CreateDesktopWindowSnappedLeft(gfx::Rect(0, 0, 400, 400));
EXPECT_EQ(Shell::GetPrimaryRootWindow(), window1->GetRootWindow());
std::unique_ptr<aura::Window> window2 =
CreateTestWindow(gfx::Rect(800, 0, 400, 400));
EXPECT_NE(Shell::GetPrimaryRootWindow(), window2->GetRootWindow());
wm::ActivateWindow(window1.get());
tablet_mode_controller()->SetEnabledForTest(true);
// After display mirroring triggers, as the split view state will still be
// |SplitViewController::State::kLeftSnapped|, check for overview mode.
base::RunLoop().RunUntilIdle();
EXPECT_EQ(SplitViewController::State::kLeftSnapped,
split_view_controller()->state());
EXPECT_TRUE(Shell::Get()->overview_controller()->InOverviewSession());
}
// Test that tablet mode controller does not respond to the input device changes // Test that tablet mode controller does not respond to the input device changes
// during its suspend. // during its suspend.
TEST_P(TabletModeControllerTest, DoNotObserverInputDeviceChangeDuringSuspend) { TEST_P(TabletModeControllerTest, DoNotObserverInputDeviceChangeDuringSuspend) {
......
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