From 6344760afdb784d456ae77cb366b06962c4069c5 Mon Sep 17 00:00:00 2001 From: "skuhne@chromium.org" Date: Sun, 9 Mar 2014 17:58:25 +0000 Subject: Adding a gray semi transparent backdrop behind the topmost window within the default container This is part of the "always maximized" feature. Windows which cannot be maximized - or cannot be made to cover the entire screen should have a backdrop behind them which covers the desktop. Tried various ways to implement this and this seems to be the best solution. BUG=337567, 337563 Review URL: https://codereview.chromium.org/169643005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255863 0039d316-1c4b-4281-b951-d872f2087c98 --- .../maximize_mode/maximize_mode_window_manager.cc | 72 +++++++++++++++++----- 1 file changed, 58 insertions(+), 14 deletions(-) (limited to '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 cd42ba9..6858f36 100644 --- a/ash/wm/maximize_mode/maximize_mode_window_manager.cc +++ b/ash/wm/maximize_mode/maximize_mode_window_manager.cc @@ -4,9 +4,12 @@ #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/shell_window_ids.h" +#include "ash/wm/maximize_mode/workspace_backdrop_delegate.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 +17,9 @@ namespace ash { namespace internal { MaximizeModeWindowManager::~MaximizeModeWindowManager() { + Shell::GetInstance()->RemoveShellObserver(this); Shell::GetScreen()->RemoveObserver(this); + EnableBackdropBehindTopWindowOnEachDisplay(false); RemoveWindowCreationObservers(); RestoreAllWindows(); } @@ -23,6 +28,22 @@ int MaximizeModeWindowManager::GetNumberOfManagedWindows() { return initial_state_type_.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)) @@ -65,10 +86,15 @@ void MaximizeModeWindowManager::OnDisplayRemoved(const gfx::Display& display) { DisplayConfigurationChanged(); } -MaximizeModeWindowManager::MaximizeModeWindowManager() { +MaximizeModeWindowManager::MaximizeModeWindowManager() + : backdrops_hidden_(false) { + // TODO(skuhne): Turn off the overview mode and full screen modes before + // entering the MaximzieMode. MaximizeAllWindows(); AddWindowCreationObservers(); + EnableBackdropBehindTopWindowOnEachDisplay(true); Shell::GetScreen()->AddObserver(this); + Shell::GetInstance()->AddShellObserver(this); } void MaximizeModeWindowManager::MaximizeAllWindows() { @@ -110,7 +136,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 != wm::WINDOW_STATE_TYPE_MINIMIZED) @@ -128,7 +153,6 @@ void MaximizeModeWindowManager::RestoreAndForgetWindow( // Restore window if it can be restored. if (state != wm::WINDOW_STATE_TYPE_MAXIMIZED) { if (!CanMaximize(window)) { - // TODO(skuhne): Remove the background cover layer. if (window_state->HasRestoreBounds()) { // TODO(skuhne): If the system shuts down in maximized mode, the proper // restore coordinates should get saved. @@ -187,19 +211,17 @@ void MaximizeModeWindowManager::CenterWindow(aura::Window* window) { void MaximizeModeWindowManager::AddWindowCreationObservers() { DCHECK(observed_container_windows_.empty()); - // Observe window activations and switchable containers on all root windows - // for newly created windows during overview. + // Observe window activations/creations in the default containers on all root + // windows. aura::Window::Windows root_windows = Shell::GetAllRootWindows(); for (aura::Window::Windows::const_iterator iter = root_windows.begin(); iter != root_windows.end(); ++iter) { - for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { - aura::Window* container = Shell::GetContainer(*iter, - kSwitchableWindowContainerIds[i]); - DCHECK(observed_container_windows_.find(container) == - observed_container_windows_.end()); - container->AddObserver(this); - observed_container_windows_.insert(container); - } + aura::Window* container = Shell::GetContainer(*iter, + internal::kShellWindowId_DefaultContainer); + DCHECK(observed_container_windows_.find(container) == + observed_container_windows_.end()); + container->AddObserver(this); + observed_container_windows_.insert(container); } } @@ -213,8 +235,10 @@ void MaximizeModeWindowManager::RemoveWindowCreationObservers() { } void MaximizeModeWindowManager::DisplayConfigurationChanged() { + EnableBackdropBehindTopWindowOnEachDisplay(false); RemoveWindowCreationObservers(); AddWindowCreationObservers(); + EnableBackdropBehindTopWindowOnEachDisplay(true); } bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { @@ -222,5 +246,25 @@ bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { observed_container_windows_.end(); } +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; + aura::Window* container = Shell::GetContainer( + controller->root_window(), + internal::kShellWindowId_DefaultContainer); + controller->workspace_controller()->SetMaximizeBackdropDelegate( + scoped_ptr( + enable ? new WorkspaceBackdropDelegate(container) : NULL)); + } +} + } // namespace internal } // namespace ash -- cgit v1.1