| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_root_window_controller.h" | 5 #include "ash/common/wm_root_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/shell_window_ids.h" | 7 #include "ash/common/shell_window_ids.h" |
| 8 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 9 #include "ash/common/wallpaper/wallpaper_widget_controller.h" |
| 8 #include "ash/common/wm/root_window_layout_manager.h" | 10 #include "ash/common/wm/root_window_layout_manager.h" |
| 9 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 11 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 10 #include "ash/common/wm/workspace_controller.h" | 12 #include "ash/common/wm/workspace_controller.h" |
| 11 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 12 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
| 13 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 14 | 16 |
| 15 namespace ash { | 17 namespace ash { |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 // Creates a new window for use as a container. | 20 // Creates a new window for use as a container. |
| 19 WmWindow* CreateContainer(int window_id, const char* name, WmWindow* parent) { | 21 WmWindow* CreateContainer(int window_id, const char* name, WmWindow* parent) { |
| 20 WmWindow* window = WmShell::Get()->NewContainerWindow(); | 22 WmWindow* window = WmShell::Get()->NewContainerWindow(); |
| 21 window->SetShellWindowId(window_id); | 23 window->SetShellWindowId(window_id); |
| 22 window->SetName(name); | 24 window->SetName(name); |
| 23 parent->AddChild(window); | 25 parent->AddChild(window); |
| 24 if (window_id != kShellWindowId_UnparentedControlContainer) | 26 if (window_id != kShellWindowId_UnparentedControlContainer) |
| 25 window->Show(); | 27 window->Show(); |
| 26 return window; | 28 return window; |
| 27 } | 29 } |
| 28 | 30 |
| 29 } // namespace | 31 } // namespace |
| 30 | 32 |
| 31 WmRootWindowController::WmRootWindowController(WmWindow* root) | 33 WmRootWindowController::WmRootWindowController(WmWindow* root) |
| 32 : root_(root), root_window_layout_manager_(nullptr) {} | 34 : root_(root), root_window_layout_manager_(nullptr) {} |
| 33 | 35 |
| 34 WmRootWindowController::~WmRootWindowController() {} | 36 WmRootWindowController::~WmRootWindowController() { |
| 37 if (animating_wallpaper_widget_controller_.get()) |
| 38 animating_wallpaper_widget_controller_->StopAnimating(); |
| 39 } |
| 40 |
| 41 void WmRootWindowController::SetWallpaperWidgetController( |
| 42 WallpaperWidgetController* controller) { |
| 43 wallpaper_widget_controller_.reset(controller); |
| 44 } |
| 45 |
| 46 void WmRootWindowController::SetAnimatingWallpaperWidgetController( |
| 47 AnimatingWallpaperWidgetController* controller) { |
| 48 if (animating_wallpaper_widget_controller_.get()) |
| 49 animating_wallpaper_widget_controller_->StopAnimating(); |
| 50 animating_wallpaper_widget_controller_.reset(controller); |
| 51 } |
| 35 | 52 |
| 36 wm::WorkspaceWindowState WmRootWindowController::GetWorkspaceWindowState() { | 53 wm::WorkspaceWindowState WmRootWindowController::GetWorkspaceWindowState() { |
| 37 return workspace_controller_ ? workspace_controller()->GetWindowState() | 54 return workspace_controller_ ? workspace_controller()->GetWindowState() |
| 38 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; | 55 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| 39 } | 56 } |
| 40 | 57 |
| 58 void WmRootWindowController::OnInitialWallpaperAnimationStarted() {} |
| 59 |
| 60 void WmRootWindowController::OnWallpaperAnimationFinished( |
| 61 views::Widget* widget) { |
| 62 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished(); |
| 63 // Only removes old component when wallpaper animation finished. If we |
| 64 // remove the old one before the new wallpaper is done fading in there will |
| 65 // be a white flash during the animation. |
| 66 if (animating_wallpaper_widget_controller()) { |
| 67 WallpaperWidgetController* controller = |
| 68 animating_wallpaper_widget_controller()->GetController(true); |
| 69 DCHECK_EQ(controller->widget(), widget); |
| 70 // Release the old controller and close its wallpaper widget. |
| 71 SetWallpaperWidgetController(controller); |
| 72 } |
| 73 } |
| 74 |
| 41 void WmRootWindowController::CreateContainers() { | 75 void WmRootWindowController::CreateContainers() { |
| 42 // These containers are just used by PowerButtonController to animate groups | 76 // These containers are just used by PowerButtonController to animate groups |
| 43 // of containers simultaneously without messing up the current transformations | 77 // of containers simultaneously without messing up the current transformations |
| 44 // on those containers. These are direct children of the root window; all of | 78 // on those containers. These are direct children of the root window; all of |
| 45 // the other containers are their children. | 79 // the other containers are their children. |
| 46 | 80 |
| 47 // The wallpaper container is not part of the lock animation, so it is not | 81 // The wallpaper container is not part of the lock animation, so it is not |
| 48 // included in those animate groups. When the screen is locked, the wallpaper | 82 // included in those animate groups. When the screen is locked, the wallpaper |
| 49 // is moved to the lock screen wallpaper container (and moved back on unlock). | 83 // is moved to the lock screen wallpaper container (and moved back on unlock). |
| 50 // Ensure that there's an opaque layer occluding the non-lock-screen layers. | 84 // Ensure that there's an opaque layer occluding the non-lock-screen layers. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 WmWindow* default_container = | 257 WmWindow* default_container = |
| 224 root_->GetChildByShellWindowId(kShellWindowId_DefaultContainer); | 258 root_->GetChildByShellWindowId(kShellWindowId_DefaultContainer); |
| 225 workspace_controller_.reset(new WorkspaceController(default_container)); | 259 workspace_controller_.reset(new WorkspaceController(default_container)); |
| 226 } | 260 } |
| 227 | 261 |
| 228 void WmRootWindowController::DeleteWorkspaceController() { | 262 void WmRootWindowController::DeleteWorkspaceController() { |
| 229 workspace_controller_.reset(); | 263 workspace_controller_.reset(); |
| 230 } | 264 } |
| 231 | 265 |
| 232 } // namespace ash | 266 } // namespace ash |
| OLD | NEW |