Commit e539c403 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

End overview when opening app list (or home launcher in tablet mode).

Previously it was by design that we don't end overview when opening
app list while splitview + overview are both active. But after the
discussion in Issue 991390, we decided to follow the current existing
behavior and let app list end splitview+overview in this case.

Bug: 996869
Change-Id: I15689b5cf61872110254446bdecce3bc3103aca3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1766090
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690973}
parent 0710e3a5
...@@ -1108,14 +1108,9 @@ bool AppListControllerImpl::KeyboardTraversalEngaged() { ...@@ -1108,14 +1108,9 @@ bool AppListControllerImpl::KeyboardTraversalEngaged() {
bool AppListControllerImpl::CanProcessEventsOnApplistViews() { bool AppListControllerImpl::CanProcessEventsOnApplistViews() {
// Do not allow processing events during overview or while overview is // Do not allow processing events during overview or while overview is
// finished but still animating out. Note in clamshell mode, if overview and // finished but still animating out.
// splitview is both active, we still allow the user to open app list and
// select an app. The app will be opened in snapped window state and overview
// will be ended after the app is opened.
OverviewController* overview_controller = Shell::Get()->overview_controller(); OverviewController* overview_controller = Shell::Get()->overview_controller();
auto* split_view_controller = Shell::Get()->split_view_controller(); if (overview_controller->InOverviewSession() ||
if ((overview_controller->InOverviewSession() &&
!split_view_controller->InClamshellSplitViewMode()) ||
overview_controller->IsCompletingShutdownAnimations()) { overview_controller->IsCompletingShutdownAnimations()) {
return false; return false;
} }
......
...@@ -680,12 +680,19 @@ void OverviewSession::OnWindowActivating( ...@@ -680,12 +680,19 @@ void OverviewSession::OnWindowActivating(
return; return;
} }
auto* grid = GetGridWithRootWindow(gained_active->GetRootWindow()); // If app list is open in clamshell mode, end overview. Note: we have special
if (!grid) // logic to end overview when app list (i.e., home launcher) is open in tablet
// mode, so do not handle it here.
if (gained_active == Shell::Get()->app_list_controller()->GetWindow() &&
!Shell::Get()->tablet_mode_controller()->InTabletMode()) {
ResetFocusRestoreWindow(false);
EndOverview();
return; return;
}
// Do not cancel overview mode if the window activation was caused by // Do not cancel overview mode if the window activation happens when split
// snapping window to one side of the screen. // view mode is also active. SplitViewController will do the right thing to
// handle the window activation change.
if (Shell::Get()->split_view_controller()->InSplitViewMode()) if (Shell::Get()->split_view_controller()->InSplitViewMode())
return; return;
...@@ -694,9 +701,6 @@ void OverviewSession::OnWindowActivating( ...@@ -694,9 +701,6 @@ void OverviewSession::OnWindowActivating(
if (IsSlidingOutOverviewFromShelf()) if (IsSlidingOutOverviewFromShelf())
return; return;
// Don't restore focus on exit if a window was just activated.
ResetFocusRestoreWindow(false);
// Do not cancel overview mode while a window or overview item is being // Do not cancel overview mode while a window or overview item is being
// dragged as evidenced by the presence of a drop target. (Dragging to close // dragged as evidenced by the presence of a drop target. (Dragging to close
// does not count; canceling overview mode is okay then.) // does not count; canceling overview mode is okay then.)
...@@ -705,6 +709,8 @@ void OverviewSession::OnWindowActivating( ...@@ -705,6 +709,8 @@ void OverviewSession::OnWindowActivating(
return; return;
} }
auto* grid = GetGridWithRootWindow(gained_active->GetRootWindow());
DCHECK(grid);
const auto& windows = grid->window_list(); const auto& windows = grid->window_list();
auto iter = std::find_if( auto iter = std::find_if(
windows.begin(), windows.end(), windows.begin(), windows.end(),
...@@ -714,6 +720,9 @@ void OverviewSession::OnWindowActivating( ...@@ -714,6 +720,9 @@ void OverviewSession::OnWindowActivating(
if (iter != windows.end()) if (iter != windows.end())
selected_item_ = iter->get(); selected_item_ = iter->get();
// Don't restore focus on exit if a window was just activated.
ResetFocusRestoreWindow(false);
EndOverview(); EndOverview();
} }
......
...@@ -4614,7 +4614,7 @@ TEST_F(SplitViewOverviewSessionInClamshellTest, BasicFunctionalitiesTest) { ...@@ -4614,7 +4614,7 @@ TEST_F(SplitViewOverviewSessionInClamshellTest, BasicFunctionalitiesTest) {
// Overview bounds will adjust from snapped bounds to fullscreen bounds. // Overview bounds will adjust from snapped bounds to fullscreen bounds.
EXPECT_EQ(GetGridBounds(), overview_bounds); EXPECT_EQ(GetGridBounds(), overview_bounds);
// 7. Test if split view mode is active, open the app list will not end // 7. Test if split view mode is active, open the app list will end both
// overview and splitview. // overview and splitview.
overview_item3 = GetOverviewItemForWindow(window3.get()); overview_item3 = GetOverviewItemForWindow(window3.get());
DragWindowTo(overview_item3, gfx::PointF(0, 0)); DragWindowTo(overview_item3, gfx::PointF(0, 0));
...@@ -4627,57 +4627,17 @@ TEST_F(SplitViewOverviewSessionInClamshellTest, BasicFunctionalitiesTest) { ...@@ -4627,57 +4627,17 @@ TEST_F(SplitViewOverviewSessionInClamshellTest, BasicFunctionalitiesTest) {
display::Screen::GetScreen()->GetDisplayNearestWindow(window3.get()).id(), display::Screen::GetScreen()->GetDisplayNearestWindow(window3.get()).id(),
app_list::AppListShowSource::kSearchKey, base::TimeTicks()); app_list::AppListShowSource::kSearchKey, base::TimeTicks());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_TRUE(overview_controller()->InOverviewSession());
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
}
// Test that if app list is visible when overview is open, overview should
// ignore all key events.
TEST_F(SplitViewOverviewSessionInClamshellTest, IgnoreEventsIfApplistVisible) {
const gfx::Rect bounds(400, 400);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
// If splitview is not active, open app list when overview is active will
// just end overview.
ToggleOverview();
// Open app list.
AppListControllerImpl* app_list_controller =
Shell::Get()->app_list_controller();
app_list_controller->ToggleAppList(
display::Screen::GetScreen()->GetDisplayNearestWindow(window1.get()).id(),
app_list::AppListShowSource::kSearchKey, base::TimeTicks());
base::RunLoop().RunUntilIdle();
// Test that app list is open and overview is ended.
EXPECT_TRUE(app_list_controller->IsVisible());
EXPECT_FALSE(overview_controller()->InOverviewSession()); EXPECT_FALSE(overview_controller()->InOverviewSession());
EXPECT_FALSE(split_view_controller()->InSplitViewMode());
// 8. Test if splitview is active, open the app list will end overview if
// overview is active.
ToggleOverview(); ToggleOverview();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(app_list_controller->IsVisible());
OverviewItem* overview_item1 = GetOverviewItemForWindow(window1.get());
DragWindowTo(overview_item1, gfx::PointF(0, 0));
EXPECT_TRUE(overview_controller()->InOverviewSession());
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
// Open app list. // Open app list.
app_list_controller->ToggleAppList( app_list_controller->ToggleAppList(
display::Screen::GetScreen()->GetDisplayNearestWindow(window1.get()).id(), display::Screen::GetScreen()->GetDisplayNearestWindow(window3.get()).id(),
app_list::AppListShowSource::kSearchKey, base::TimeTicks()); app_list::AppListShowSource::kSearchKey, base::TimeTicks());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
// Test that app list is open, splitview and overview are both active.
EXPECT_TRUE(app_list_controller->IsVisible());
EXPECT_TRUE(overview_controller()->InOverviewSession());
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
// Send ui::VKEY_ESCAPE should dismiss app list. But splitview and overview
// should still be active.
SendKey(ui::VKEY_ESCAPE);
EXPECT_FALSE(app_list_controller->IsVisible());
EXPECT_TRUE(overview_controller()->InOverviewSession());
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
// Send ui::VKEY_ESCAPE should then end overview.
SendKey(ui::VKEY_ESCAPE);
EXPECT_FALSE(overview_controller()->InOverviewSession()); EXPECT_FALSE(overview_controller()->InOverviewSession());
EXPECT_FALSE(split_view_controller()->InSplitViewMode()); EXPECT_FALSE(split_view_controller()->InSplitViewMode());
} }
......
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