Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Side by Side Diff: ash/wm/workspace_controller.cc

Issue 2861243003: chromeos: Converts WorkspaceLayoutManager to aura::LayoutManager (Closed)
Patch Set: feedback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/workspace_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/shelf/wm_shelf.h" 11 #include "ash/shelf/wm_shelf.h"
12 #include "ash/shell_port.h" 12 #include "ash/shell_port.h"
13 #include "ash/wm/fullscreen_window_finder.h" 13 #include "ash/wm/fullscreen_window_finder.h"
14 #include "ash/wm/window_state.h" 14 #include "ash/wm/window_state.h"
15 #include "ash/wm/window_state_aura.h" 15 #include "ash/wm/window_state_aura.h"
16 #include "ash/wm/wm_window_animations.h" 16 #include "ash/wm/wm_window_animations.h"
17 #include "ash/wm/workspace/workspace_event_handler.h" 17 #include "ash/wm/workspace/workspace_event_handler.h"
18 #include "ash/wm/workspace/workspace_layout_manager.h" 18 #include "ash/wm/workspace/workspace_layout_manager.h"
19 #include "ash/wm/workspace/workspace_layout_manager_backdrop_delegate.h" 19 #include "ash/wm/workspace/workspace_layout_manager_backdrop_delegate.h"
20 #include "ash/wm_window.h" 20 #include "ash/wm_window.h"
21 #include "base/memory/ptr_util.h"
22 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
23 #include "ui/compositor/layer.h" 22 #include "ui/compositor/layer.h"
24 #include "ui/compositor/scoped_layer_animation_settings.h" 23 #include "ui/compositor/scoped_layer_animation_settings.h"
25 24
26 namespace ash { 25 namespace ash {
27 namespace { 26 namespace {
28 27
29 // 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
30 // animation (when logging in). 29 // animation (when logging in).
31 const int kInitialPauseTimeMS = 750; 30 const int kInitialPauseTimeMS = 750;
32 31
33 // The duration of the animation that occurs on first login. 32 // The duration of the animation that occurs on first login.
34 const int kInitialAnimationDurationMS = 200; 33 const int kInitialAnimationDurationMS = 200;
35 34
36 } // namespace 35 } // namespace
37 36
38 WorkspaceController::WorkspaceController(WmWindow* viewport) 37 WorkspaceController::WorkspaceController(aura::Window* viewport)
39 : viewport_(viewport), 38 : viewport_(viewport),
40 event_handler_(ShellPort::Get()->CreateWorkspaceEventHandler(viewport)), 39 event_handler_(ShellPort::Get()->CreateWorkspaceEventHandler(
40 WmWindow::Get(viewport))),
41 layout_manager_(new WorkspaceLayoutManager(viewport)) { 41 layout_manager_(new WorkspaceLayoutManager(viewport)) {
42 viewport_->aura_window()->AddObserver(this); 42 viewport_->AddObserver(this);
43 viewport_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); 43 ::wm::SetWindowVisibilityAnimationTransition(viewport_, ::wm::ANIMATE_NONE);
44 viewport_->SetLayoutManager(base::WrapUnique(layout_manager_)); 44 viewport_->SetLayoutManager(layout_manager_);
45 } 45 }
46 46
47 WorkspaceController::~WorkspaceController() { 47 WorkspaceController::~WorkspaceController() {
48 if (!viewport_) 48 if (!viewport_)
49 return; 49 return;
50 50
51 viewport_->aura_window()->RemoveObserver(this); 51 viewport_->RemoveObserver(this);
52 viewport_->SetLayoutManager(nullptr); 52 viewport_->SetLayoutManager(nullptr);
53 } 53 }
54 54
55 wm::WorkspaceWindowState WorkspaceController::GetWindowState() const { 55 wm::WorkspaceWindowState WorkspaceController::GetWindowState() const {
56 if (!viewport_ || !viewport_->GetRootWindowController()->HasShelf()) 56 if (!viewport_ || !RootWindowController::ForWindow(viewport_)->HasShelf())
57 return wm::WORKSPACE_WINDOW_STATE_DEFAULT; 57 return wm::WORKSPACE_WINDOW_STATE_DEFAULT;
58 58
59 const WmWindow* fullscreen = wm::GetWindowForFullscreenMode(viewport_); 59 const aura::Window* fullscreen = wm::GetWindowForFullscreenMode(viewport_);
60 if (fullscreen && !fullscreen->GetWindowState()->ignored_by_shelf()) 60 if (fullscreen && !wm::GetWindowState(fullscreen)->ignored_by_shelf())
61 return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; 61 return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN;
62 62
63 const gfx::Rect shelf_bounds(WmShelf::ForWindow(viewport_)->GetIdealBounds()); 63 const gfx::Rect shelf_bounds(
64 WmShelf::ForWindow(WmWindow::Get(viewport_))->GetIdealBounds());
64 bool window_overlaps_launcher = false; 65 bool window_overlaps_launcher = false;
65 // The default container may contain windows that may overlap the launcher 66 // The default container may contain windows that may overlap the launcher
66 // shelf and affect its transparency. 67 // shelf and affect its transparency.
67 aura::Window* container = 68 aura::Window* container =
68 viewport_->GetRootWindow()->aura_window()->GetChildById( 69 viewport_->GetRootWindow()->GetChildById(kShellWindowId_DefaultContainer);
69 kShellWindowId_DefaultContainer);
70 for (aura::Window* window : container->children()) { 70 for (aura::Window* window : container->children()) {
71 wm::WindowState* window_state = wm::GetWindowState(window); 71 wm::WindowState* window_state = wm::GetWindowState(window);
72 if (window_state->ignored_by_shelf() || 72 if (window_state->ignored_by_shelf() ||
73 (window->layer() && !window->layer()->GetTargetVisibility())) { 73 (window->layer() && !window->layer()->GetTargetVisibility())) {
74 continue; 74 continue;
75 } 75 }
76 if (window_state->IsMaximized()) 76 if (window_state->IsMaximized())
77 return wm::WORKSPACE_WINDOW_STATE_MAXIMIZED; 77 return wm::WORKSPACE_WINDOW_STATE_MAXIMIZED;
78 window_overlaps_launcher |= window->bounds().Intersects(shelf_bounds); 78 window_overlaps_launcher |= window->bounds().Intersects(shelf_bounds);
79 } 79 }
80 80
81 return window_overlaps_launcher 81 return window_overlaps_launcher
82 ? wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF 82 ? wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF
83 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; 83 : wm::WORKSPACE_WINDOW_STATE_DEFAULT;
84 } 84 }
85 85
86 void WorkspaceController::DoInitialAnimation() { 86 void WorkspaceController::DoInitialAnimation() {
87 viewport_->Show(); 87 viewport_->Show();
88 88
89 ui::Layer* layer = viewport_->GetLayer(); 89 ui::Layer* layer = viewport_->layer();
90 layer->SetOpacity(0.0f); 90 layer->SetOpacity(0.0f);
91 SetTransformForScaleAnimation(layer, LAYER_SCALE_ANIMATION_ABOVE); 91 SetTransformForScaleAnimation(layer, LAYER_SCALE_ANIMATION_ABOVE);
92 92
93 // In order for pause to work we need to stop animations. 93 // In order for pause to work we need to stop animations.
94 layer->GetAnimator()->StopAnimating(); 94 layer->GetAnimator()->StopAnimating();
95 95
96 { 96 {
97 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); 97 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
98 98
99 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); 99 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
(...skipping 10 matching lines...) Expand all
110 layer->SetOpacity(1.0f); 110 layer->SetOpacity(1.0f);
111 } 111 }
112 } 112 }
113 113
114 void WorkspaceController::SetMaximizeBackdropDelegate( 114 void WorkspaceController::SetMaximizeBackdropDelegate(
115 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { 115 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) {
116 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); 116 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate));
117 } 117 }
118 118
119 void WorkspaceController::OnWindowDestroying(aura::Window* window) { 119 void WorkspaceController::OnWindowDestroying(aura::Window* window) {
120 DCHECK_EQ(WmWindow::Get(window), viewport_); 120 DCHECK_EQ(window, viewport_);
121 viewport_->aura_window()->RemoveObserver(this); 121 viewport_->RemoveObserver(this);
122 viewport_ = nullptr; 122 viewport_ = nullptr;
123 // Destroy |event_handler_| too as it depends upon |window|. 123 // Destroy |event_handler_| too as it depends upon |window|.
124 event_handler_.reset(); 124 event_handler_.reset();
125 layout_manager_ = nullptr; 125 layout_manager_ = nullptr;
126 } 126 }
127 127
128 } // namespace ash 128 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698