| Index: ash/wm/maximize_mode/maximize_mode_window_manager.cc
|
| diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager.cc b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
|
| index 6360450d36cbd9f62e045c0f8147dd037646d6a2..feb668c6da1e71789d562768bda73f850eabae78 100644
|
| --- a/ash/wm/maximize_mode/maximize_mode_window_manager.cc
|
| +++ b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
|
| @@ -4,9 +4,11 @@
|
|
|
| #include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
|
|
|
| +#include "ash/root_window_controller.h"
|
| #include "ash/shell.h"
|
| #include "ash/switchable_windows.h"
|
| #include "ash/wm/mru_window_tracker.h"
|
| +#include "ash/wm/workspace_controller.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/gfx/screen.h"
|
|
|
| @@ -14,7 +16,9 @@ namespace ash {
|
| namespace internal {
|
|
|
| MaximizeModeWindowManager::~MaximizeModeWindowManager() {
|
| + Shell::GetInstance()->RemoveShellObserver(this);
|
| Shell::GetScreen()->RemoveObserver(this);
|
| + EnableBackdropBehindTopWindowOnEachDisplay(false);
|
| RemoveWindowCreationObservers();
|
| RestoreAllWindows();
|
| }
|
| @@ -23,6 +27,22 @@ int MaximizeModeWindowManager::GetNumberOfManagedWindows() {
|
| return initial_show_state_.size();
|
| }
|
|
|
| +void MaximizeModeWindowManager::OnOverviewModeStarted() {
|
| + if (backdrops_hidden_)
|
| + return;
|
| +
|
| + EnableBackdropBehindTopWindowOnEachDisplay(false);
|
| + backdrops_hidden_ = true;
|
| +}
|
| +
|
| +void MaximizeModeWindowManager::OnOverviewModeEnded() {
|
| + if (!backdrops_hidden_)
|
| + return;
|
| +
|
| + backdrops_hidden_ = false;
|
| + EnableBackdropBehindTopWindowOnEachDisplay(true);
|
| +}
|
| +
|
| void MaximizeModeWindowManager::OnWindowDestroying(aura::Window* window) {
|
| // If a known window gets destroyed we need to remove all knowledge about it.
|
| if (!IsContainerWindow(window))
|
| @@ -58,25 +78,28 @@ void MaximizeModeWindowManager::OnDisplayBoundsChanged(
|
| }
|
|
|
| void MaximizeModeWindowManager::OnDisplayAdded(const gfx::Display& display) {
|
| - RemoveWindowCreationObservers();
|
| - AddWindowCreationObservers();
|
| -
|
| + DisplayConfigurationChanged();
|
| }
|
| +
|
| void MaximizeModeWindowManager::OnDisplayRemoved(const gfx::Display& display) {
|
| - RemoveWindowCreationObservers();
|
| - AddWindowCreationObservers();
|
| + DisplayConfigurationChanged();
|
| }
|
|
|
| -MaximizeModeWindowManager::MaximizeModeWindowManager() {
|
| +MaximizeModeWindowManager::MaximizeModeWindowManager()
|
| + : backdrops_hidden_(false) {
|
| MaximizeAllWindows();
|
| AddWindowCreationObservers();
|
| + EnableBackdropBehindTopWindowOnEachDisplay(true);
|
| Shell::GetScreen()->AddObserver(this);
|
| + Shell::GetInstance()->AddShellObserver(this);
|
| }
|
|
|
| void MaximizeModeWindowManager::MaximizeAllWindows() {
|
| MruWindowTracker::WindowList windows =
|
| MruWindowTracker::BuildWindowList(false);
|
| // Add all existing Mru windows.
|
| + // TODO(skuhne): The MRUWindowTracker also includes always on top and panel
|
| + // windows. Panel windows shouldn't be a problem, but always on top might be.
|
| for (MruWindowTracker::WindowList::iterator window = windows.begin();
|
| window != windows.end(); ++window) {
|
| MaximizeAndTrackWindow(*window);
|
| @@ -116,7 +139,6 @@ void MaximizeModeWindowManager::MaximizeAndTrackWindow(
|
| else
|
| window_state->SetRestoreBoundsInScreen(initial_rect);
|
| CenterWindow(window);
|
| - // TODO(skuhne): Add a background cover layer.
|
| } else {
|
| // Minimized windows can remain as they are.
|
| if (state != ui::SHOW_STATE_MINIMIZED)
|
| @@ -131,7 +153,6 @@ void MaximizeModeWindowManager::RestoreAndForgetWindow(
|
| // Restore window if it can be restored.
|
| if (state != ui::SHOW_STATE_MAXIMIZED) {
|
| if (!CanMaximize(window)) {
|
| - // TODO(skuhne): Remove the background cover layer.
|
| ash::wm::WindowState* window_state = ash::wm::GetWindowState(window);
|
| DCHECK(window_state->HasRestoreBounds());
|
| gfx::Rect initial_bounds =
|
| @@ -193,6 +214,7 @@ void MaximizeModeWindowManager::AddWindowCreationObservers() {
|
| aura::Window::Windows root_windows = Shell::GetAllRootWindows();
|
| for (aura::Window::Windows::const_iterator iter = root_windows.begin();
|
| iter != root_windows.end(); ++iter) {
|
| + // TODO(skuhne): We might only need the DefaultContainer here.
|
| for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) {
|
| aura::Window* container = Shell::GetContainer(*iter,
|
| kSwitchableWindowContainerIds[i]);
|
| @@ -213,10 +235,32 @@ void MaximizeModeWindowManager::RemoveWindowCreationObservers() {
|
| observed_container_windows_.clear();
|
| }
|
|
|
| +void MaximizeModeWindowManager::EnableBackdropBehindTopWindowOnEachDisplay(
|
| + bool enable) {
|
| + if (backdrops_hidden_)
|
| + return;
|
| + // Inform the WorkspaceLayoutManager that we want to show a backdrop behind
|
| + // the topmost window of its container.
|
| + Shell::RootWindowControllerList controllers =
|
| + Shell::GetAllRootWindowControllers();
|
| + for (Shell::RootWindowControllerList::iterator iter = controllers.begin();
|
| + iter != controllers.end(); ++iter) {
|
| + RootWindowController* controller = *iter;
|
| + controller->workspace_controller()->AddBackdropBehindTopWindow(enable);
|
| + }
|
| +}
|
| +
|
| bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) {
|
| return observed_container_windows_.find(window) !=
|
| observed_container_windows_.end();
|
| }
|
|
|
| +void MaximizeModeWindowManager::DisplayConfigurationChanged() {
|
| + EnableBackdropBehindTopWindowOnEachDisplay(false);
|
| + RemoveWindowCreationObservers();
|
| + AddWindowCreationObservers();
|
| + EnableBackdropBehindTopWindowOnEachDisplay(true);
|
| +}
|
| +
|
| } // namespace internal
|
| } // namespace ash
|
|
|