| 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/wm/workspace_controller.h" | 5 #include "ash/common/wm/workspace_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| 11 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 11 #include "ash/common/wm/dock/docked_window_layout_manager.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_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 14 #include "ash/common/wm/wm_window_animations.h" | 14 #include "ash/common/wm/wm_window_animations.h" |
| 15 #include "ash/common/wm/workspace/workspace_event_handler.h" | 15 #include "ash/common/wm/workspace/workspace_event_handler.h" |
| 16 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 16 #include "ash/common/wm/workspace/workspace_layout_manager.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_root_window_controller.h" | 18 #include "ash/common/wm_root_window_controller.h" |
| 19 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 20 #include "ash/common/wm_window.h" | 20 #include "ash/common/wm_window.h" |
| 21 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
| 22 #include "ui/aura/client/aura_constants.h" | |
| 23 #include "ui/aura/window.h" | |
| 24 #include "ui/aura/window_event_dispatcher.h" | |
| 25 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
| 26 #include "ui/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 27 #include "ui/wm/core/visibility_controller.h" | |
| 28 #include "ui/wm/core/window_animations.h" | |
| 29 #include "ui/wm/public/activation_client.h" | |
| 30 | 24 |
| 31 namespace ash { | 25 namespace ash { |
| 32 namespace { | 26 namespace { |
| 33 | 27 |
| 34 // Amount of time to pause before animating anything. Only used during initial | 28 // Amount of time to pause before animating anything. Only used during initial |
| 35 // animation (when logging in). | 29 // animation (when logging in). |
| 36 const int kInitialPauseTimeMS = 750; | 30 const int kInitialPauseTimeMS = 750; |
| 37 | 31 |
| 38 // The duration of the animation that occurs on first login. | 32 // The duration of the animation that occurs on first login. |
| 39 const int kInitialAnimationDurationMS = 200; | 33 const int kInitialAnimationDurationMS = 200; |
| 40 | 34 |
| 41 } // namespace | 35 } // namespace |
| 42 | 36 |
| 43 WorkspaceController::WorkspaceController(WmWindow* viewport) | 37 WorkspaceController::WorkspaceController(WmWindow* viewport) |
| 44 : viewport_(viewport), | 38 : viewport_(viewport), |
| 45 event_handler_(WmShell::Get()->CreateWorkspaceEventHandler(viewport)), | 39 event_handler_(WmShell::Get()->CreateWorkspaceEventHandler(viewport)), |
| 46 layout_manager_(new WorkspaceLayoutManager(viewport)) { | 40 layout_manager_(new WorkspaceLayoutManager(viewport)) { |
| 41 viewport_->AddObserver(this); |
| 47 viewport_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 42 viewport_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
| 48 viewport_->SetLayoutManager(base::WrapUnique(layout_manager_)); | 43 viewport_->SetLayoutManager(base::WrapUnique(layout_manager_)); |
| 49 } | 44 } |
| 50 | 45 |
| 51 WorkspaceController::~WorkspaceController() { | 46 WorkspaceController::~WorkspaceController() { |
| 47 if (!viewport_) |
| 48 return; |
| 49 |
| 50 viewport_->RemoveObserver(this); |
| 52 viewport_->SetLayoutManager(nullptr); | 51 viewport_->SetLayoutManager(nullptr); |
| 53 } | 52 } |
| 54 | 53 |
| 55 wm::WorkspaceWindowState WorkspaceController::GetWindowState() const { | 54 wm::WorkspaceWindowState WorkspaceController::GetWindowState() const { |
| 56 if (!viewport_->GetRootWindowController()->HasShelf()) | 55 if (!viewport_->GetRootWindowController()->HasShelf()) |
| 57 return wm::WORKSPACE_WINDOW_STATE_DEFAULT; | 56 return wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| 58 | 57 |
| 59 const WmWindow* fullscreen = wm::GetWindowForFullscreenMode(viewport_); | 58 const WmWindow* fullscreen = wm::GetWindowForFullscreenMode(viewport_); |
| 60 if (fullscreen && !fullscreen->GetWindowState()->ignored_by_shelf()) | 59 if (fullscreen && !fullscreen->GetWindowState()->ignored_by_shelf()) |
| 61 return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; | 60 return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 layer->SetTransform(gfx::Transform()); | 116 layer->SetTransform(gfx::Transform()); |
| 118 layer->SetOpacity(1.0f); | 117 layer->SetOpacity(1.0f); |
| 119 } | 118 } |
| 120 } | 119 } |
| 121 | 120 |
| 122 void WorkspaceController::SetMaximizeBackdropDelegate( | 121 void WorkspaceController::SetMaximizeBackdropDelegate( |
| 123 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { | 122 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { |
| 124 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); | 123 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); |
| 125 } | 124 } |
| 126 | 125 |
| 126 void WorkspaceController::OnWindowDestroying(WmWindow* window) { |
| 127 DCHECK_EQ(window, viewport_); |
| 128 viewport_->RemoveObserver(this); |
| 129 viewport_ = nullptr; |
| 130 // Destroy |event_handler_| too as it depends upon |window|. |
| 131 event_handler_.reset(); |
| 132 } |
| 133 |
| 127 } // namespace ash | 134 } // namespace ash |
| OLD | NEW |