maximize_mode_window_manager.cc revision a02191e04bc25c4935f804f2c080ae28663d096d
1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/wm/maximize_mode/maximize_mode_window_manager.h" 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/root_window_controller.h" 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/shell.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/shell_window_ids.h" 1023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ash/wm/maximize_mode/maximize_mode_window_state.h" 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/wm/mru_window_tracker.h" 1323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ash/wm/overview/window_selector_controller.h" 14a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "ash/wm/wm_event.h" 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/wm/workspace_controller.h" 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/window.h" 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/gfx/screen.h" 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace ash { 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)MaximizeModeWindowManager::~MaximizeModeWindowManager() { 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::GetInstance()->RemoveShellObserver(this); 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::GetScreen()->RemoveObserver(this); 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EnableBackdropBehindTopWindowOnEachDisplay(false); 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) RemoveWindowCreationObservers(); 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) RestoreAllWindows(); 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::GetInstance()->OnMaximizeModeEnded(); 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)int MaximizeModeWindowManager::GetNumberOfManagedWindows() { 3123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) return window_state_map_.size(); 3223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)} 3323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 3423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)void MaximizeModeWindowManager::WindowStateDestroyed(aura::Window* window) { 3523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // At this time ForgetWindow() should already have been called. If not, 3623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // someone else must have replaced the "window manager's state object". 3723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) DCHECK(!window->HasObserver(this)); 3823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 3923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) WindowToState::iterator it = window_state_map_.find(window); 4023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) DCHECK(it != window_state_map_.end()); 4123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) window_state_map_.erase(it); 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 44a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochvoid MaximizeModeWindowManager::OnOverviewModeStarting() { 45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (backdrops_hidden_) 46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EnableBackdropBehindTopWindowOnEachDisplay(false); 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) backdrops_hidden_ = true; 50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 52a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochvoid MaximizeModeWindowManager::OnOverviewModeEnding() { 53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!backdrops_hidden_) 54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) backdrops_hidden_ = false; 57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EnableBackdropBehindTopWindowOnEachDisplay(true); 58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::OnWindowDestroying(aura::Window* window) { 61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // If a known window gets destroyed we need to remove all knowledge about it. 62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!IsContainerWindow(window)) 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ForgetWindow(window); 64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 66a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochvoid MaximizeModeWindowManager::OnWindowAdded(aura::Window* window) { 67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // A window can get removed and then re-added by a drag and drop operation. 68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (IsContainerWindow(window->parent()) && 69a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch window_state_map_.find(window) == window_state_map_.end()) { 70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MaximizeAndTrackWindow(window); 71a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got 72a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // already sent and we have to notify our state again. 73a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch if (window_state_map_.find(window) != window_state_map_.end()) { 74a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); 75a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch wm::GetWindowState(window)->OnWMEvent(&event); 76a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch } 77a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch } 78a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 79a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 80a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::OnWindowBoundsChanged( 81a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* window, 82a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const gfx::Rect& old_bounds, 83a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const gfx::Rect& new_bounds) { 84a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!IsContainerWindow(window)) 85a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 86a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Reposition all non maximizeable windows. 8723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) for (WindowToState::iterator it = window_state_map_.begin(); 8823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) it != window_state_map_.end(); 89a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ++it) { 9023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) it->second->UpdateWindowPosition(wm::GetWindowState(it->first), false); 91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 92a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::OnDisplayBoundsChanged( 95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const gfx::Display& display) { 96a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Nothing to do here. 97a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::OnDisplayAdded(const gfx::Display& display) { 100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DisplayConfigurationChanged(); 101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::OnDisplayRemoved(const gfx::Display& display) { 104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DisplayConfigurationChanged(); 105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)MaximizeModeWindowManager::MaximizeModeWindowManager() 108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) : backdrops_hidden_(false) { 10923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // The overview mode needs to be ended before the maximize mode is started. To 11023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // guarantee the proper order, it will be turned off from here. 11123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) WindowSelectorController* controller = 11223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) Shell::GetInstance()->window_selector_controller(); 11323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) if (controller && controller->IsSelecting()) 11423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) controller->OnSelectionCanceled(); 11523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MaximizeAllWindows(); 117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) AddWindowCreationObservers(); 118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EnableBackdropBehindTopWindowOnEachDisplay(true); 119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::GetInstance()->OnMaximizeModeStarted(); 120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::GetScreen()->AddObserver(this); 121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::GetInstance()->AddShellObserver(this); 122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::MaximizeAllWindows() { 125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MruWindowTracker::WindowList windows = 126a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MruWindowTracker::BuildWindowList(false); 127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Add all existing Mru windows. 128a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (MruWindowTracker::WindowList::iterator window = windows.begin(); 129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window != windows.end(); ++window) { 130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MaximizeAndTrackWindow(*window); 131a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 132a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 134a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::RestoreAllWindows() { 13523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) while (window_state_map_.size()) 13623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) ForgetWindow(window_state_map_.begin()->first); 137a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 138a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 139a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::MaximizeAndTrackWindow( 140a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* window) { 141a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!ShouldHandleWindow(window)) 142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 14423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) DCHECK(window_state_map_.find(window) == window_state_map_.end()); 145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window->AddObserver(this); 146a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 14723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // We create and remember a maximize mode state which will attach itself to 14823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // the provided state object. 14923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) window_state_map_[window] = new MaximizeModeWindowState(window, this); 150a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 151a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 15223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)void MaximizeModeWindowManager::ForgetWindow(aura::Window* window) { 15323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) WindowToState::iterator it = window_state_map_.find(window); 15423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 15523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // The following DCHECK could fail if our window state object was destroyed 15623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // earlier by someone else. However - at this point there is no other client 15723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // which replaces the state object and therefore this should not happen. 15823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) DCHECK(it != window_state_map_.end()); 159a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) window->RemoveObserver(this); 16023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 16123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // By telling the state object to revert, it will switch back the old 16223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) // State object and destroy itself, calling WindowStateDerstroyed(). 16323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) it->second->LeaveMaximizeMode(wm::GetWindowState(it->first)); 16423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) DCHECK(window_state_map_.find(window) == window_state_map_.end()); 165a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 166a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 167a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool MaximizeModeWindowManager::ShouldHandleWindow(aura::Window* window) { 168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DCHECK(window); 169a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return window->type() == ui::wm::WINDOW_TYPE_NORMAL; 170a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 171a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 172a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::AddWindowCreationObservers() { 173a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DCHECK(observed_container_windows_.empty()); 174a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Observe window activations/creations in the default containers on all root 175a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // windows. 176a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 177a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (aura::Window::Windows::const_iterator iter = root_windows.begin(); 178a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) iter != root_windows.end(); ++iter) { 179c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch aura::Window* container = 180c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch Shell::GetContainer(*iter, kShellWindowId_DefaultContainer); 181a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DCHECK(observed_container_windows_.find(container) == 182a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) observed_container_windows_.end()); 183a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) container->AddObserver(this); 184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) observed_container_windows_.insert(container); 185a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 188a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::RemoveWindowCreationObservers() { 189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (std::set<aura::Window*>::iterator iter = 190a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) observed_container_windows_.begin(); 191a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) iter != observed_container_windows_.end(); ++iter) { 192a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) (*iter)->RemoveObserver(this); 193a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 194a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) observed_container_windows_.clear(); 195a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 196a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 197a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::DisplayConfigurationChanged() { 198a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EnableBackdropBehindTopWindowOnEachDisplay(false); 199a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) RemoveWindowCreationObservers(); 200a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) AddWindowCreationObservers(); 201a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EnableBackdropBehindTopWindowOnEachDisplay(true); 202a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 203a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 204a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { 205a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return observed_container_windows_.find(window) != 206a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) observed_container_windows_.end(); 207a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 208a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 209a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void MaximizeModeWindowManager::EnableBackdropBehindTopWindowOnEachDisplay( 210a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool enable) { 211a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (backdrops_hidden_) 212a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 213a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Inform the WorkspaceLayoutManager that we want to show a backdrop behind 214a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // the topmost window of its container. 215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::RootWindowControllerList controllers = 216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Shell::GetAllRootWindowControllers(); 217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (Shell::RootWindowControllerList::iterator iter = controllers.begin(); 218a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) iter != controllers.end(); ++iter) { 219a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) RootWindowController* controller = *iter; 220a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* container = Shell::GetContainer( 221a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch controller->GetRootWindow(), kShellWindowId_DefaultContainer); 222a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) controller->workspace_controller()->SetMaximizeBackdropDelegate( 223a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<WorkspaceLayoutManagerDelegate>( 224a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) enable ? new WorkspaceBackdropDelegate(container) : NULL)); 225a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 226a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 228a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace ash 229