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

overview: Fixed bad overview mode state transition with double tap.

Do not activate quick switch when double tapping the tray, if the mru
window is not activate. This was causing an unexpected window activation
which was messing up the overview state, and also visually popping up
and activating an unexpected window.

Test: Checked that OnEndingAnimation does not get called between ToggleOverview calls
Bug: 905082
Change-Id: Iaa7d3d02482d33d27ade6684ece8b92e9c270204
Reviewed-on: https://chromium-review.googlesource.com/c/1336149
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608193}
parent 0b8cddae
......@@ -13,6 +13,7 @@
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_container.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/window_selector.h"
#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
......@@ -79,7 +80,9 @@ bool OverviewButtonTray::PerformAction(const ui::Event& event) {
kDoubleTapThresholdMs) {
// Second taps should not be processed outside of overview mode. (First
// taps should be outside of overview).
DCHECK(Shell::Get()->window_selector_controller()->IsSelecting());
WindowSelectorController* window_selector_controller =
Shell::Get()->window_selector_controller();
DCHECK(window_selector_controller->IsSelecting());
base::RecordAction(base::UserMetricsAction("Tablet_QuickSwitch"));
......@@ -89,8 +92,12 @@ bool OverviewButtonTray::PerformAction(const ui::Event& event) {
Shell::Get()->mru_window_tracker()->BuildWindowForCycleList();
// Switch to the second most recently used window (most recent is the
// current window) if it exists, unless splitview mode is active.
if (mru_window_list.size() > 1u) {
// current window) if it exists, unless splitview mode is active. Do not
// switch we entered overview mode will all windows minimized.
if (mru_window_list.size() > 1u &&
window_selector_controller->window_selector()
->enter_exit_overview_type() !=
WindowSelector::EnterExitOverviewType::kWindowsMinimized) {
aura::Window* new_active_window = mru_window_list[1];
// In splitview mode, quick switch will only affect the windows on the non
......@@ -110,7 +117,7 @@ bool OverviewButtonTray::PerformAction(const ui::Event& event) {
}
AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr);
wm::GetWindowState(new_active_window)->Activate();
::wm::ActivateWindow(new_active_window);
last_press_event_time_ = base::nullopt;
return true;
}
......
......@@ -133,6 +133,8 @@ TEST_F(OverviewButtonTrayTest, PerformAction) {
}
TEST_F(OverviewButtonTrayTest, PerformDoubleTapAction) {
TabletModeControllerTestApi().EnterTabletMode();
ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
// Add two windows and activate the second one to test quick switch.
......@@ -167,6 +169,15 @@ TEST_F(OverviewButtonTrayTest, PerformDoubleTapAction) {
PerformDoubleTap();
EXPECT_EQ(window2->layer()->GetTargetOpacity(), 1.0);
EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
// Verify that if all windows are minimized, double tapping the tray will have
// no effect.
ASSERT_TRUE(!Shell::Get()->window_selector_controller()->IsSelecting());
wm::GetWindowState(window1.get())->Minimize();
wm::GetWindowState(window2.get())->Minimize();
PerformDoubleTap();
EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
}
// Tests that tapping on the control will record the user action Tray_Overview.
......
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