Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/workspace/workspace_layout_manager.h" | 5 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | |
| 11 #include "ash/common/wm/always_on_top_controller.h" | 12 #include "ash/common/wm/always_on_top_controller.h" |
| 12 #include "ash/common/wm/fullscreen_window_finder.h" | 13 #include "ash/common/wm/fullscreen_window_finder.h" |
| 13 #include "ash/common/wm/window_positioner.h" | 14 #include "ash/common/wm/window_positioner.h" |
| 14 #include "ash/common/wm/window_state.h" | 15 #include "ash/common/wm/window_state.h" |
| 15 #include "ash/common/wm/wm_event.h" | 16 #include "ash/common/wm/wm_event.h" |
| 16 #include "ash/common/wm/wm_screen_util.h" | 17 #include "ash/common/wm/wm_screen_util.h" |
| 17 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" | 18 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" |
| 18 #include "ash/common/wm/workspace/workspace_layout_manager_delegate.h" | |
| 19 #include "ash/common/wm_root_window_controller.h" | 19 #include "ash/common/wm_root_window_controller.h" |
| 20 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
| 21 #include "ash/common/wm_window.h" | 21 #include "ash/common/wm_window.h" |
| 22 #include "ash/common/wm_window_property.h" | 22 #include "ash/common/wm_window_property.h" |
| 23 #include "base/command_line.h" | 23 #include "base/command_line.h" |
| 24 #include "ui/compositor/layer.h" | 24 #include "ui/compositor/layer.h" |
| 25 #include "ui/keyboard/keyboard_controller.h" | 25 #include "ui/keyboard/keyboard_controller.h" |
| 26 #include "ui/keyboard/keyboard_controller_observer.h" | 26 #include "ui/keyboard/keyboard_controller_observer.h" |
| 27 | 27 |
| 28 namespace ash { | 28 namespace ash { |
| 29 | 29 |
| 30 WorkspaceLayoutManager::WorkspaceLayoutManager( | 30 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window) |
| 31 WmWindow* window, | |
| 32 std::unique_ptr<wm::WorkspaceLayoutManagerDelegate> delegate) | |
| 33 : window_(window), | 31 : window_(window), |
| 34 root_window_(window->GetRootWindow()), | 32 root_window_(window->GetRootWindow()), |
| 35 root_window_controller_(root_window_->GetRootWindowController()), | 33 root_window_controller_(root_window_->GetRootWindowController()), |
| 36 shell_(window_->GetShell()), | 34 shell_(window_->GetShell()), |
| 37 delegate_(std::move(delegate)), | |
| 38 work_area_in_parent_(wm::GetDisplayWorkAreaBounds(window_)), | 35 work_area_in_parent_(wm::GetDisplayWorkAreaBounds(window_)), |
| 39 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) { | 36 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) { |
| 40 shell_->AddShellObserver(this); | 37 shell_->AddShellObserver(this); |
| 41 shell_->AddActivationObserver(this); | 38 shell_->AddActivationObserver(this); |
| 42 root_window_->AddObserver(this); | 39 root_window_->AddObserver(this); |
| 43 root_window_controller_->AddObserver(this); | 40 root_window_controller_->AddObserver(this); |
| 44 DCHECK(window->GetBoolProperty( | 41 DCHECK(window->GetBoolProperty( |
| 45 WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); | 42 WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); |
| 46 } | 43 } |
| 47 | 44 |
| 48 WorkspaceLayoutManager::~WorkspaceLayoutManager() { | 45 WorkspaceLayoutManager::~WorkspaceLayoutManager() { |
| 49 if (root_window_) | 46 if (root_window_) |
| 50 root_window_->RemoveObserver(this); | 47 root_window_->RemoveObserver(this); |
| 51 for (WmWindow* window : windows_) { | 48 for (WmWindow* window : windows_) { |
| 52 wm::WindowState* window_state = window->GetWindowState(); | 49 wm::WindowState* window_state = window->GetWindowState(); |
| 53 window_state->RemoveObserver(this); | 50 window_state->RemoveObserver(this); |
| 54 window->RemoveObserver(this); | 51 window->RemoveObserver(this); |
| 55 } | 52 } |
| 56 root_window_->GetRootWindowController()->RemoveObserver(this); | 53 root_window_->GetRootWindowController()->RemoveObserver(this); |
| 57 shell_->RemoveActivationObserver(this); | 54 shell_->RemoveActivationObserver(this); |
| 58 shell_->RemoveShellObserver(this); | 55 shell_->RemoveShellObserver(this); |
| 59 } | 56 } |
| 60 | 57 |
| 61 void WorkspaceLayoutManager::DeleteDelegate() { | |
| 62 delegate_.reset(); | |
| 63 } | |
| 64 | |
| 65 void WorkspaceLayoutManager::SetMaximizeBackdropDelegate( | 58 void WorkspaceLayoutManager::SetMaximizeBackdropDelegate( |
| 66 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { | 59 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { |
| 67 backdrop_delegate_.reset(delegate.release()); | 60 backdrop_delegate_.reset(delegate.release()); |
| 68 } | 61 } |
| 69 | 62 |
| 70 ////////////////////////////////////////////////////////////////////////////// | 63 ////////////////////////////////////////////////////////////////////////////// |
| 71 // WorkspaceLayoutManager, aura::LayoutManager implementation: | 64 // WorkspaceLayoutManager, aura::LayoutManager implementation: |
| 72 | 65 |
| 73 void WorkspaceLayoutManager::OnWindowResized() {} | 66 void WorkspaceLayoutManager::OnWindowResized() {} |
| 74 | 67 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 // If a user plugs an external display into a laptop running Aura the | 331 // If a user plugs an external display into a laptop running Aura the |
| 339 // display size will change. Maximized windows need to resize to match. | 332 // display size will change. Maximized windows need to resize to match. |
| 340 // We also do this when developers running Aura on a desktop manually resize | 333 // We also do this when developers running Aura on a desktop manually resize |
| 341 // the host window. | 334 // the host window. |
| 342 // We also need to do this when the work area insets changes. | 335 // We also need to do this when the work area insets changes. |
| 343 for (WmWindow* window : windows_) | 336 for (WmWindow* window : windows_) |
| 344 window->GetWindowState()->OnWMEvent(event); | 337 window->GetWindowState()->OnWMEvent(event); |
| 345 } | 338 } |
| 346 | 339 |
| 347 void WorkspaceLayoutManager::UpdateShelfVisibility() { | 340 void WorkspaceLayoutManager::UpdateShelfVisibility() { |
| 348 if (delegate_) | 341 if (root_window_controller_->GetShelf()) |
|
James Cook
2016/08/10 19:55:41
Maybe this should be HasShelf()? I'm not sure. It
msw
2016/08/10 20:47:40
Done.
| |
| 349 delegate_->UpdateShelfVisibility(); | 342 root_window_controller_->GetShelf()->UpdateVisibilityState(); |
| 350 } | 343 } |
| 351 | 344 |
| 352 void WorkspaceLayoutManager::UpdateFullscreenState() { | 345 void WorkspaceLayoutManager::UpdateFullscreenState() { |
| 353 // TODO(flackr): The fullscreen state is currently tracked per workspace | 346 // TODO(flackr): The fullscreen state is currently tracked per workspace |
| 354 // but the shell notification implies a per root window state. Currently | 347 // but the shell notification implies a per root window state. Currently |
| 355 // only windows in the default workspace container will go fullscreen but | 348 // only windows in the default workspace container will go fullscreen but |
| 356 // this should really be tracked by the RootWindowController since | 349 // this should really be tracked by the RootWindowController since |
| 357 // technically any container could get a fullscreen window. | 350 // technically any container could get a fullscreen window. |
| 358 if (!delegate_) | |
| 359 return; | |
| 360 bool is_fullscreen = wm::GetWindowForFullscreenMode(window_) != nullptr; | 351 bool is_fullscreen = wm::GetWindowForFullscreenMode(window_) != nullptr; |
| 361 if (is_fullscreen != is_fullscreen_) { | 352 if (is_fullscreen != is_fullscreen_) { |
| 362 delegate_->OnFullscreenStateChanged(is_fullscreen); | 353 WmShell::Get()->NotifyFullscreenStateChanged(is_fullscreen, root_window_); |
| 363 is_fullscreen_ = is_fullscreen; | 354 is_fullscreen_ = is_fullscreen; |
| 364 } | 355 } |
| 365 } | 356 } |
| 366 | 357 |
| 367 void WorkspaceLayoutManager::UpdateAlwaysOnTop(WmWindow* window_on_top) { | 358 void WorkspaceLayoutManager::UpdateAlwaysOnTop(WmWindow* window_on_top) { |
| 368 // Changing always on top state may change window's parent. Iterate on a copy | 359 // Changing always on top state may change window's parent. Iterate on a copy |
| 369 // of |windows_| to avoid invalidating an iterator. Since both workspace and | 360 // of |windows_| to avoid invalidating an iterator. Since both workspace and |
| 370 // always_on_top containers' layouts are managed by this class all the | 361 // always_on_top containers' layouts are managed by this class all the |
| 371 // appropriate windows will be included in the iteration. | 362 // appropriate windows will be included in the iteration. |
| 372 WindowSet windows(windows_); | 363 WindowSet windows(windows_); |
| 373 for (auto* window : windows) { | 364 for (auto* window : windows) { |
| 374 wm::WindowState* window_state = window->GetWindowState(); | 365 wm::WindowState* window_state = window->GetWindowState(); |
| 375 if (window_on_top) | 366 if (window_on_top) |
| 376 window_state->DisableAlwaysOnTop(window_on_top); | 367 window_state->DisableAlwaysOnTop(window_on_top); |
| 377 else | 368 else |
| 378 window_state->RestoreAlwaysOnTop(); | 369 window_state->RestoreAlwaysOnTop(); |
| 379 } | 370 } |
| 380 } | 371 } |
| 381 | 372 |
| 382 } // namespace ash | 373 } // namespace ash |
| OLD | NEW |