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

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

Issue 10444014: ash: Improved window maximize/restore animations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix lock screen, app windows Created 8 years, 6 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 12 matching lines...) Expand all
23 #include "ui/aura/window.h" 23 #include "ui/aura/window.h"
24 #include "ui/base/ui_base_types.h" 24 #include "ui/base/ui_base_types.h"
25 #include "ui/compositor/layer.h" 25 #include "ui/compositor/layer.h"
26 #include "ui/compositor/layer_animator.h" 26 #include "ui/compositor/layer_animator.h"
27 #include "ui/compositor/scoped_layer_animation_settings.h" 27 #include "ui/compositor/scoped_layer_animation_settings.h"
28 #include "ui/gfx/screen.h" 28 #include "ui/gfx/screen.h"
29 #include "ui/gfx/transform.h" 29 #include "ui/gfx/transform.h"
30 30
31 namespace { 31 namespace {
32 32
33 // Returns a list of all the windows with layers in |result|. 33 // Returns a list of all the windows with layers in |result|. Optionally
34 // ignores the window |ignore_window|.
34 void BuildWindowList(const std::vector<aura::Window*>& windows, 35 void BuildWindowList(const std::vector<aura::Window*>& windows,
36 aura::Window* ignore_window,
35 std::vector<aura::Window*>* result) { 37 std::vector<aura::Window*>* result) {
36 for (size_t i = 0; i < windows.size(); ++i) { 38 for (size_t i = 0; i < windows.size(); ++i) {
39 if (windows[i] == ignore_window)
40 continue;
37 if (windows[i]->layer()) 41 if (windows[i]->layer())
38 result->push_back(windows[i]); 42 result->push_back(windows[i]);
39 BuildWindowList(windows[i]->transient_children(), result); 43 BuildWindowList(windows[i]->transient_children(), ignore_window, result);
40 } 44 }
41 } 45 }
42 46
43 } 47 }
44 48
45 namespace ash { 49 namespace ash {
46 namespace internal { 50 namespace internal {
47 51
48 //////////////////////////////////////////////////////////////////////////////// 52 ////////////////////////////////////////////////////////////////////////////////
49 // WindowManager, public: 53 // WindowManager, public:
50 54
51 WorkspaceManager::WorkspaceManager(aura::Window* contents_view) 55 WorkspaceManager::WorkspaceManager(aura::Window* contents_view)
52 : contents_view_(contents_view), 56 : contents_view_(contents_view),
53 active_workspace_(NULL), 57 active_workspace_(NULL),
54 ignored_window_(NULL), 58 maximize_restore_window_(NULL),
55 grid_size_(0), 59 grid_size_(0),
56 shelf_(NULL) { 60 shelf_(NULL) {
57 DCHECK(contents_view); 61 DCHECK(contents_view);
58 } 62 }
59 63
60 WorkspaceManager::~WorkspaceManager() { 64 WorkspaceManager::~WorkspaceManager() {
61 std::vector<Workspace*> copy_to_delete(workspaces_); 65 std::vector<Workspace*> copy_to_delete(workspaces_);
62 STLDeleteElements(&copy_to_delete); 66 STLDeleteElements(&copy_to_delete);
63 } 67 }
64 68
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 else 209 else
206 active_workspace_ = NULL; 210 active_workspace_ = NULL;
207 } 211 }
208 } 212 }
209 213
210 void WorkspaceManager::SetVisibilityOfWorkspaceWindows( 214 void WorkspaceManager::SetVisibilityOfWorkspaceWindows(
211 ash::internal::Workspace* workspace, 215 ash::internal::Workspace* workspace,
212 AnimateChangeType change_type, 216 AnimateChangeType change_type,
213 bool value) { 217 bool value) {
214 std::vector<aura::Window*> children; 218 std::vector<aura::Window*> children;
215 BuildWindowList(workspace->windows(), &children); 219 BuildWindowList(workspace->windows(), maximize_restore_window_, &children);
216 SetWindowLayerVisibility(children, change_type, value); 220 SetWindowLayerVisibility(children, change_type, value);
217 } 221 }
218 222
219 void WorkspaceManager::SetWindowLayerVisibility( 223 void WorkspaceManager::SetWindowLayerVisibility(
220 const std::vector<aura::Window*>& windows, 224 const std::vector<aura::Window*>& windows,
221 AnimateChangeType change_type, 225 AnimateChangeType change_type,
222 bool value) { 226 bool value) {
223 for (size_t i = 0; i < windows.size(); ++i) { 227 for (size_t i = 0; i < windows.size(); ++i) {
224 ui::Layer* layer = windows[i]->layer(); 228 ui::Layer* layer = windows[i]->layer();
225 // Only show the layer for windows that want to be visible. 229 // Only show the layer for windows that want to be visible.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 i != workspaces_.end(); 286 i != workspaces_.end();
283 ++i) { 287 ++i) {
284 if ((*i)->Contains(window)) 288 if ((*i)->Contains(window))
285 return i - workspaces_.begin(); 289 return i - workspaces_.begin();
286 } 290 }
287 return -1; 291 return -1;
288 } 292 }
289 293
290 void WorkspaceManager::SetWindowBounds(aura::Window* window, 294 void WorkspaceManager::SetWindowBounds(aura::Window* window,
291 const gfx::Rect& bounds) { 295 const gfx::Rect& bounds) {
292 ignored_window_ = window;
293 window->SetBounds(bounds); 296 window->SetBounds(bounds);
294 ignored_window_ = NULL;
295 } 297 }
296 298
297 void WorkspaceManager::OnTypeOfWorkspacedNeededChanged(aura::Window* window) { 299 void WorkspaceManager::OnTypeOfWorkspacedNeededChanged(aura::Window* window) {
298 DCHECK(IsManagedWindow(window)); 300 DCHECK(IsManagedWindow(window));
299 Workspace* current_workspace = FindBy(window); 301 Workspace* current_workspace = FindBy(window);
300 DCHECK(current_workspace); 302 DCHECK(current_workspace);
301 Workspace* new_workspace = NULL; 303 Workspace* new_workspace = NULL;
302 if (Workspace::TypeForWindow(window) == Workspace::TYPE_MAXIMIZED) { 304 if (Workspace::TypeForWindow(window) == Workspace::TYPE_MAXIMIZED) {
303 // Unmaximized -> maximized; create a new workspace. 305 // Unmaximized -> maximized; create a new workspace.
304 current_workspace->RemoveWindow(window); 306 current_workspace->RemoveWindow(window);
305 new_workspace = CreateWorkspace(Workspace::TYPE_MAXIMIZED); 307 new_workspace = CreateWorkspace(Workspace::TYPE_MAXIMIZED);
306 new_workspace->AddWindowAfter(window, NULL); 308 new_workspace->AddWindowAfter(window, NULL);
307 } else { 309 } else {
308 // Maximized -> unmaximized; move window to unmaximized workspace. 310 // Maximized -> unmaximized; move window to unmaximized workspace.
309 new_workspace = GetManagedWorkspace(); 311 new_workspace = GetManagedWorkspace();
310 current_workspace->RemoveWindow(window); 312 current_workspace->RemoveWindow(window);
311 if (!new_workspace) 313 if (!new_workspace)
312 new_workspace = CreateWorkspace(Workspace::TYPE_MANAGED); 314 new_workspace = CreateWorkspace(Workspace::TYPE_MANAGED);
313 new_workspace->AddWindowAfter(window, NULL); 315 new_workspace->AddWindowAfter(window, NULL);
314 } 316 }
317 maximize_restore_window_ = window;
315 SetActiveWorkspace(new_workspace); 318 SetActiveWorkspace(new_workspace);
319 maximize_restore_window_ = NULL;
316 // Delete at the end so that we don't attempt to switch to another 320 // Delete at the end so that we don't attempt to switch to another
317 // workspace in RemoveWorkspace(). 321 // workspace in RemoveWorkspace().
318 CleanupWorkspace(current_workspace); 322 CleanupWorkspace(current_workspace);
319 } 323 }
320 324
321 Workspace* WorkspaceManager::GetManagedWorkspace() { 325 Workspace* WorkspaceManager::GetManagedWorkspace() {
322 for (size_t i = 0; i < workspaces_.size(); ++i) { 326 for (size_t i = 0; i < workspaces_.size(); ++i) {
323 if (workspaces_[i]->type() == Workspace::TYPE_MANAGED) 327 if (workspaces_[i]->type() == Workspace::TYPE_MANAGED)
324 return workspaces_[i]; 328 return workspaces_[i];
325 } 329 }
(...skipping 10 matching lines...) Expand all
336 return workspace; 340 return workspace;
337 } 341 }
338 342
339 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) { 343 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) {
340 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty()) 344 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty())
341 delete workspace; 345 delete workspace;
342 } 346 }
343 347
344 } // namespace internal 348 } // namespace internal
345 } // namespace ash 349 } // 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