| 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/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_layout_manager.h" | 16 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 16 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" | 17 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" |
| 17 #include "ash/common/wm_root_window_controller.h" | 18 #include "ash/common/wm_root_window_controller.h" |
| 19 #include "ash/common/wm_shell.h" |
| 18 #include "ash/common/wm_window.h" | 20 #include "ash/common/wm_window.h" |
| 19 #include "ash/wm/workspace/workspace_event_handler.h" | |
| 20 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
| 21 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
| 24 #include "ui/compositor/layer.h" | 25 #include "ui/compositor/layer.h" |
| 25 #include "ui/compositor/scoped_layer_animation_settings.h" | 26 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 26 #include "ui/wm/core/visibility_controller.h" | 27 #include "ui/wm/core/visibility_controller.h" |
| 27 #include "ui/wm/core/window_animations.h" | 28 #include "ui/wm/core/window_animations.h" |
| 28 #include "ui/wm/public/activation_client.h" | 29 #include "ui/wm/public/activation_client.h" |
| 29 | 30 |
| 30 namespace ash { | 31 namespace ash { |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // Amount of time to pause before animating anything. Only used during initial | 34 // Amount of time to pause before animating anything. Only used during initial |
| 34 // animation (when logging in). | 35 // animation (when logging in). |
| 35 const int kInitialPauseTimeMS = 750; | 36 const int kInitialPauseTimeMS = 750; |
| 36 | 37 |
| 37 // The duration of the animation that occurs on first login. | 38 // The duration of the animation that occurs on first login. |
| 38 const int kInitialAnimationDurationMS = 200; | 39 const int kInitialAnimationDurationMS = 200; |
| 39 | 40 |
| 40 } // namespace | 41 } // namespace |
| 41 | 42 |
| 42 WorkspaceController::WorkspaceController(WmWindow* viewport) | 43 WorkspaceController::WorkspaceController(WmWindow* viewport) |
| 43 : viewport_(viewport), | 44 : viewport_(viewport), |
| 44 event_handler_(new WorkspaceEventHandler), | 45 event_handler_(WmShell::Get()->CreateWorkspaceEventHandler(viewport)), |
| 45 layout_manager_(new WorkspaceLayoutManager(viewport)) { | 46 layout_manager_(new WorkspaceLayoutManager(viewport)) { |
| 46 viewport_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 47 viewport_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
| 47 viewport_->SetLayoutManager(base::WrapUnique(layout_manager_)); | 48 viewport_->SetLayoutManager(base::WrapUnique(layout_manager_)); |
| 48 viewport_->AddLimitedPreTargetHandler(event_handler_.get()); | |
| 49 } | 49 } |
| 50 | 50 |
| 51 WorkspaceController::~WorkspaceController() { | 51 WorkspaceController::~WorkspaceController() { |
| 52 viewport_->SetLayoutManager(nullptr); | 52 viewport_->SetLayoutManager(nullptr); |
| 53 viewport_->RemoveLimitedPreTargetHandler(event_handler_.get()); | |
| 54 } | 53 } |
| 55 | 54 |
| 56 wm::WorkspaceWindowState WorkspaceController::GetWindowState() const { | 55 wm::WorkspaceWindowState WorkspaceController::GetWindowState() const { |
| 57 if (!viewport_->GetRootWindowController()->HasShelf()) | 56 if (!viewport_->GetRootWindowController()->HasShelf()) |
| 58 return wm::WORKSPACE_WINDOW_STATE_DEFAULT; | 57 return wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| 59 | 58 |
| 60 const WmWindow* fullscreen = wm::GetWindowForFullscreenMode(viewport_); | 59 const WmWindow* fullscreen = wm::GetWindowForFullscreenMode(viewport_); |
| 61 if (fullscreen && !fullscreen->GetWindowState()->ignored_by_shelf()) | 60 if (fullscreen && !fullscreen->GetWindowState()->ignored_by_shelf()) |
| 62 return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; | 61 return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; |
| 63 | 62 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 layer->SetOpacity(1.0f); | 118 layer->SetOpacity(1.0f); |
| 120 } | 119 } |
| 121 } | 120 } |
| 122 | 121 |
| 123 void WorkspaceController::SetMaximizeBackdropDelegate( | 122 void WorkspaceController::SetMaximizeBackdropDelegate( |
| 124 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { | 123 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { |
| 125 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); | 124 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); |
| 126 } | 125 } |
| 127 | 126 |
| 128 } // namespace ash | 127 } // namespace ash |
| OLD | NEW |