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

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: Check if the container is kShellWindowId_DefaultContainer instead. 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
« 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/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(viewport_, ::wm::ANIMATE_NONE);
49 viewport_, ::wm::ANIMATE_NONE);
50
51 viewport_->SetLayoutManager(layout_manager_); 49 viewport_->SetLayoutManager(layout_manager_);
52 viewport_->AddPreTargetHandler(event_handler_.get()); 50 viewport_->AddPreTargetHandler(event_handler_.get());
53 } 51 }
54 52
55 WorkspaceController::~WorkspaceController() { 53 WorkspaceController::~WorkspaceController() {
56 viewport_->SetLayoutManager(NULL); 54 viewport_->SetLayoutManager(nullptr);
57 viewport_->RemovePreTargetHandler(event_handler_.get()); 55 viewport_->RemovePreTargetHandler(event_handler_.get());
58 } 56 }
59 57
60 WorkspaceWindowState WorkspaceController::GetWindowState() const { 58 WorkspaceWindowState WorkspaceController::GetWindowState() const {
61 if (!shelf_) 59 if (!shelf_)
62 return WORKSPACE_WINDOW_STATE_DEFAULT; 60 return WORKSPACE_WINDOW_STATE_DEFAULT;
63 const aura::Window* topmost_fullscreen_window = GetRootWindowController( 61 const aura::Window* topmost_fullscreen_window = GetRootWindowController(
64 viewport_->GetRootWindow())->GetWindowForFullscreenMode(); 62 viewport_->GetRootWindow())->GetWindowForFullscreenMode();
65 if (topmost_fullscreen_window && 63 if (topmost_fullscreen_window &&
66 !wm::GetWindowState(topmost_fullscreen_window)->ignored_by_shelf()) { 64 !wm::GetWindowState(topmost_fullscreen_window)->ignored_by_shelf()) {
67 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; 65 return WORKSPACE_WINDOW_STATE_FULL_SCREEN;
68 } 66 }
69 67
70 // These are the container ids of containers which may contain windows that 68 // These are the container ids of containers which may contain windows that
71 // may overlap the launcher shelf and affect its transparency. 69 // may overlap the launcher shelf and affect its transparency.
72 const int kWindowContainerIds[] = {kShellWindowId_DefaultContainer, 70 const int kWindowContainerIds[] = {kShellWindowId_DefaultContainer,
73 kShellWindowId_DockedContainer, }; 71 kShellWindowId_DockedContainer};
74 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); 72 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds());
75 bool window_overlaps_launcher = false; 73 bool window_overlaps_launcher = false;
76 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) { 74 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) {
77 const aura::Window* container = Shell::GetContainer( 75 const aura::Window* container = Shell::GetContainer(
78 viewport_->GetRootWindow(), kWindowContainerIds[idx]); 76 viewport_->GetRootWindow(), kWindowContainerIds[idx]);
79 const aura::Window::Windows& windows(container->children()); 77 const aura::Window::Windows& windows(container->children());
80 for (aura::Window::Windows::const_iterator i = windows.begin(); 78 for (auto* window : windows) {
81 i != windows.end(); ++i) { 79 wm::WindowState* window_state = wm::GetWindowState(window);
82 wm::WindowState* window_state = wm::GetWindowState(*i);
83 if (window_state->ignored_by_shelf()) 80 if (window_state->ignored_by_shelf())
84 continue; 81 continue;
85 ui::Layer* layer = (*i)->layer(); 82 if (!window->layer()->GetTargetVisibility())
86 if (!layer->GetTargetVisibility())
87 continue; 83 continue;
88 if (window_state->IsMaximized()) 84 if (window_state->IsMaximized())
89 return WORKSPACE_WINDOW_STATE_MAXIMIZED; 85 return WORKSPACE_WINDOW_STATE_MAXIMIZED;
90 if (!window_overlaps_launcher && 86 window_overlaps_launcher |= window->bounds().Intersects(shelf_bounds);
91 ((*i)->bounds().Intersects(shelf_bounds))) {
92 window_overlaps_launcher = true;
93 }
94 } 87 }
95 } 88 }
96 89
97 return (window_overlaps_launcher || IsDockedAreaVisible(shelf_)) ? 90 return (window_overlaps_launcher || IsDockedAreaVisible(shelf_)) ?
98 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : 91 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF :
99 WORKSPACE_WINDOW_STATE_DEFAULT; 92 WORKSPACE_WINDOW_STATE_DEFAULT;
100 } 93 }
101 94
102 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) {
103 shelf_ = shelf;
104 layout_manager_->SetShelf(shelf);
105 }
106
107 void WorkspaceController::DoInitialAnimation() { 95 void WorkspaceController::DoInitialAnimation() {
108 viewport_->Show(); 96 viewport_->Show();
109 97
110 viewport_->layer()->SetOpacity(0.0f); 98 viewport_->layer()->SetOpacity(0.0f);
111 SetTransformForScaleAnimation( 99 SetTransformForScaleAnimation(
112 viewport_->layer(), LAYER_SCALE_ANIMATION_ABOVE); 100 viewport_->layer(), LAYER_SCALE_ANIMATION_ABOVE);
113 101
114 // In order for pause to work we need to stop animations. 102 // In order for pause to work we need to stop animations.
115 viewport_->layer()->GetAnimator()->StopAnimating(); 103 viewport_->layer()->GetAnimator()->StopAnimating();
116 104
(...skipping 15 matching lines...) Expand all
132 viewport_->layer()->SetOpacity(1.0f); 120 viewport_->layer()->SetOpacity(1.0f);
133 } 121 }
134 } 122 }
135 123
136 void WorkspaceController::SetMaximizeBackdropDelegate( 124 void WorkspaceController::SetMaximizeBackdropDelegate(
137 std::unique_ptr<WorkspaceLayoutManagerDelegate> delegate) { 125 std::unique_ptr<WorkspaceLayoutManagerDelegate> delegate) {
138 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); 126 layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate));
139 } 127 }
140 128
141 } // namespace ash 129 } // 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