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

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

Issue 1841803002: Cleanup WorkspaceController and WorkspaceLayoutManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep nullptr comparisons. Created 4 years, 8 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
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/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"
(...skipping 24 matching lines...) Expand all
35 // Returns true if there are visible docked windows in the same screen as the 35 // Returns true if there are visible docked windows in the same screen as the
36 // |shelf|. 36 // |shelf|.
37 bool IsDockedAreaVisible(const ShelfLayoutManager* shelf) { 37 bool IsDockedAreaVisible(const ShelfLayoutManager* shelf) {
38 return shelf->dock_bounds().width() > 0; 38 return shelf->dock_bounds().width() > 0;
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 WorkspaceController::WorkspaceController(aura::Window* viewport) 43 WorkspaceController::WorkspaceController(aura::Window* viewport)
44 : viewport_(viewport), 44 : viewport_(viewport),
45 shelf_(NULL), 45 shelf_(nullptr),
46 event_handler_(new WorkspaceEventHandler), 46 event_handler_(new WorkspaceEventHandler),
47 layout_manager_(new WorkspaceLayoutManager(viewport)) { 47 layout_manager_(new WorkspaceLayoutManager(viewport)) {
48 SetWindowVisibilityAnimationTransition( 48 SetWindowVisibilityAnimationTransition(
49 viewport_, ::wm::ANIMATE_NONE); 49 viewport_, ::wm::ANIMATE_NONE);
50 50
51 viewport_->SetLayoutManager(layout_manager_); 51 viewport_->SetLayoutManager(layout_manager_);
52 viewport_->AddPreTargetHandler(event_handler_.get()); 52 viewport_->AddPreTargetHandler(event_handler_.get());
53 } 53 }
54 54
55 WorkspaceController::~WorkspaceController() { 55 WorkspaceController::~WorkspaceController() {
56 viewport_->SetLayoutManager(NULL); 56 viewport_->SetLayoutManager(nullptr);
57 viewport_->RemovePreTargetHandler(event_handler_.get()); 57 viewport_->RemovePreTargetHandler(event_handler_.get());
58 } 58 }
59 59
60 WorkspaceWindowState WorkspaceController::GetWindowState() const { 60 WorkspaceWindowState WorkspaceController::GetWindowState() const {
61 if (!shelf_) 61 if (!shelf_)
62 return WORKSPACE_WINDOW_STATE_DEFAULT; 62 return WORKSPACE_WINDOW_STATE_DEFAULT;
63 const aura::Window* topmost_fullscreen_window = GetRootWindowController( 63 const aura::Window* topmost_fullscreen_window = GetRootWindowController(
64 viewport_->GetRootWindow())->GetWindowForFullscreenMode(); 64 viewport_->GetRootWindow())->GetWindowForFullscreenMode();
65 if (topmost_fullscreen_window && 65 if (topmost_fullscreen_window &&
66 !wm::GetWindowState(topmost_fullscreen_window)->ignored_by_shelf()) { 66 !wm::GetWindowState(topmost_fullscreen_window)->ignored_by_shelf()) {
67 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; 67 return WORKSPACE_WINDOW_STATE_FULL_SCREEN;
68 } 68 }
69 69
70 // These are the container ids of containers which may contain windows that 70 // These are the container ids of containers which may contain windows that
71 // may overlap the launcher shelf and affect its transparency. 71 // may overlap the launcher shelf and affect its transparency.
72 const int kWindowContainerIds[] = {kShellWindowId_DefaultContainer, 72 const int kWindowContainerIds[] = {kShellWindowId_DefaultContainer,
73 kShellWindowId_DockedContainer, }; 73 kShellWindowId_DockedContainer};
74 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); 74 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds());
75
75 bool window_overlaps_launcher = false; 76 bool window_overlaps_launcher = false;
76 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) { 77 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) {
77 const aura::Window* container = Shell::GetContainer( 78 const aura::Window* container = Shell::GetContainer(
78 viewport_->GetRootWindow(), kWindowContainerIds[idx]); 79 viewport_->GetRootWindow(), kWindowContainerIds[idx]);
79 const aura::Window::Windows& windows(container->children()); 80 const aura::Window::Windows& windows(container->children());
80 for (aura::Window::Windows::const_iterator i = windows.begin(); 81 for (auto window : windows) {
oshima 2016/03/29 22:42:25 nit: auto*
msw 2016/03/29 22:48:00 Done.
81 i != windows.end(); ++i) { 82 wm::WindowState* window_state = wm::GetWindowState(window);
82 wm::WindowState* window_state = wm::GetWindowState(*i);
83 if (window_state->ignored_by_shelf()) 83 if (window_state->ignored_by_shelf())
84 continue; 84 continue;
85 ui::Layer* layer = (*i)->layer(); 85 if (!window->layer()->GetTargetVisibility())
86 if (!layer->GetTargetVisibility())
87 continue; 86 continue;
88 if (window_state->IsMaximized()) 87 if (window_state->IsMaximized())
89 return WORKSPACE_WINDOW_STATE_MAXIMIZED; 88 return WORKSPACE_WINDOW_STATE_MAXIMIZED;
90 if (!window_overlaps_launcher && 89 window_overlaps_launcher |= window->bounds().Intersects(shelf_bounds);
91 ((*i)->bounds().Intersects(shelf_bounds))) {
92 window_overlaps_launcher = true;
93 }
94 } 90 }
95 } 91 }
96 92
97 return (window_overlaps_launcher || IsDockedAreaVisible(shelf_)) ? 93 return (window_overlaps_launcher || IsDockedAreaVisible(shelf_)) ?
98 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : 94 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF :
99 WORKSPACE_WINDOW_STATE_DEFAULT; 95 WORKSPACE_WINDOW_STATE_DEFAULT;
100 } 96 }
101 97
102 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) {
103 shelf_ = shelf;
104 layout_manager_->SetShelf(shelf);
105 }
106
107 void WorkspaceController::DoInitialAnimation() { 98 void WorkspaceController::DoInitialAnimation() {
108 viewport_->Show(); 99 viewport_->Show();
109 100
110 viewport_->layer()->SetOpacity(0.0f); 101 viewport_->layer()->SetOpacity(0.0f);
111 SetTransformForScaleAnimation( 102 SetTransformForScaleAnimation(
112 viewport_->layer(), LAYER_SCALE_ANIMATION_ABOVE); 103 viewport_->layer(), LAYER_SCALE_ANIMATION_ABOVE);
113 104
114 // In order for pause to work we need to stop animations. 105 // In order for pause to work we need to stop animations.
115 viewport_->layer()->GetAnimator()->StopAnimating(); 106 viewport_->layer()->GetAnimator()->StopAnimating();
116 107
(...skipping 15 matching lines...) Expand all
132 viewport_->layer()->SetOpacity(1.0f); 123 viewport_->layer()->SetOpacity(1.0f);
133 } 124 }
134 } 125 }
135 126
136 void WorkspaceController::SetMaximizeBackdropDelegate( 127 void WorkspaceController::SetMaximizeBackdropDelegate(
137 scoped_ptr<WorkspaceLayoutManagerDelegate> delegate) { 128 scoped_ptr<WorkspaceLayoutManagerDelegate> delegate) {
138 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); 129 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate));
139 } 130 }
140 131
141 } // namespace ash 132 } // namespace ash
OLDNEW
« ash/wm/workspace/workspace_layout_manager.cc ('K') | « ash/wm/workspace_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698