Commit a21285f9 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Fix focus not correct after closing a split view window.

Test: added test
Bug: 992223
Change-Id: I717921ba2a0cc428b934b57e247f54395691b907
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1750155Reviewed-by: default avatarAvery Musbach <amusbach@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686463}
parent 55702a3b
...@@ -881,7 +881,7 @@ void OverviewSession::OnKeyEvent(ui::KeyEvent* event) { ...@@ -881,7 +881,7 @@ void OverviewSession::OnKeyEvent(ui::KeyEvent* event) {
} }
void OverviewSession::OnShellDestroying() { void OverviewSession::OnShellDestroying() {
// Cancel selection will call |Shutodnw()|, which will remove observer. // Cancel selection will call |Shutdown()|, which will remove observer.
EndOverview(); EndOverview();
} }
...@@ -927,6 +927,11 @@ void OverviewSession::OnSplitViewStateChanged(SplitViewState previous_state, ...@@ -927,6 +927,11 @@ void OverviewSession::OnSplitViewStateChanged(SplitViewState previous_state,
// Notify |split_view_drag_indicators_| if split view mode ended. // Notify |split_view_drag_indicators_| if split view mode ended.
if (split_view_drag_indicators_ && state == SplitViewState::kNoSnap) if (split_view_drag_indicators_ && state == SplitViewState::kNoSnap)
split_view_drag_indicators_->OnSplitViewModeEnded(); split_view_drag_indicators_->OnSplitViewModeEnded();
// Transfer focus from |window| to |overview_focus_widget_| to match the
// behavior of entering overview mode in the beginning.
DCHECK(overview_focus_widget_);
wm::ActivateWindow(GetOverviewFocusWindow());
} }
void OverviewSession::OnSplitViewDividerPositionChanged() { void OverviewSession::OnSplitViewDividerPositionChanged() {
......
...@@ -4368,6 +4368,29 @@ TEST_F(SplitViewOverviewSessionTest, NoCrashWhenPressTabKey) { ...@@ -4368,6 +4368,29 @@ TEST_F(SplitViewOverviewSessionTest, NoCrashWhenPressTabKey) {
EXPECT_TRUE(InOverviewSession()); EXPECT_TRUE(InOverviewSession());
} }
// Tests closing a snapped window while in overview mode.
TEST_F(SplitViewOverviewSessionTest, ClosingSplitViewWindow) {
const gfx::Rect bounds(400, 400);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
ToggleOverview();
// Drag |window1| selector item to snap to left.
OverviewItem* overview_item1 =
GetOverviewItemInGridWithWindow(0, window1.get());
DragWindowTo(overview_item1, gfx::PointF(0, 0));
EXPECT_TRUE(overview_controller()->InOverviewSession());
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
// Now close the snapped |window1|. We should remain in overview mode and the
// overview focus window should regain focus.
window1.reset();
EXPECT_TRUE(overview_controller()->InOverviewSession());
EXPECT_FALSE(split_view_controller()->InSplitViewMode());
EXPECT_EQ(overview_session()->GetOverviewFocusWindow(),
window_util::GetFocusedWindow());
}
// Test the split view and overview functionalities in clamshell mode. Split // Test the split view and overview functionalities in clamshell mode. Split
// view is only active when overview is active in clamshell mode. // view is only active when overview is active in clamshell mode.
class SplitViewOverviewSessionInClamshellTest class SplitViewOverviewSessionInClamshellTest
......
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