| 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" | |
| 14 #include "ash/wm/maximize_mode/maximize_mode_event_handler.h" | 13 #include "ash/wm/maximize_mode/maximize_mode_event_handler.h" |
| 15 #include "ash/wm/maximize_mode/maximize_mode_window_state.h" | 14 #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); |
| 85 SetDeferBoundsUpdates(true); | 89 SetDeferBoundsUpdates(true); |
| 90 backdrops_hidden_ = true; |
| 86 } | 91 } |
| 87 | 92 |
| 88 void MaximizeModeWindowManager::OnOverviewModeEnded() { | 93 void MaximizeModeWindowManager::OnOverviewModeEnded() { |
| 94 if (!backdrops_hidden_) |
| 95 return; |
| 96 |
| 97 backdrops_hidden_ = false; |
| 98 EnableBackdropBehindTopWindowOnEachDisplay(true); |
| 89 SetDeferBoundsUpdates(false); | 99 SetDeferBoundsUpdates(false); |
| 90 } | 100 } |
| 91 | 101 |
| 92 void MaximizeModeWindowManager::OnWindowDestroying(aura::Window* window) { | 102 void MaximizeModeWindowManager::OnWindowDestroying(aura::Window* window) { |
| 93 if (IsContainerWindow(window)) { | 103 if (IsContainerWindow(window)) { |
| 94 // container window can be removed on display destruction. | 104 // container window can be removed on display destruction. |
| 95 window->RemoveObserver(this); | 105 window->RemoveObserver(this); |
| 96 observed_container_windows_.erase(window); | 106 observed_container_windows_.erase(window); |
| 97 } else if (base::ContainsValue(added_windows_, window)) { | 107 } else if (base::ContainsValue(added_windows_, window)) { |
| 98 // Added window was destroyed before being shown. | 108 // Added window was destroyed before being shown. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 uint32_t) { | 195 uint32_t) { |
| 186 // Nothing to do here. | 196 // Nothing to do here. |
| 187 } | 197 } |
| 188 | 198 |
| 189 void MaximizeModeWindowManager::SetIgnoreWmEventsForExit() { | 199 void MaximizeModeWindowManager::SetIgnoreWmEventsForExit() { |
| 190 for (auto& pair : window_state_map_) { | 200 for (auto& pair : window_state_map_) { |
| 191 pair.second->set_ignore_wm_events(true); | 201 pair.second->set_ignore_wm_events(true); |
| 192 } | 202 } |
| 193 } | 203 } |
| 194 | 204 |
| 195 MaximizeModeWindowManager::MaximizeModeWindowManager() { | 205 MaximizeModeWindowManager::MaximizeModeWindowManager() |
| 206 : backdrops_hidden_(false) { |
| 196 // The overview mode needs to be ended before the maximize mode is started. To | 207 // The overview mode needs to be ended before the maximize mode is started. To |
| 197 // guarantee the proper order, it will be turned off from here. | 208 // guarantee the proper order, it will be turned off from here. |
| 198 CancelOverview(); | 209 CancelOverview(); |
| 199 | 210 |
| 200 MaximizeAllWindows(); | 211 MaximizeAllWindows(); |
| 201 AddWindowCreationObservers(); | 212 AddWindowCreationObservers(); |
| 202 EnableBackdropBehindTopWindowOnEachDisplay(true); | 213 EnableBackdropBehindTopWindowOnEachDisplay(true); |
| 203 display::Screen::GetScreen()->AddObserver(this); | 214 display::Screen::GetScreen()->AddObserver(this); |
| 204 Shell::Get()->AddShellObserver(this); | 215 Shell::Get()->AddShellObserver(this); |
| 205 event_handler_ = ShellPort::Get()->CreateMaximizeModeEventHandler(); | 216 event_handler_ = ShellPort::Get()->CreateMaximizeModeEventHandler(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 AddWindowCreationObservers(); | 303 AddWindowCreationObservers(); |
| 293 EnableBackdropBehindTopWindowOnEachDisplay(true); | 304 EnableBackdropBehindTopWindowOnEachDisplay(true); |
| 294 } | 305 } |
| 295 | 306 |
| 296 bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { | 307 bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { |
| 297 return base::ContainsKey(observed_container_windows_, window); | 308 return base::ContainsKey(observed_container_windows_, window); |
| 298 } | 309 } |
| 299 | 310 |
| 300 void MaximizeModeWindowManager::EnableBackdropBehindTopWindowOnEachDisplay( | 311 void MaximizeModeWindowManager::EnableBackdropBehindTopWindowOnEachDisplay( |
| 301 bool enable) { | 312 bool enable) { |
| 313 if (backdrops_hidden_) |
| 314 return; |
| 315 |
| 302 // Inform the WorkspaceLayoutManager that we want to show a backdrop behind | 316 // Inform the WorkspaceLayoutManager that we want to show a backdrop behind |
| 303 // the topmost window of its container. | 317 // the topmost window of its container. |
| 304 for (WmWindow* root : ShellPort::Get()->GetAllRootWindows()) { | 318 for (WmWindow* root : ShellPort::Get()->GetAllRootWindows()) { |
| 305 RootWindowController* controller = root->GetRootWindowController(); | 319 RootWindowController* controller = root->GetRootWindowController(); |
| 306 controller->workspace_controller()->SetBackdropDelegate( | 320 WmWindow* default_container = |
| 307 enable ? base::MakeUnique<MaximizeModeBackdropDelegateImpl>() | 321 root->GetChildByShellWindowId(kShellWindowId_DefaultContainer); |
| 322 controller->workspace_controller()->SetMaximizeBackdropDelegate( |
| 323 enable ? base::MakeUnique<WorkspaceBackdropDelegate>(default_container) |
| 308 : nullptr); | 324 : nullptr); |
| 309 } | 325 } |
| 310 } | 326 } |
| 311 | 327 |
| 312 } // namespace ash | 328 } // namespace ash |
| OLD | NEW |