| 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/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
| 13 #include "ash/wm/common/workspace/workspace_layout_manager_delegate.h" |
| 13 #include "ash/wm/window_animations.h" | 14 #include "ash/wm/window_animations.h" |
| 14 #include "ash/wm/window_state.h" | 15 #include "ash/wm/window_state.h" |
| 15 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
| 16 #include "ash/wm/workspace/workspace_event_handler.h" | 17 #include "ash/wm/workspace/workspace_event_handler.h" |
| 17 #include "ash/wm/workspace/workspace_layout_manager.h" | 18 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 18 #include "ash/wm/workspace/workspace_layout_manager_delegate.h" | 19 #include "ash/wm/workspace/workspace_layout_manager_backdrop_delegate.h" |
| 19 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
| 20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| 22 #include "ui/compositor/layer.h" | 23 #include "ui/compositor/layer.h" |
| 23 #include "ui/compositor/scoped_layer_animation_settings.h" | 24 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 24 #include "ui/wm/core/visibility_controller.h" | 25 #include "ui/wm/core/visibility_controller.h" |
| 25 #include "ui/wm/core/window_animations.h" | 26 #include "ui/wm/core/window_animations.h" |
| 26 #include "ui/wm/public/activation_client.h" | 27 #include "ui/wm/public/activation_client.h" |
| 27 | 28 |
| 28 namespace ash { | 29 namespace ash { |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // Amount of time to pause before animating anything. Only used during initial | 32 // Amount of time to pause before animating anything. Only used during initial |
| 32 // animation (when logging in). | 33 // animation (when logging in). |
| 33 const int kInitialPauseTimeMS = 750; | 34 const int kInitialPauseTimeMS = 750; |
| 34 | 35 |
| 35 // Returns true if there are visible docked windows in the same screen as the | 36 // Returns true if there are visible docked windows in the same screen as the |
| 36 // |shelf|. | 37 // |shelf|. |
| 37 bool IsDockedAreaVisible(const ShelfLayoutManager* shelf) { | 38 bool IsDockedAreaVisible(const ShelfLayoutManager* shelf) { |
| 38 return shelf->dock_bounds().width() > 0; | 39 return shelf->dock_bounds().width() > 0; |
| 39 } | 40 } |
| 40 | 41 |
| 41 } // namespace | 42 } // namespace |
| 42 | 43 |
| 43 WorkspaceController::WorkspaceController(aura::Window* viewport) | 44 WorkspaceController::WorkspaceController( |
| 45 aura::Window* viewport, |
| 46 std::unique_ptr<wm::WorkspaceLayoutManagerDelegate> delegate) |
| 44 : viewport_(viewport), | 47 : viewport_(viewport), |
| 45 shelf_(NULL), | 48 shelf_(NULL), |
| 46 event_handler_(new WorkspaceEventHandler), | 49 event_handler_(new WorkspaceEventHandler), |
| 47 layout_manager_(new WorkspaceLayoutManager(viewport)) { | 50 layout_manager_( |
| 51 new WorkspaceLayoutManager(viewport, std::move(delegate))) { |
| 48 SetWindowVisibilityAnimationTransition( | 52 SetWindowVisibilityAnimationTransition( |
| 49 viewport_, ::wm::ANIMATE_NONE); | 53 viewport_, ::wm::ANIMATE_NONE); |
| 50 | 54 |
| 51 viewport_->SetLayoutManager(layout_manager_); | 55 viewport_->SetLayoutManager(layout_manager_); |
| 52 viewport_->AddPreTargetHandler(event_handler_.get()); | 56 viewport_->AddPreTargetHandler(event_handler_.get()); |
| 53 } | 57 } |
| 54 | 58 |
| 55 WorkspaceController::~WorkspaceController() { | 59 WorkspaceController::~WorkspaceController() { |
| 56 viewport_->SetLayoutManager(NULL); | 60 viewport_->SetLayoutManager(NULL); |
| 57 viewport_->RemovePreTargetHandler(event_handler_.get()); | 61 viewport_->RemovePreTargetHandler(event_handler_.get()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 98 } |
| 95 } | 99 } |
| 96 | 100 |
| 97 return (window_overlaps_launcher || IsDockedAreaVisible(shelf_)) ? | 101 return (window_overlaps_launcher || IsDockedAreaVisible(shelf_)) ? |
| 98 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : | 102 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : |
| 99 WORKSPACE_WINDOW_STATE_DEFAULT; | 103 WORKSPACE_WINDOW_STATE_DEFAULT; |
| 100 } | 104 } |
| 101 | 105 |
| 102 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { | 106 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { |
| 103 shelf_ = shelf; | 107 shelf_ = shelf; |
| 104 layout_manager_->SetShelf(shelf); | |
| 105 } | 108 } |
| 106 | 109 |
| 107 void WorkspaceController::DoInitialAnimation() { | 110 void WorkspaceController::DoInitialAnimation() { |
| 108 viewport_->Show(); | 111 viewport_->Show(); |
| 109 | 112 |
| 110 viewport_->layer()->SetOpacity(0.0f); | 113 viewport_->layer()->SetOpacity(0.0f); |
| 111 SetTransformForScaleAnimation( | 114 SetTransformForScaleAnimation( |
| 112 viewport_->layer(), LAYER_SCALE_ANIMATION_ABOVE); | 115 viewport_->layer(), LAYER_SCALE_ANIMATION_ABOVE); |
| 113 | 116 |
| 114 // In order for pause to work we need to stop animations. | 117 // In order for pause to work we need to stop animations. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 127 ui::LayerAnimationElement::VISIBILITY); | 130 ui::LayerAnimationElement::VISIBILITY); |
| 128 settings.SetTweenType(gfx::Tween::EASE_OUT); | 131 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 129 settings.SetTransitionDuration( | 132 settings.SetTransitionDuration( |
| 130 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); | 133 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); |
| 131 viewport_->layer()->SetTransform(gfx::Transform()); | 134 viewport_->layer()->SetTransform(gfx::Transform()); |
| 132 viewport_->layer()->SetOpacity(1.0f); | 135 viewport_->layer()->SetOpacity(1.0f); |
| 133 } | 136 } |
| 134 } | 137 } |
| 135 | 138 |
| 136 void WorkspaceController::SetMaximizeBackdropDelegate( | 139 void WorkspaceController::SetMaximizeBackdropDelegate( |
| 137 std::unique_ptr<WorkspaceLayoutManagerDelegate> delegate) { | 140 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { |
| 138 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); | 141 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); |
| 139 } | 142 } |
| 140 | 143 |
| 141 } // namespace ash | 144 } // namespace ash |
| OLD | NEW |