| 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/common/wm/maximize_mode/maximize_mode_window_manager.h" | 5 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 controller->OnSelectionEnded(); | 35 controller->OnSelectionEnded(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 MaximizeModeWindowManager::~MaximizeModeWindowManager() { | 40 MaximizeModeWindowManager::~MaximizeModeWindowManager() { |
| 41 // Overview mode needs to be ended before exiting maximize mode to prevent | 41 // Overview mode needs to be ended before exiting maximize mode to prevent |
| 42 // transforming windows which are currently in | 42 // transforming windows which are currently in |
| 43 // overview: http://crbug.com/366605 | 43 // overview: http://crbug.com/366605 |
| 44 CancelOverview(); | 44 CancelOverview(); |
| 45 | 45 for (auto* window : added_windows_) |
| 46 window->RemoveObserver(this); |
| 47 added_windows_.clear(); |
| 46 WmShell::Get()->RemoveShellObserver(this); | 48 WmShell::Get()->RemoveShellObserver(this); |
| 47 display::Screen::GetScreen()->RemoveObserver(this); | 49 display::Screen::GetScreen()->RemoveObserver(this); |
| 48 EnableBackdropBehindTopWindowOnEachDisplay(false); | 50 EnableBackdropBehindTopWindowOnEachDisplay(false); |
| 49 RemoveWindowCreationObservers(); | 51 RemoveWindowCreationObservers(); |
| 50 RestoreAllWindows(); | 52 RestoreAllWindows(); |
| 51 } | 53 } |
| 52 | 54 |
| 53 int MaximizeModeWindowManager::GetNumberOfManagedWindows() { | 55 int MaximizeModeWindowManager::GetNumberOfManagedWindows() { |
| 54 return window_state_map_.size(); | 56 return window_state_map_.size(); |
| 55 } | 57 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 backdrops_hidden_ = false; | 94 backdrops_hidden_ = false; |
| 93 EnableBackdropBehindTopWindowOnEachDisplay(true); | 95 EnableBackdropBehindTopWindowOnEachDisplay(true); |
| 94 SetDeferBoundsUpdates(false); | 96 SetDeferBoundsUpdates(false); |
| 95 } | 97 } |
| 96 | 98 |
| 97 void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) { | 99 void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) { |
| 98 if (IsContainerWindow(window)) { | 100 if (IsContainerWindow(window)) { |
| 99 // container window can be removed on display destruction. | 101 // container window can be removed on display destruction. |
| 100 window->RemoveObserver(this); | 102 window->RemoveObserver(this); |
| 101 observed_container_windows_.erase(window); | 103 observed_container_windows_.erase(window); |
| 104 } else if (base::ContainsValue(added_windows_, window)) { |
| 105 // Added window was destroyed before being shown. |
| 106 added_windows_.erase(window); |
| 107 window->RemoveObserver(this); |
| 102 } else { | 108 } else { |
| 103 // If a known window gets destroyed we need to remove all knowledge about | 109 // If a known window gets destroyed we need to remove all knowledge about |
| 104 // it. | 110 // it. |
| 105 ForgetWindow(window); | 111 ForgetWindow(window); |
| 106 } | 112 } |
| 107 } | 113 } |
| 108 | 114 |
| 109 void MaximizeModeWindowManager::OnWindowTreeChanged( | 115 void MaximizeModeWindowManager::OnWindowTreeChanged( |
| 110 WmWindow* window, | 116 WmWindow* window, |
| 111 const TreeChangeParams& params) { | 117 const TreeChangeParams& params) { |
| 112 // A window can get removed and then re-added by a drag and drop operation. | 118 // A window can get removed and then re-added by a drag and drop operation. |
| 113 if (params.new_parent && IsContainerWindow(params.new_parent) && | 119 if (params.new_parent && IsContainerWindow(params.new_parent) && |
| 114 !base::ContainsKey(window_state_map_, params.target)) { | 120 !base::ContainsKey(window_state_map_, params.target)) { |
| 121 // Don't register the window if the window is invisible. Instead, |
| 122 // wait until it becomes visible because the client may update the |
| 123 // flag to control if the window should be added. |
| 124 if (!params.target->IsVisible()) { |
| 125 if (!base::ContainsValue(added_windows_, params.target)) { |
| 126 added_windows_.insert(params.target); |
| 127 params.target->AddObserver(this); |
| 128 } |
| 129 return; |
| 130 } |
| 115 MaximizeAndTrackWindow(params.target); | 131 MaximizeAndTrackWindow(params.target); |
| 116 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got | 132 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got |
| 117 // already sent and we have to notify our state again. | 133 // already sent and we have to notify our state again. |
| 118 if (base::ContainsKey(window_state_map_, params.target)) { | 134 if (base::ContainsKey(window_state_map_, params.target)) { |
| 119 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); | 135 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); |
| 120 params.target->GetWindowState()->OnWMEvent(&event); | 136 params.target->GetWindowState()->OnWMEvent(&event); |
| 121 } | 137 } |
| 122 } | 138 } |
| 123 } | 139 } |
| 124 | 140 |
| 125 void MaximizeModeWindowManager::OnWindowPropertyChanged( | 141 void MaximizeModeWindowManager::OnWindowPropertyChanged( |
| 126 WmWindow* window, | 142 WmWindow* window, |
| 127 WmWindowProperty property) { | 143 WmWindowProperty property) { |
| 128 // Stop managing |window| if the always-on-top property is added. | 144 // Stop managing |window| if the always-on-top property is added. |
| 129 if (property == WmWindowProperty::ALWAYS_ON_TOP && window->IsAlwaysOnTop()) | 145 if (property == WmWindowProperty::ALWAYS_ON_TOP && window->IsAlwaysOnTop()) |
| 130 ForgetWindow(window); | 146 ForgetWindow(window); |
| 131 } | 147 } |
| 132 | 148 |
| 133 void MaximizeModeWindowManager::OnWindowBoundsChanged( | 149 void MaximizeModeWindowManager::OnWindowBoundsChanged( |
| 134 WmWindow* window, | 150 WmWindow* window, |
| 135 const gfx::Rect& old_bounds, | 151 const gfx::Rect& old_bounds, |
| 136 const gfx::Rect& new_bounds) { | 152 const gfx::Rect& new_bounds) { |
| 137 if (!IsContainerWindow(window)) | 153 if (!IsContainerWindow(window)) |
| 138 return; | 154 return; |
| 139 // Reposition all non maximizeable windows. | 155 // Reposition all non maximizeable windows. |
| 140 for (auto& pair : window_state_map_) | 156 for (auto& pair : window_state_map_) |
| 141 pair.second->UpdateWindowPosition(pair.first->GetWindowState()); | 157 pair.second->UpdateWindowPosition(pair.first->GetWindowState()); |
| 142 } | 158 } |
| 143 | 159 |
| 160 void MaximizeModeWindowManager::OnWindowVisibilityChanged(WmWindow* window, |
| 161 bool visible) { |
| 162 // Skip if it's already managed. |
| 163 if (base::ContainsKey(window_state_map_, window)) |
| 164 return; |
| 165 |
| 166 if (IsContainerWindow(window->GetParent()) && |
| 167 base::ContainsValue(added_windows_, window) && visible) { |
| 168 added_windows_.erase(window); |
| 169 window->RemoveObserver(this); |
| 170 MaximizeAndTrackWindow(window); |
| 171 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got |
| 172 // already sent and we have to notify our state again. |
| 173 if (base::ContainsKey(window_state_map_, window)) { |
| 174 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); |
| 175 window->GetWindowState()->OnWMEvent(&event); |
| 176 } |
| 177 } |
| 178 } |
| 179 |
| 144 void MaximizeModeWindowManager::OnDisplayAdded( | 180 void MaximizeModeWindowManager::OnDisplayAdded( |
| 145 const display::Display& display) { | 181 const display::Display& display) { |
| 146 DisplayConfigurationChanged(); | 182 DisplayConfigurationChanged(); |
| 147 } | 183 } |
| 148 | 184 |
| 149 void MaximizeModeWindowManager::OnDisplayRemoved( | 185 void MaximizeModeWindowManager::OnDisplayRemoved( |
| 150 const display::Display& display) { | 186 const display::Display& display) { |
| 151 DisplayConfigurationChanged(); | 187 DisplayConfigurationChanged(); |
| 152 } | 188 } |
| 153 | 189 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { | 318 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { |
| 283 WmRootWindowController* controller = root->GetRootWindowController(); | 319 WmRootWindowController* controller = root->GetRootWindowController(); |
| 284 WmWindow* default_container = | 320 WmWindow* default_container = |
| 285 root->GetChildByShellWindowId(kShellWindowId_DefaultContainer); | 321 root->GetChildByShellWindowId(kShellWindowId_DefaultContainer); |
| 286 controller->SetMaximizeBackdropDelegate(base::WrapUnique( | 322 controller->SetMaximizeBackdropDelegate(base::WrapUnique( |
| 287 enable ? new WorkspaceBackdropDelegate(default_container) : nullptr)); | 323 enable ? new WorkspaceBackdropDelegate(default_container) : nullptr)); |
| 288 } | 324 } |
| 289 } | 325 } |
| 290 | 326 |
| 291 } // namespace ash | 327 } // namespace ash |
| OLD | NEW |