| 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/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| 11 #include "ash/common/wm/always_on_top_controller.h" | 11 #include "ash/common/wm/always_on_top_controller.h" |
| 12 #include "ash/common/wm/fullscreen_window_finder.h" | 12 #include "ash/common/wm/fullscreen_window_finder.h" |
| 13 #include "ash/common/wm/window_positioner.h" | 13 #include "ash/common/wm/window_positioner.h" |
| 14 #include "ash/common/wm/window_state.h" | 14 #include "ash/common/wm/window_state.h" |
| 15 #include "ash/common/wm/wm_event.h" | 15 #include "ash/common/wm/wm_event.h" |
| 16 #include "ash/common/wm/wm_screen_util.h" | 16 #include "ash/common/wm/wm_screen_util.h" |
| 17 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" | 17 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" |
| 18 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 19 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
| 20 #include "ash/public/cpp/shell_window_ids.h" | 20 #include "ash/public/cpp/shell_window_ids.h" |
| 21 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
| 22 #include "ash/shell.h" |
| 22 #include "ash/wm/window_properties.h" | 23 #include "ash/wm/window_properties.h" |
| 23 #include "ash/wm/window_state_aura.h" | 24 #include "ash/wm/window_state_aura.h" |
| 24 #include "base/command_line.h" | 25 #include "base/command_line.h" |
| 25 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
| 26 #include "ui/base/ui_base_switches.h" | 27 #include "ui/base/ui_base_switches.h" |
| 27 #include "ui/compositor/layer.h" | 28 #include "ui/compositor/layer.h" |
| 28 #include "ui/display/display.h" | 29 #include "ui/display/display.h" |
| 29 #include "ui/display/screen.h" | 30 #include "ui/display/screen.h" |
| 30 #include "ui/keyboard/keyboard_controller.h" | 31 #include "ui/keyboard/keyboard_controller.h" |
| 31 #include "ui/keyboard/keyboard_controller_observer.h" | 32 #include "ui/keyboard/keyboard_controller_observer.h" |
| 33 #include "ui/wm/public/activation_client.h" |
| 32 | 34 |
| 33 namespace ash { | 35 namespace ash { |
| 34 | 36 |
| 35 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window) | 37 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window) |
| 36 : window_(window), | 38 : window_(window), |
| 37 root_window_(window->GetRootWindow()), | 39 root_window_(window->GetRootWindow()), |
| 38 root_window_controller_(root_window_->GetRootWindowController()), | 40 root_window_controller_(root_window_->GetRootWindowController()), |
| 39 shell_(window_->GetShell()), | 41 shell_(window_->GetShell()), |
| 40 work_area_in_parent_(wm::GetDisplayWorkAreaBoundsInParent(window_)), | 42 work_area_in_parent_(wm::GetDisplayWorkAreaBoundsInParent(window_)), |
| 41 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) { | 43 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) { |
| 42 shell_->AddShellObserver(this); | 44 shell_->AddShellObserver(this); |
| 43 shell_->AddActivationObserver(this); | 45 Shell::GetInstance()->activation_client()->AddObserver(this); |
| 44 root_window_->aura_window()->AddObserver(this); | 46 root_window_->aura_window()->AddObserver(this); |
| 45 display::Screen::GetScreen()->AddObserver(this); | 47 display::Screen::GetScreen()->AddObserver(this); |
| 46 DCHECK(window->aura_window()->GetProperty(kSnapChildrenToPixelBoundary)); | 48 DCHECK(window->aura_window()->GetProperty(kSnapChildrenToPixelBoundary)); |
| 47 } | 49 } |
| 48 | 50 |
| 49 WorkspaceLayoutManager::~WorkspaceLayoutManager() { | 51 WorkspaceLayoutManager::~WorkspaceLayoutManager() { |
| 50 if (root_window_) | 52 if (root_window_) |
| 51 root_window_->aura_window()->RemoveObserver(this); | 53 root_window_->aura_window()->RemoveObserver(this); |
| 52 for (WmWindow* window : windows_) { | 54 for (WmWindow* window : windows_) { |
| 53 wm::WindowState* window_state = window->GetWindowState(); | 55 wm::WindowState* window_state = window->GetWindowState(); |
| 54 window_state->RemoveObserver(this); | 56 window_state->RemoveObserver(this); |
| 55 window->aura_window()->RemoveObserver(this); | 57 window->aura_window()->RemoveObserver(this); |
| 56 } | 58 } |
| 57 display::Screen::GetScreen()->RemoveObserver(this); | 59 display::Screen::GetScreen()->RemoveObserver(this); |
| 58 shell_->RemoveActivationObserver(this); | 60 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
| 59 shell_->RemoveShellObserver(this); | 61 shell_->RemoveShellObserver(this); |
| 60 } | 62 } |
| 61 | 63 |
| 62 void WorkspaceLayoutManager::SetMaximizeBackdropDelegate( | 64 void WorkspaceLayoutManager::SetMaximizeBackdropDelegate( |
| 63 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { | 65 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { |
| 64 backdrop_delegate_ = std::move(delegate); | 66 backdrop_delegate_ = std::move(delegate); |
| 65 } | 67 } |
| 66 | 68 |
| 67 ////////////////////////////////////////////////////////////////////////////// | 69 ////////////////////////////////////////////////////////////////////////////// |
| 68 // WorkspaceLayoutManager, aura::LayoutManager implementation: | 70 // WorkspaceLayoutManager, aura::LayoutManager implementation: |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 if (root_window_ == WmWindow::Get(window)) { | 238 if (root_window_ == WmWindow::Get(window)) { |
| 237 const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); | 239 const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); |
| 238 AdjustAllWindowsBoundsForWorkAreaChange(&wm_event); | 240 AdjustAllWindowsBoundsForWorkAreaChange(&wm_event); |
| 239 } | 241 } |
| 240 } | 242 } |
| 241 | 243 |
| 242 ////////////////////////////////////////////////////////////////////////////// | 244 ////////////////////////////////////////////////////////////////////////////// |
| 243 // WorkspaceLayoutManager, | 245 // WorkspaceLayoutManager, |
| 244 // aura::client::ActivationChangeObserver implementation: | 246 // aura::client::ActivationChangeObserver implementation: |
| 245 | 247 |
| 246 void WorkspaceLayoutManager::OnWindowActivated(WmWindow* gained_active, | 248 void WorkspaceLayoutManager::OnWindowActivated(ActivationReason reason, |
| 247 WmWindow* lost_active) { | 249 aura::Window* gained_active, |
| 250 aura::Window* lost_active) { |
| 251 WmWindow* wm_gained_active = WmWindow::Get(gained_active); |
| 248 wm::WindowState* window_state = | 252 wm::WindowState* window_state = |
| 249 gained_active ? gained_active->GetWindowState() : nullptr; | 253 wm_gained_active ? wm_gained_active->GetWindowState() : nullptr; |
| 250 if (window_state && window_state->IsMinimized() && | 254 if (window_state && window_state->IsMinimized() && |
| 251 !gained_active->IsVisible()) { | 255 !wm_gained_active->IsVisible()) { |
| 252 window_state->Unminimize(); | 256 window_state->Unminimize(); |
| 253 DCHECK(!window_state->IsMinimized()); | 257 DCHECK(!window_state->IsMinimized()); |
| 254 } | 258 } |
| 255 UpdateFullscreenState(); | 259 UpdateFullscreenState(); |
| 256 UpdateShelfVisibility(); | 260 UpdateShelfVisibility(); |
| 257 } | 261 } |
| 258 | 262 |
| 259 ////////////////////////////////////////////////////////////////////////////// | 263 ////////////////////////////////////////////////////////////////////////////// |
| 260 // WorkspaceLayoutManager, wm::WindowStateObserver implementation: | 264 // WorkspaceLayoutManager, wm::WindowStateObserver implementation: |
| 261 | 265 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 for (auto* window : windows) { | 382 for (auto* window : windows) { |
| 379 wm::WindowState* window_state = window->GetWindowState(); | 383 wm::WindowState* window_state = window->GetWindowState(); |
| 380 if (window_on_top) | 384 if (window_on_top) |
| 381 window_state->DisableAlwaysOnTop(window_on_top); | 385 window_state->DisableAlwaysOnTop(window_on_top); |
| 382 else | 386 else |
| 383 window_state->RestoreAlwaysOnTop(); | 387 window_state->RestoreAlwaysOnTop(); |
| 384 } | 388 } |
| 385 } | 389 } |
| 386 | 390 |
| 387 } // namespace ash | 391 } // namespace ash |
| OLD | NEW |