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

Side by Side Diff: ash/wm/workspace/workspace_manager.cc

Issue 10827377: Adds an interface between WorkspaceController and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add virtual & OVERRIDE Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/workspace/workspace_manager.h ('k') | ash/wm/workspace_controller.h » ('j') | 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/workspace_manager.h" 5 #include "ash/wm/workspace/workspace_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 !window->transient_parent() && 72 !window->transient_parent() &&
73 ash::GetTrackedByWorkspace(window) && 73 ash::GetTrackedByWorkspace(window) &&
74 (!ash::GetPersistsAcrossAllWorkspaces(window) || 74 (!ash::GetPersistsAcrossAllWorkspaces(window) ||
75 wm::IsWindowMaximized(window)); 75 wm::IsWindowMaximized(window));
76 } 76 }
77 77
78 bool WorkspaceManager::Contains(aura::Window* window) const { 78 bool WorkspaceManager::Contains(aura::Window* window) const {
79 return FindBy(window) != NULL; 79 return FindBy(window) != NULL;
80 } 80 }
81 81
82 bool WorkspaceManager::IsInMaximizedMode() const {
83 return active_workspace_ &&
84 active_workspace_->type() == Workspace::TYPE_MAXIMIZED;
85 }
86
87 void WorkspaceManager::AddWindow(aura::Window* window) { 82 void WorkspaceManager::AddWindow(aura::Window* window) {
88 DCHECK(ShouldManageWindow(window)); 83 DCHECK(ShouldManageWindow(window));
89 84
90 Workspace* current_workspace = FindBy(window); 85 Workspace* current_workspace = FindBy(window);
91 if (current_workspace) { 86 if (current_workspace) {
92 // Already know about this window. Make sure the workspace is active. 87 // Already know about this window. Make sure the workspace is active.
93 if (active_workspace_ != current_workspace) { 88 if (active_workspace_ != current_workspace) {
94 if (active_workspace_) 89 if (active_workspace_)
95 window->layer()->GetAnimator()->StopAnimating(); 90 window->layer()->GetAnimator()->StopAnimating();
96 current_workspace->Activate(); 91 current_workspace->Activate();
(...skipping 24 matching lines...) Expand all
121 } 116 }
122 117
123 void WorkspaceManager::RemoveWindow(aura::Window* window) { 118 void WorkspaceManager::RemoveWindow(aura::Window* window) {
124 Workspace* workspace = FindBy(window); 119 Workspace* workspace = FindBy(window);
125 if (!workspace) 120 if (!workspace)
126 return; 121 return;
127 workspace->RemoveWindow(window); 122 workspace->RemoveWindow(window);
128 CleanupWorkspace(workspace); 123 CleanupWorkspace(workspace);
129 } 124 }
130 125
131 void WorkspaceManager::SetActiveWorkspaceByWindow(aura::Window* window) {
132 Workspace* workspace = FindBy(window);
133 if (workspace)
134 workspace->Activate();
135 }
136
137 void WorkspaceManager::SetGridSize(int grid_size) {
138 grid_size_ = grid_size;
139 }
140
141 void WorkspaceManager::UpdateShelfVisibility() { 126 void WorkspaceManager::UpdateShelfVisibility() {
142 if (shelf_) 127 if (shelf_)
143 shelf_->UpdateVisibilityState(); 128 shelf_->UpdateVisibilityState();
144 } 129 }
145 130
131 void WorkspaceManager::ShowStateChanged(aura::Window* window) {
132 Workspace* workspace = FindBy(window);
133 if (!workspace)
134 return;
135 if (!ShouldManageWindow(window)) {
136 RemoveWindow(window);
137 } else {
138 Workspace::Type old_type = workspace->type();
139 Workspace::Type new_type = Workspace::TypeForWindow(window);
140 if (new_type != old_type)
141 OnTypeOfWorkspacedNeededChanged(window);
142 }
143 UpdateShelfVisibility();
144 }
145
146 bool WorkspaceManager::IsInMaximizedMode() const {
147 return active_workspace_ &&
148 active_workspace_->type() == Workspace::TYPE_MAXIMIZED;
149 }
150
151 void WorkspaceManager::SetGridSize(int size) {
152 grid_size_ = size;
153 }
154
155 int WorkspaceManager::GetGridSize() const {
156 return grid_size_;
157 }
158
146 WorkspaceWindowState WorkspaceManager::GetWindowState() const { 159 WorkspaceWindowState WorkspaceManager::GetWindowState() const {
147 if (!shelf_ || !active_workspace_) 160 if (!shelf_ || !active_workspace_)
148 return WORKSPACE_WINDOW_STATE_DEFAULT; 161 return WORKSPACE_WINDOW_STATE_DEFAULT;
149 162
150 // TODO: this code needs to be made multi-display aware. 163 // TODO: this code needs to be made multi-display aware.
151 gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); 164 gfx::Rect shelf_bounds(shelf_->GetIdealBounds());
152 const aura::Window::Windows& windows(contents_view_->children()); 165 const aura::Window::Windows& windows(contents_view_->children());
153 bool window_overlaps_launcher = false; 166 bool window_overlaps_launcher = false;
154 bool has_maximized_window = false; 167 bool has_maximized_window = false;
155 for (aura::Window::Windows::const_iterator i = windows.begin(); 168 for (aura::Window::Windows::const_iterator i = windows.begin();
(...skipping 12 matching lines...) Expand all
168 window_overlaps_launcher = true; 181 window_overlaps_launcher = true;
169 } 182 }
170 if (has_maximized_window) 183 if (has_maximized_window)
171 return WORKSPACE_WINDOW_STATE_MAXIMIZED; 184 return WORKSPACE_WINDOW_STATE_MAXIMIZED;
172 185
173 return window_overlaps_launcher ? 186 return window_overlaps_launcher ?
174 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : 187 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF :
175 WORKSPACE_WINDOW_STATE_DEFAULT; 188 WORKSPACE_WINDOW_STATE_DEFAULT;
176 } 189 }
177 190
178 void WorkspaceManager::ShowStateChanged(aura::Window* window) { 191 void WorkspaceManager::SetShelf(ShelfLayoutManager* shelf) {
192 shelf_ = shelf;
193 }
194
195 void WorkspaceManager::SetActiveWorkspaceByWindow(aura::Window* window) {
179 Workspace* workspace = FindBy(window); 196 Workspace* workspace = FindBy(window);
180 if (!workspace) 197 if (workspace)
181 return; 198 workspace->Activate();
182 if (!ShouldManageWindow(window)) { 199 }
183 RemoveWindow(window); 200
184 } else { 201 aura::Window* WorkspaceManager::GetParentForNewWindow(aura::Window* window) {
185 Workspace::Type old_type = workspace->type(); 202 return contents_view_;
186 Workspace::Type new_type = Workspace::TypeForWindow(window);
187 if (new_type != old_type)
188 OnTypeOfWorkspacedNeededChanged(window);
189 }
190 UpdateShelfVisibility();
191 } 203 }
192 204
193 //////////////////////////////////////////////////////////////////////////////// 205 ////////////////////////////////////////////////////////////////////////////////
194 // WorkspaceManager, private: 206 // WorkspaceManager, private:
195 207
196 void WorkspaceManager::AddWorkspace(Workspace* workspace) { 208 void WorkspaceManager::AddWorkspace(Workspace* workspace) {
197 DCHECK(std::find(workspaces_.begin(), workspaces_.end(), 209 DCHECK(std::find(workspaces_.begin(), workspaces_.end(),
198 workspace) == workspaces_.end()); 210 workspace) == workspaces_.end());
199 if (active_workspace_) { 211 if (active_workspace_) {
200 // New workspaces go right after current workspace. 212 // New workspaces go right after current workspace.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return workspace; 364 return workspace;
353 } 365 }
354 366
355 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) { 367 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) {
356 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty()) 368 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty())
357 delete workspace; 369 delete workspace;
358 } 370 }
359 371
360 } // namespace internal 372 } // namespace internal
361 } // namespace ash 373 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_manager.h ('k') | ash/wm/workspace_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698