| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 void WorkspaceManager::SetOverview(bool overview) { | 164 void WorkspaceManager::SetOverview(bool overview) { |
| 165 if (is_overview_ == overview) | 165 if (is_overview_ == overview) |
| 166 return; | 166 return; |
| 167 NOTIMPLEMENTED(); | 167 NOTIMPLEMENTED(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void WorkspaceManager::SetWorkspaceSize(const gfx::Size& workspace_size) { | 170 void WorkspaceManager::SetWorkspaceSize(const gfx::Size& workspace_size) { |
| 171 if (workspace_size == workspace_size_) | 171 if (workspace_size == workspace_size_) |
| 172 return; | 172 return; |
| 173 workspace_size_ = workspace_size; | 173 workspace_size_ = workspace_size; |
| 174 for (Workspaces::const_iterator i = workspaces_.begin(); | 174 SetWorkspaceBounds(); |
| 175 i != workspaces_.end(); ++i) { | 175 } |
| 176 (*i)->SetBounds(GetWorkAreaBounds()); | 176 |
| 177 } | 177 void WorkspaceManager::OnScreenWorkAreaInsetsChanged() { |
| 178 SetWorkspaceBounds(); |
| 178 } | 179 } |
| 179 | 180 |
| 180 gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { | 181 gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { |
| 181 if (grid_size_ <= 1) | 182 if (grid_size_ <= 1) |
| 182 return bounds; | 183 return bounds; |
| 183 return AlignRectToGrid(bounds, grid_size_); | 184 return AlignRectToGrid(bounds, grid_size_); |
| 184 } | 185 } |
| 185 | 186 |
| 186 void WorkspaceManager::OnWindowPropertyChanged(aura::Window* window, | 187 void WorkspaceManager::OnWindowPropertyChanged(aura::Window* window, |
| 187 const void* key, | 188 const void* key, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 352 |
| 352 void WorkspaceManager::SetFullScreenOrMaximizedBounds(aura::Window* window) { | 353 void WorkspaceManager::SetFullScreenOrMaximizedBounds(aura::Window* window) { |
| 353 if (!GetRestoreBounds(window)) | 354 if (!GetRestoreBounds(window)) |
| 354 SetRestoreBounds(window, window->GetTargetBounds()); | 355 SetRestoreBounds(window, window->GetTargetBounds()); |
| 355 if (wm::IsWindowMaximized(window)) | 356 if (wm::IsWindowMaximized(window)) |
| 356 SetWindowBounds(window, GetWorkAreaBounds()); | 357 SetWindowBounds(window, GetWorkAreaBounds()); |
| 357 else if (wm::IsWindowFullscreen(window)) | 358 else if (wm::IsWindowFullscreen(window)) |
| 358 SetWindowBounds(window, gfx::Screen::GetMonitorAreaNearestWindow(window)); | 359 SetWindowBounds(window, gfx::Screen::GetMonitorAreaNearestWindow(window)); |
| 359 } | 360 } |
| 360 | 361 |
| 362 void WorkspaceManager::SetWorkspaceBounds() { |
| 363 for (Workspaces::const_iterator i = workspaces_.begin(); |
| 364 i != workspaces_.end(); ++i) { |
| 365 (*i)->SetBounds(GetWorkAreaBounds()); |
| 366 } |
| 367 } |
| 368 |
| 361 void WorkspaceManager::OnTypeOfWorkspacedNeededChanged(aura::Window* window) { | 369 void WorkspaceManager::OnTypeOfWorkspacedNeededChanged(aura::Window* window) { |
| 362 DCHECK(IsManagedWindow(window)); | 370 DCHECK(IsManagedWindow(window)); |
| 363 Workspace* current_workspace = FindBy(window); | 371 Workspace* current_workspace = FindBy(window); |
| 364 DCHECK(current_workspace); | 372 DCHECK(current_workspace); |
| 365 Workspace* new_workspace = NULL; | 373 Workspace* new_workspace = NULL; |
| 366 if (Workspace::TypeForWindow(window) == Workspace::TYPE_MAXIMIZED) { | 374 if (Workspace::TypeForWindow(window) == Workspace::TYPE_MAXIMIZED) { |
| 367 // Unmaximized -> maximized; create a new workspace. | 375 // Unmaximized -> maximized; create a new workspace. |
| 368 SetRestoreBounds(window, window->bounds()); | 376 SetRestoreBounds(window, window->bounds()); |
| 369 current_workspace->RemoveWindow(window); | 377 current_workspace->RemoveWindow(window); |
| 370 new_workspace = CreateWorkspace(Workspace::TYPE_MAXIMIZED); | 378 new_workspace = CreateWorkspace(Workspace::TYPE_MAXIMIZED); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 401 if (type == Workspace::TYPE_MAXIMIZED) | 409 if (type == Workspace::TYPE_MAXIMIZED) |
| 402 workspace = new MaximizedWorkspace(this); | 410 workspace = new MaximizedWorkspace(this); |
| 403 else | 411 else |
| 404 workspace = new ManagedWorkspace(this); | 412 workspace = new ManagedWorkspace(this); |
| 405 AddWorkspace(workspace); | 413 AddWorkspace(workspace); |
| 406 return workspace; | 414 return workspace; |
| 407 } | 415 } |
| 408 | 416 |
| 409 } // namespace internal | 417 } // namespace internal |
| 410 } // namespace ash | 418 } // namespace ash |
| OLD | NEW |