Do not change the workspace when entering/leaving overview
* This also fixes the IsSelecting so that it returns false
during shutdown.
BUG=834400
TEST=Covered by unit test
Change-Id: Iac0cb8a3bdf03609727c31c51000c52ececfc66a
Reviewed-on: https://chromium-review.googlesource.com/1140749
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576078}
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index 67e568e..d526a43 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -28,6 +28,7 @@
#include "ash/system/status_area_widget.h"
#include "ash/wm/fullscreen_window_finder.h"
#include "ash/wm/mru_window_tracker.h"
+#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/screen_pinning_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h"
@@ -673,7 +674,9 @@
const display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(
shelf_widget_->GetNativeWindow());
- if (!state_.IsScreenLocked() && change_work_area &&
+ bool in_overview =
+ Shell::Get()->window_selector_controller()->IsSelecting();
+ if (!in_overview && !state_.IsScreenLocked() && change_work_area &&
(shelf_->alignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED ||
display.work_area() == display.bounds())) {
gfx::Insets insets;
diff --git a/ash/wm/overview/window_selector_controller.cc b/ash/wm/overview/window_selector_controller.cc
index 76de53c..c0c2838 100644
--- a/ash/wm/overview/window_selector_controller.cc
+++ b/ash/wm/overview/window_selector_controller.cc
@@ -410,10 +410,10 @@
overview_blur_controller_->Unblur();
is_shutting_down_ = true;
Shell::Get()->NotifyOverviewModeEnding();
- window_selector_->Shutdown();
+ auto* window_selector = window_selector_.release();
+ window_selector->Shutdown();
// Don't delete |window_selector_| yet since the stack is still using it.
- base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
- window_selector_.release());
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window_selector);
last_selection_time_ = base::Time::Now();
Shell::Get()->NotifyOverviewModeEnded();
is_shutting_down_ = false;
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index c3286a6..0495e22 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -949,6 +949,7 @@
// mode correctly applies the transformations to the window and correctly
// updates the window bounds on exiting overview mode: http://crbug.com/401664.
TEST_F(WindowSelectorTest, FullscreenWindowTabletMode) {
+ UpdateDisplay("800x600");
const gfx::Rect bounds(400, 400);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
@@ -961,13 +962,24 @@
gfx::Rect fullscreen_window_bounds(window1->bounds());
EXPECT_NE(normal_window_bounds, fullscreen_window_bounds);
EXPECT_EQ(fullscreen_window_bounds, window2->GetTargetBounds());
+
+ const gfx::Rect fullscreen(800, 600);
+ const gfx::Rect normal_work_area(800, 552);
+ display::Screen* screen = display::Screen::GetScreen();
+ EXPECT_EQ(gfx::Rect(800, 600),
+ screen->GetDisplayNearestWindow(window1.get()).work_area());
+
ToggleOverview();
+ EXPECT_EQ(fullscreen,
+ screen->GetDisplayNearestWindow(window1.get()).work_area());
+
// Window 2 would normally resize to normal window bounds on showing the shelf
// for overview but this is deferred until overview is exited.
EXPECT_EQ(fullscreen_window_bounds, window2->GetTargetBounds());
EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get()));
ToggleOverview();
-
+ EXPECT_EQ(fullscreen,
+ screen->GetDisplayNearestWindow(window1.get()).work_area());
// Since the fullscreen window is still active, window2 will still have the
// larger bounds.
EXPECT_EQ(fullscreen_window_bounds, window2->GetTargetBounds());
@@ -976,7 +988,19 @@
// the shelf bringing window2 back to the normal bounds.
ToggleOverview();
ClickWindow(window2.get());
+ // Selecting non fullscreen window should set the work area back to normal.
+ EXPECT_EQ(normal_work_area,
+ screen->GetDisplayNearestWindow(window1.get()).work_area());
EXPECT_EQ(normal_window_bounds, window2->GetTargetBounds());
+
+ ToggleOverview();
+ EXPECT_EQ(normal_work_area,
+ screen->GetDisplayNearestWindow(window1.get()).work_area());
+ ClickWindow(window1.get());
+ // Selecting fullscreen. The work area should be updated to fullscreen as
+ // well.
+ EXPECT_EQ(fullscreen,
+ screen->GetDisplayNearestWindow(window1.get()).work_area());
}
// Tests that beginning window selection hides the app list.