| OLD | NEW |
| 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/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 const int WorkspaceManager::kOpenMaximizedThreshold = 1600; | 68 const int WorkspaceManager::kOpenMaximizedThreshold = 1600; |
| 69 | 69 |
| 70 WorkspaceManager::WorkspaceManager(aura::Window* contents_view) | 70 WorkspaceManager::WorkspaceManager(aura::Window* contents_view) |
| 71 : contents_view_(contents_view), | 71 : contents_view_(contents_view), |
| 72 active_workspace_(NULL), | 72 active_workspace_(NULL), |
| 73 workspace_size_( | 73 workspace_size_( |
| 74 gfx::Screen::GetMonitorAreaNearestWindow(contents_view_).size()), | 74 gfx::Screen::GetMonitorAreaNearestWindow(contents_view_).size()), |
| 75 is_overview_(false), | 75 is_overview_(false), |
| 76 ignored_window_(NULL), | 76 ignored_window_(NULL), |
| 77 grid_size_(0), | 77 grid_size_(0), |
| 78 open_new_windows_maximized_(true), | 78 open_new_windows_maximized_(false), |
| 79 shelf_(NULL) { | 79 shelf_(NULL) { |
| 80 DCHECK(contents_view); | 80 DCHECK(contents_view); |
| 81 } | 81 } |
| 82 | 82 |
| 83 WorkspaceManager::~WorkspaceManager() { | 83 WorkspaceManager::~WorkspaceManager() { |
| 84 for (size_t i = 0; i < workspaces_.size(); ++i) { | 84 for (size_t i = 0; i < workspaces_.size(); ++i) { |
| 85 Workspace* workspace = workspaces_[i]; | 85 Workspace* workspace = workspaces_[i]; |
| 86 for (size_t j = 0; j < workspace->windows().size(); ++j) | 86 for (size_t j = 0; j < workspace->windows().size(); ++j) |
| 87 workspace->windows()[j]->RemoveObserver(this); | 87 workspace->windows()[j]->RemoveObserver(this); |
| 88 } | 88 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 ignored_window_ = NULL; | 355 ignored_window_ = NULL; |
| 356 } | 356 } |
| 357 | 357 |
| 358 void WorkspaceManager::SetWindowBoundsFromRestoreBounds(aura::Window* window) { | 358 void WorkspaceManager::SetWindowBoundsFromRestoreBounds(aura::Window* window) { |
| 359 const gfx::Rect* restore = GetRestoreBounds(window); | 359 const gfx::Rect* restore = GetRestoreBounds(window); |
| 360 gfx::Rect bounds; | 360 gfx::Rect bounds; |
| 361 if (restore) | 361 if (restore) |
| 362 bounds = restore->AdjustToFit(GetWorkAreaBounds()); | 362 bounds = restore->AdjustToFit(GetWorkAreaBounds()); |
| 363 else | 363 else |
| 364 bounds = window->bounds().AdjustToFit(GetWorkAreaBounds()); | 364 bounds = window->bounds().AdjustToFit(GetWorkAreaBounds()); |
| 365 SetWindowBounds(window, AlignRectToGrid(bounds, grid_size_)); | 365 SetWindowBounds(window, bounds); |
| 366 ash::ClearRestoreBounds(window); | 366 ash::ClearRestoreBounds(window); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void WorkspaceManager::SetFullScreenOrMaximizedBounds(aura::Window* window) { | 369 void WorkspaceManager::SetFullScreenOrMaximizedBounds(aura::Window* window) { |
| 370 if (!GetRestoreBounds(window)) | 370 if (!GetRestoreBounds(window)) |
| 371 SetRestoreBounds(window, window->GetTargetBounds()); | 371 SetRestoreBounds(window, window->GetTargetBounds()); |
| 372 if (window_util::IsWindowMaximized(window)) | 372 if (window_util::IsWindowMaximized(window)) |
| 373 SetWindowBounds(window, GetWorkAreaBounds()); | 373 SetWindowBounds(window, GetWorkAreaBounds()); |
| 374 else if (window_util::IsWindowFullscreen(window)) | 374 else if (window_util::IsWindowFullscreen(window)) |
| 375 SetWindowBounds(window, gfx::Screen::GetMonitorAreaNearestWindow(window)); | 375 SetWindowBounds(window, gfx::Screen::GetMonitorAreaNearestWindow(window)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 if (type == Workspace::TYPE_MAXIMIZED) | 418 if (type == Workspace::TYPE_MAXIMIZED) |
| 419 workspace = new MaximizedWorkspace(this); | 419 workspace = new MaximizedWorkspace(this); |
| 420 else | 420 else |
| 421 workspace = new ManagedWorkspace(this); | 421 workspace = new ManagedWorkspace(this); |
| 422 AddWorkspace(workspace); | 422 AddWorkspace(workspace); |
| 423 return workspace; | 423 return workspace; |
| 424 } | 424 } |
| 425 | 425 |
| 426 } // namespace internal | 426 } // namespace internal |
| 427 } // namespace ash | 427 } // namespace ash |
| OLD | NEW |