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

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

Issue 10828026: Renames two WorkspaceManager methods so that they are more clearly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/workspace_manager_unittest.cc » ('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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 grid_size_(0), 59 grid_size_(0),
60 shelf_(NULL) { 60 shelf_(NULL) {
61 DCHECK(contents_view); 61 DCHECK(contents_view);
62 } 62 }
63 63
64 WorkspaceManager::~WorkspaceManager() { 64 WorkspaceManager::~WorkspaceManager() {
65 std::vector<Workspace*> copy_to_delete(workspaces_); 65 std::vector<Workspace*> copy_to_delete(workspaces_);
66 STLDeleteElements(&copy_to_delete); 66 STLDeleteElements(&copy_to_delete);
67 } 67 }
68 68
69 bool WorkspaceManager::IsManagedWindow(aura::Window* window) const { 69 // static
70 bool WorkspaceManager::ShouldManageWindow(aura::Window* window) {
70 return window->type() == aura::client::WINDOW_TYPE_NORMAL && 71 return window->type() == aura::client::WINDOW_TYPE_NORMAL &&
71 !window->transient_parent() && 72 !window->transient_parent() &&
72 ash::GetTrackedByWorkspace(window) && 73 ash::GetTrackedByWorkspace(window) &&
73 !ash::GetPersistsAcrossAllWorkspaces(window); 74 !ash::GetPersistsAcrossAllWorkspaces(window);
74 } 75 }
75 76
76 bool WorkspaceManager::IsManagingWindow(aura::Window* window) const { 77 bool WorkspaceManager::Contains(aura::Window* window) const {
77 return FindBy(window) != NULL; 78 return FindBy(window) != NULL;
78 } 79 }
79 80
80 bool WorkspaceManager::IsInMaximizedMode() const { 81 bool WorkspaceManager::IsInMaximizedMode() const {
81 return active_workspace_ && 82 return active_workspace_ &&
82 active_workspace_->type() == Workspace::TYPE_MAXIMIZED; 83 active_workspace_->type() == Workspace::TYPE_MAXIMIZED;
83 } 84 }
84 85
85 void WorkspaceManager::AddWindow(aura::Window* window) { 86 void WorkspaceManager::AddWindow(aura::Window* window) {
86 DCHECK(IsManagedWindow(window)); 87 DCHECK(ShouldManageWindow(window));
87 88
88 Workspace* current_workspace = FindBy(window); 89 Workspace* current_workspace = FindBy(window);
89 if (current_workspace) { 90 if (current_workspace) {
90 // Already know about this window. Make sure the workspace is active. 91 // Already know about this window. Make sure the workspace is active.
91 if (active_workspace_ != current_workspace) { 92 if (active_workspace_ != current_workspace) {
92 if (active_workspace_) 93 if (active_workspace_)
93 window->layer()->GetAnimator()->StopAnimating(); 94 window->layer()->GetAnimator()->StopAnimating();
94 current_workspace->Activate(); 95 current_workspace->Activate();
95 } 96 }
96 window->Show(); 97 window->Show();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 window_overlaps_launcher = true; 163 window_overlaps_launcher = true;
163 } 164 }
164 if (has_maximized_window) 165 if (has_maximized_window)
165 return WINDOW_STATE_MAXIMIZED; 166 return WINDOW_STATE_MAXIMIZED;
166 167
167 return window_overlaps_launcher ? WINDOW_STATE_WINDOW_OVERLAPS_SHELF : 168 return window_overlaps_launcher ? WINDOW_STATE_WINDOW_OVERLAPS_SHELF :
168 WINDOW_STATE_DEFAULT; 169 WINDOW_STATE_DEFAULT;
169 } 170 }
170 171
171 void WorkspaceManager::ShowStateChanged(aura::Window* window) { 172 void WorkspaceManager::ShowStateChanged(aura::Window* window) {
172 if (!IsManagedWindow(window) || !FindBy(window)) 173 if (!ShouldManageWindow(window) || !FindBy(window))
173 return; 174 return;
174 175
175 Workspace::Type old_type = FindBy(window)->type(); 176 Workspace::Type old_type = FindBy(window)->type();
176 Workspace::Type new_type = Workspace::TypeForWindow(window); 177 Workspace::Type new_type = Workspace::TypeForWindow(window);
177 if (new_type != old_type) 178 if (new_type != old_type)
178 OnTypeOfWorkspacedNeededChanged(window); 179 OnTypeOfWorkspacedNeededChanged(window);
179 UpdateShelfVisibility(); 180 UpdateShelfVisibility();
180 } 181 }
181 182
182 //////////////////////////////////////////////////////////////////////////////// 183 ////////////////////////////////////////////////////////////////////////////////
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 292 }
292 return -1; 293 return -1;
293 } 294 }
294 295
295 void WorkspaceManager::SetWindowBounds(aura::Window* window, 296 void WorkspaceManager::SetWindowBounds(aura::Window* window,
296 const gfx::Rect& bounds) { 297 const gfx::Rect& bounds) {
297 window->SetBounds(bounds); 298 window->SetBounds(bounds);
298 } 299 }
299 300
300 void WorkspaceManager::OnTypeOfWorkspacedNeededChanged(aura::Window* window) { 301 void WorkspaceManager::OnTypeOfWorkspacedNeededChanged(aura::Window* window) {
301 DCHECK(IsManagedWindow(window)); 302 DCHECK(ShouldManageWindow(window));
302 Workspace* current_workspace = FindBy(window); 303 Workspace* current_workspace = FindBy(window);
303 DCHECK(current_workspace); 304 DCHECK(current_workspace);
304 Workspace* new_workspace = NULL; 305 Workspace* new_workspace = NULL;
305 if (Workspace::TypeForWindow(window) == Workspace::TYPE_MAXIMIZED) { 306 if (Workspace::TypeForWindow(window) == Workspace::TYPE_MAXIMIZED) {
306 // Unmaximized -> maximized; create a new workspace. 307 // Unmaximized -> maximized; create a new workspace.
307 current_workspace->RemoveWindow(window); 308 current_workspace->RemoveWindow(window);
308 new_workspace = CreateWorkspace(Workspace::TYPE_MAXIMIZED); 309 new_workspace = CreateWorkspace(Workspace::TYPE_MAXIMIZED);
309 new_workspace->AddWindowAfter(window, NULL); 310 new_workspace->AddWindowAfter(window, NULL);
310 } else { 311 } else {
311 // Maximized -> unmaximized; move window to unmaximized workspace. 312 // Maximized -> unmaximized; move window to unmaximized workspace.
(...skipping 29 matching lines...) Expand all
341 return workspace; 342 return workspace;
342 } 343 }
343 344
344 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) { 345 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) {
345 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty()) 346 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty())
346 delete workspace; 347 delete workspace;
347 } 348 }
348 349
349 } // namespace internal 350 } // namespace internal
350 } // namespace ash 351 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_manager.h ('k') | ash/wm/workspace/workspace_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698