| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/public/cpp/shell_window_ids.h" | 8 #include "ash/public/cpp/shell_window_ids.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/shell_port.h" | 12 #include "ash/shell_port.h" |
| 13 #include "ash/wm/maximize_mode/maximize_mode_backdrop_delegate_impl.h" |
| 13 #include "ash/wm/maximize_mode/maximize_mode_event_handler.h" | 14 #include "ash/wm/maximize_mode/maximize_mode_event_handler.h" |
| 14 #include "ash/wm/maximize_mode/maximize_mode_window_state.h" | 15 #include "ash/wm/maximize_mode/maximize_mode_window_state.h" |
| 15 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" | |
| 16 #include "ash/wm/mru_window_tracker.h" | 16 #include "ash/wm/mru_window_tracker.h" |
| 17 #include "ash/wm/overview/window_selector_controller.h" | 17 #include "ash/wm/overview/window_selector_controller.h" |
| 18 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
| 19 #include "ash/wm/window_state_aura.h" | 19 #include "ash/wm/window_state_aura.h" |
| 20 #include "ash/wm/wm_event.h" | 20 #include "ash/wm/wm_event.h" |
| 21 #include "ash/wm/workspace_controller.h" | 21 #include "ash/wm/workspace_controller.h" |
| 22 #include "ash/wm_window.h" | 22 #include "ash/wm_window.h" |
| 23 #include "base/command_line.h" | 23 #include "base/command_line.h" |
| 24 #include "base/memory/ptr_util.h" | 24 #include "base/memory/ptr_util.h" |
| 25 #include "base/stl_util.h" | 25 #include "base/stl_util.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // At this time ForgetWindow() should already have been called. If not, | 75 // At this time ForgetWindow() should already have been called. If not, |
| 76 // someone else must have replaced the "window manager's state object". | 76 // someone else must have replaced the "window manager's state object". |
| 77 DCHECK(!window->aura_window()->HasObserver(this)); | 77 DCHECK(!window->aura_window()->HasObserver(this)); |
| 78 | 78 |
| 79 auto it = window_state_map_.find(window); | 79 auto it = window_state_map_.find(window); |
| 80 DCHECK(it != window_state_map_.end()); | 80 DCHECK(it != window_state_map_.end()); |
| 81 window_state_map_.erase(it); | 81 window_state_map_.erase(it); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void MaximizeModeWindowManager::OnOverviewModeStarting() { | 84 void MaximizeModeWindowManager::OnOverviewModeStarting() { |
| 85 if (backdrops_hidden_) | |
| 86 return; | |
| 87 | |
| 88 EnableBackdropBehindTopWindowOnEachDisplay(false); | |
| 89 SetDeferBoundsUpdates(true); | 85 SetDeferBoundsUpdates(true); |
| 90 backdrops_hidden_ = true; | |
| 91 } | 86 } |
| 92 | 87 |
| 93 void MaximizeModeWindowManager::OnOverviewModeEnded() { | 88 void MaximizeModeWindowManager::OnOverviewModeEnded() { |
| 94 if (!backdrops_hidden_) | |
| 95 return; | |
| 96 | |
| 97 backdrops_hidden_ = false; | |
| 98 EnableBackdropBehindTopWindowOnEachDisplay(true); | |
| 99 SetDeferBoundsUpdates(false); | 89 SetDeferBoundsUpdates(false); |
| 100 } | 90 } |
| 101 | 91 |
| 102 void MaximizeModeWindowManager::OnWindowDestroying(aura::Window* window) { | 92 void MaximizeModeWindowManager::OnWindowDestroying(aura::Window* window) { |
| 103 if (IsContainerWindow(window)) { | 93 if (IsContainerWindow(window)) { |
| 104 // container window can be removed on display destruction. | 94 // container window can be removed on display destruction. |
| 105 window->RemoveObserver(this); | 95 window->RemoveObserver(this); |
| 106 observed_container_windows_.erase(window); | 96 observed_container_windows_.erase(window); |
| 107 } else if (base::ContainsValue(added_windows_, window)) { | 97 } else if (base::ContainsValue(added_windows_, window)) { |
| 108 // Added window was destroyed before being shown. | 98 // Added window was destroyed before being shown. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 uint32_t) { | 185 uint32_t) { |
| 196 // Nothing to do here. | 186 // Nothing to do here. |
| 197 } | 187 } |
| 198 | 188 |
| 199 void MaximizeModeWindowManager::SetIgnoreWmEventsForExit() { | 189 void MaximizeModeWindowManager::SetIgnoreWmEventsForExit() { |
| 200 for (auto& pair : window_state_map_) { | 190 for (auto& pair : window_state_map_) { |
| 201 pair.second->set_ignore_wm_events(true); | 191 pair.second->set_ignore_wm_events(true); |
| 202 } | 192 } |
| 203 } | 193 } |
| 204 | 194 |
| 205 MaximizeModeWindowManager::MaximizeModeWindowManager() | 195 MaximizeModeWindowManager::MaximizeModeWindowManager() { |
| 206 : backdrops_hidden_(false) { | |
| 207 // The overview mode needs to be ended before the maximize mode is started. To | 196 // The overview mode needs to be ended before the maximize mode is started. To |
| 208 // guarantee the proper order, it will be turned off from here. | 197 // guarantee the proper order, it will be turned off from here. |
| 209 CancelOverview(); | 198 CancelOverview(); |
| 210 | 199 |
| 211 MaximizeAllWindows(); | 200 MaximizeAllWindows(); |
| 212 AddWindowCreationObservers(); | 201 AddWindowCreationObservers(); |
| 213 EnableBackdropBehindTopWindowOnEachDisplay(true); | 202 EnableBackdropBehindTopWindowOnEachDisplay(true); |
| 214 display::Screen::GetScreen()->AddObserver(this); | 203 display::Screen::GetScreen()->AddObserver(this); |
| 215 Shell::Get()->AddShellObserver(this); | 204 Shell::Get()->AddShellObserver(this); |
| 216 event_handler_ = ShellPort::Get()->CreateMaximizeModeEventHandler(); | 205 event_handler_ = ShellPort::Get()->CreateMaximizeModeEventHandler(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 AddWindowCreationObservers(); | 292 AddWindowCreationObservers(); |
| 304 EnableBackdropBehindTopWindowOnEachDisplay(true); | 293 EnableBackdropBehindTopWindowOnEachDisplay(true); |
| 305 } | 294 } |
| 306 | 295 |
| 307 bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { | 296 bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { |
| 308 return base::ContainsKey(observed_container_windows_, window); | 297 return base::ContainsKey(observed_container_windows_, window); |
| 309 } | 298 } |
| 310 | 299 |
| 311 void MaximizeModeWindowManager::EnableBackdropBehindTopWindowOnEachDisplay( | 300 void MaximizeModeWindowManager::EnableBackdropBehindTopWindowOnEachDisplay( |
| 312 bool enable) { | 301 bool enable) { |
| 313 if (backdrops_hidden_) | |
| 314 return; | |
| 315 | |
| 316 // Inform the WorkspaceLayoutManager that we want to show a backdrop behind | 302 // Inform the WorkspaceLayoutManager that we want to show a backdrop behind |
| 317 // the topmost window of its container. | 303 // the topmost window of its container. |
| 318 for (WmWindow* root : ShellPort::Get()->GetAllRootWindows()) { | 304 for (WmWindow* root : ShellPort::Get()->GetAllRootWindows()) { |
| 319 RootWindowController* controller = root->GetRootWindowController(); | 305 RootWindowController* controller = root->GetRootWindowController(); |
| 320 WmWindow* default_container = | 306 controller->workspace_controller()->SetBackdropDelegate( |
| 321 root->GetChildByShellWindowId(kShellWindowId_DefaultContainer); | 307 enable ? base::MakeUnique<MaximizeModeBackdropDelegateImpl>() |
| 322 controller->workspace_controller()->SetMaximizeBackdropDelegate( | |
| 323 enable ? base::MakeUnique<WorkspaceBackdropDelegate>(default_container) | |
| 324 : nullptr); | 308 : nullptr); |
| 325 } | 309 } |
| 326 } | 310 } |
| 327 | 311 |
| 328 } // namespace ash | 312 } // namespace ash |
| OLD | NEW |