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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 void MaximizeModeWindowManager::OnWindowBoundsChanged( | 140 void MaximizeModeWindowManager::OnWindowBoundsChanged( |
141 aura::Window* window, | 141 aura::Window* window, |
142 const gfx::Rect& old_bounds, | 142 const gfx::Rect& old_bounds, |
143 const gfx::Rect& new_bounds) { | 143 const gfx::Rect& new_bounds) { |
144 if (!IsContainerWindow(window)) | 144 if (!IsContainerWindow(window)) |
145 return; | 145 return; |
146 // Reposition all non maximizeable windows. | 146 // Reposition all non maximizeable windows. |
147 for (WindowToState::iterator it = window_state_map_.begin(); | 147 for (WindowToState::iterator it = window_state_map_.begin(); |
148 it != window_state_map_.end(); | 148 it != window_state_map_.end(); ++it) { |
149 ++it) { | |
150 it->second->UpdateWindowPosition(wm::GetWindowState(it->first)); | 149 it->second->UpdateWindowPosition(wm::GetWindowState(it->first)); |
151 } | 150 } |
152 } | 151 } |
153 | 152 |
154 void MaximizeModeWindowManager::OnDisplayAdded( | 153 void MaximizeModeWindowManager::OnDisplayAdded( |
155 const display::Display& display) { | 154 const display::Display& display) { |
156 DisplayConfigurationChanged(); | 155 DisplayConfigurationChanged(); |
157 } | 156 } |
158 | 157 |
159 void MaximizeModeWindowManager::OnDisplayRemoved( | 158 void MaximizeModeWindowManager::OnDisplayRemoved( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return; | 200 return; |
202 } | 201 } |
203 | 202 |
204 // Leave full screen mode. | 203 // Leave full screen mode. |
205 event->StopPropagation(); | 204 event->StopPropagation(); |
206 wm::WMEvent toggle_fullscreen(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 205 wm::WMEvent toggle_fullscreen(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
207 window_state->OnWMEvent(&toggle_fullscreen); | 206 window_state->OnWMEvent(&toggle_fullscreen); |
208 } | 207 } |
209 | 208 |
210 MaximizeModeWindowManager::MaximizeModeWindowManager() | 209 MaximizeModeWindowManager::MaximizeModeWindowManager() |
211 : backdrops_hidden_(false) { | 210 : backdrops_hidden_(false) { |
212 // The overview mode needs to be ended before the maximize mode is started. To | 211 // The overview mode needs to be ended before the maximize mode is started. To |
213 // guarantee the proper order, it will be turned off from here. | 212 // guarantee the proper order, it will be turned off from here. |
214 CancelOverview(); | 213 CancelOverview(); |
215 | 214 |
216 MaximizeAllWindows(); | 215 MaximizeAllWindows(); |
217 AddWindowCreationObservers(); | 216 AddWindowCreationObservers(); |
218 EnableBackdropBehindTopWindowOnEachDisplay(true); | 217 EnableBackdropBehindTopWindowOnEachDisplay(true); |
219 display::Screen::GetScreen()->AddObserver(this); | 218 display::Screen::GetScreen()->AddObserver(this); |
220 WmShell::Get()->AddShellObserver(this); | 219 WmShell::Get()->AddShellObserver(this); |
221 Shell::GetInstance()->AddPreTargetHandler(this); | 220 Shell::GetInstance()->AddPreTargetHandler(this); |
222 } | 221 } |
223 | 222 |
224 void MaximizeModeWindowManager::MaximizeAllWindows() { | 223 void MaximizeModeWindowManager::MaximizeAllWindows() { |
225 MruWindowTracker::WindowList windows = ash::Shell::GetInstance()-> | 224 MruWindowTracker::WindowList windows = ash::Shell::GetInstance() |
226 mru_window_tracker()->BuildWindowListIgnoreModal(); | 225 ->mru_window_tracker() |
| 226 ->BuildWindowListIgnoreModal(); |
227 // Add all existing Mru windows. | 227 // Add all existing Mru windows. |
228 for (WmWindow* window : windows) | 228 for (WmWindow* window : windows) |
229 MaximizeAndTrackWindow(WmWindowAura::GetAuraWindow(window)); | 229 MaximizeAndTrackWindow(WmWindowAura::GetAuraWindow(window)); |
230 } | 230 } |
231 | 231 |
232 void MaximizeModeWindowManager::RestoreAllWindows() { | 232 void MaximizeModeWindowManager::RestoreAllWindows() { |
233 while (window_state_map_.size()) | 233 while (window_state_map_.size()) |
234 ForgetWindow(window_state_map_.begin()->first); | 234 ForgetWindow(window_state_map_.begin()->first); |
235 } | 235 } |
236 | 236 |
237 void MaximizeModeWindowManager::SetDeferBoundsUpdates( | 237 void MaximizeModeWindowManager::SetDeferBoundsUpdates( |
238 bool defer_bounds_updates) { | 238 bool defer_bounds_updates) { |
239 for (WindowToState::iterator it = window_state_map_.begin(); | 239 for (WindowToState::iterator it = window_state_map_.begin(); |
240 it != window_state_map_.end(); | 240 it != window_state_map_.end(); ++it) { |
241 ++it) { | |
242 it->second->SetDeferBoundsUpdates(defer_bounds_updates); | 241 it->second->SetDeferBoundsUpdates(defer_bounds_updates); |
243 } | 242 } |
244 } | 243 } |
245 | 244 |
246 void MaximizeModeWindowManager::MaximizeAndTrackWindow( | 245 void MaximizeModeWindowManager::MaximizeAndTrackWindow(aura::Window* window) { |
247 aura::Window* window) { | |
248 if (!ShouldHandleWindow(window)) | 246 if (!ShouldHandleWindow(window)) |
249 return; | 247 return; |
250 | 248 |
251 DCHECK(window_state_map_.find(window) == window_state_map_.end()); | 249 DCHECK(window_state_map_.find(window) == window_state_map_.end()); |
252 window->AddObserver(this); | 250 window->AddObserver(this); |
253 | 251 |
254 // We create and remember a maximize mode state which will attach itself to | 252 // We create and remember a maximize mode state which will attach itself to |
255 // the provided state object. | 253 // the provided state object. |
256 window_state_map_[window] = new MaximizeModeWindowState(window, this); | 254 window_state_map_[window] = new MaximizeModeWindowState(window, this); |
257 } | 255 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 void MaximizeModeWindowManager::AddWindowCreationObservers() { | 287 void MaximizeModeWindowManager::AddWindowCreationObservers() { |
290 DCHECK(observed_container_windows_.empty()); | 288 DCHECK(observed_container_windows_.empty()); |
291 // Observe window activations/creations in the default containers on all root | 289 // Observe window activations/creations in the default containers on all root |
292 // windows. | 290 // windows. |
293 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 291 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
294 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | 292 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); |
295 iter != root_windows.end(); ++iter) { | 293 iter != root_windows.end(); ++iter) { |
296 aura::Window* container = | 294 aura::Window* container = |
297 Shell::GetContainer(*iter, kShellWindowId_DefaultContainer); | 295 Shell::GetContainer(*iter, kShellWindowId_DefaultContainer); |
298 DCHECK(observed_container_windows_.find(container) == | 296 DCHECK(observed_container_windows_.find(container) == |
299 observed_container_windows_.end()); | 297 observed_container_windows_.end()); |
300 container->AddObserver(this); | 298 container->AddObserver(this); |
301 observed_container_windows_.insert(container); | 299 observed_container_windows_.insert(container); |
302 } | 300 } |
303 } | 301 } |
304 | 302 |
305 void MaximizeModeWindowManager::RemoveWindowCreationObservers() { | 303 void MaximizeModeWindowManager::RemoveWindowCreationObservers() { |
306 for (std::set<aura::Window*>::iterator iter = | 304 for (std::set<aura::Window*>::iterator iter = |
307 observed_container_windows_.begin(); | 305 observed_container_windows_.begin(); |
308 iter != observed_container_windows_.end(); ++iter) { | 306 iter != observed_container_windows_.end(); ++iter) { |
309 (*iter)->RemoveObserver(this); | 307 (*iter)->RemoveObserver(this); |
310 } | 308 } |
311 observed_container_windows_.clear(); | 309 observed_container_windows_.clear(); |
312 } | 310 } |
313 | 311 |
314 void MaximizeModeWindowManager::DisplayConfigurationChanged() { | 312 void MaximizeModeWindowManager::DisplayConfigurationChanged() { |
315 EnableBackdropBehindTopWindowOnEachDisplay(false); | 313 EnableBackdropBehindTopWindowOnEachDisplay(false); |
316 RemoveWindowCreationObservers(); | 314 RemoveWindowCreationObservers(); |
317 AddWindowCreationObservers(); | 315 AddWindowCreationObservers(); |
318 EnableBackdropBehindTopWindowOnEachDisplay(true); | 316 EnableBackdropBehindTopWindowOnEachDisplay(true); |
319 } | 317 } |
320 | 318 |
321 bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { | 319 bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) { |
322 return observed_container_windows_.find(window) != | 320 return observed_container_windows_.find(window) != |
323 observed_container_windows_.end(); | 321 observed_container_windows_.end(); |
324 } | 322 } |
325 | 323 |
326 void MaximizeModeWindowManager::EnableBackdropBehindTopWindowOnEachDisplay( | 324 void MaximizeModeWindowManager::EnableBackdropBehindTopWindowOnEachDisplay( |
327 bool enable) { | 325 bool enable) { |
328 // This function should be a no-op if backdrops have been disabled. | 326 // This function should be a no-op if backdrops have been disabled. |
329 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 327 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
330 switches::kAshDisableMaximizeModeWindowBackdrop)) { | 328 switches::kAshDisableMaximizeModeWindowBackdrop)) { |
331 return; | 329 return; |
332 } | 330 } |
333 | 331 |
334 if (backdrops_hidden_) | 332 if (backdrops_hidden_) |
335 return; | 333 return; |
336 | 334 |
337 // Inform the WorkspaceLayoutManager that we want to show a backdrop behind | 335 // Inform the WorkspaceLayoutManager that we want to show a backdrop behind |
338 // the topmost window of its container. | 336 // the topmost window of its container. |
339 Shell::RootWindowControllerList controllers = | 337 Shell::RootWindowControllerList controllers = |
340 Shell::GetAllRootWindowControllers(); | 338 Shell::GetAllRootWindowControllers(); |
341 for (Shell::RootWindowControllerList::iterator iter = controllers.begin(); | 339 for (Shell::RootWindowControllerList::iterator iter = controllers.begin(); |
342 iter != controllers.end(); ++iter) { | 340 iter != controllers.end(); ++iter) { |
343 RootWindowController* controller = *iter; | 341 RootWindowController* controller = *iter; |
344 aura::Window* container = Shell::GetContainer( | 342 aura::Window* container = Shell::GetContainer( |
345 controller->GetRootWindow(), kShellWindowId_DefaultContainer); | 343 controller->GetRootWindow(), kShellWindowId_DefaultContainer); |
346 controller->workspace_controller()->SetMaximizeBackdropDelegate( | 344 controller->workspace_controller()->SetMaximizeBackdropDelegate( |
347 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate>( | 345 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate>( |
348 enable ? new WorkspaceBackdropDelegate(container) : NULL)); | 346 enable ? new WorkspaceBackdropDelegate(container) : NULL)); |
349 } | 347 } |
350 } | 348 } |
351 | 349 |
352 } // namespace ash | 350 } // namespace ash |
OLD | NEW |