Commit 1ebd7e48 authored by Richard Chui's avatar Richard Chui Committed by Commit Bot

Alt+Tab: Prevent window cycling if desk animation active

Check if there is an on-going desk animation before starting a new
window cycle.

Previously, Alt+Tabbing in quick succession between windows on different
desks leads to a broken state where the activated desk doesn't contain
the active window, preventing Alt+Tab from working until clicking on the
window.

Test: manual, added test
Fixed: 1115343
Change-Id: I5d0ffbcf00275a770b27dd923b7c14aab44264df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425113
Commit-Queue: Richard Chui <richui@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809914}
parent 41576333
......@@ -77,7 +77,8 @@ bool WindowCycleController::CanCycle() {
return !Shell::Get()->session_controller()->IsScreenLocked() &&
!Shell::IsSystemModalWindowOpen() &&
!Shell::Get()->screen_pinning_controller()->IsPinned() &&
!window_util::IsAnyWindowDragged();
!window_util::IsAnyWindowDragged() &&
!Shell::Get()->desks_controller()->AreDesksBeingModified();
}
void WindowCycleController::HandleCycleWindow(Direction direction) {
......
......@@ -1137,4 +1137,35 @@ TEST_F(WindowCycleControllerTest, FrameThrottling) {
frame_throttling_controller->RemoveObserver(&observer);
}
// Tests that pressing Alt+Tab while there is an on-going desk animation
// prevents a new window cycle from starting.
TEST_F(WindowCycleControllerTest, DoubleAltTabWithDeskSwitch) {
WindowCycleController* cycle_controller =
Shell::Get()->window_cycle_controller();
auto win0 = CreateAppWindow(gfx::Rect(250, 100));
auto* desks_controller = DesksController::Get();
desks_controller->NewDesk(DesksCreationRemovalSource::kButton);
ASSERT_EQ(2u, desks_controller->desks().size());
const Desk* desk_0 = desks_controller->desks()[0].get();
const Desk* desk_1 = desks_controller->desks()[1].get();
ActivateDesk(desk_1);
EXPECT_EQ(desk_1, desks_controller->active_desk());
auto win1 = CreateAppWindow(gfx::Rect(300, 200));
ASSERT_EQ(win1.get(), window_util::GetActiveWindow());
auto desk_1_windows = desk_1->windows();
EXPECT_EQ(1u, desk_1_windows.size());
EXPECT_TRUE(base::Contains(desk_1_windows, win1.get()));
DeskSwitchAnimationWaiter waiter;
cycle_controller->HandleCycleWindow(WindowCycleController::FORWARD);
cycle_controller->CompleteCycling();
EXPECT_FALSE(cycle_controller->CanCycle());
cycle_controller->HandleCycleWindow(WindowCycleController::FORWARD);
EXPECT_FALSE(cycle_controller->IsCycling());
waiter.Wait();
EXPECT_EQ(desk_0, desks_controller->active_desk());
EXPECT_EQ(win0.get(), window_util::GetActiveWindow());
}
} // 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