| 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" |
| 11 #include "ash/wm/shelf_layout_manager.h" | 11 #include "ash/wm/shelf_layout_manager.h" |
| 12 #include "ash/wm/window_animations.h" | 12 #include "ash/wm/window_animations.h" |
| 13 #include "ash/wm/window_resizer.h" | 13 #include "ash/wm/window_resizer.h" |
| 14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 15 #include "ash/wm/workspace/managed_workspace.h" | 15 #include "ash/wm/workspace/managed_workspace.h" |
| 16 #include "ash/wm/workspace/maximized_workspace.h" | 16 #include "ash/wm/workspace/maximized_workspace.h" |
| 17 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
| 20 #include "ui/aura/env.h" |
| 20 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
| 21 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
| 22 #include "ui/aura/screen_aura.h" | 23 #include "ui/aura/monitor.h" |
| 24 #include "ui/aura/monitor_manager.h" |
| 23 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 24 #include "ui/base/ui_base_types.h" | 26 #include "ui/base/ui_base_types.h" |
| 25 #include "ui/gfx/compositor/layer.h" | 27 #include "ui/gfx/compositor/layer.h" |
| 26 #include "ui/gfx/compositor/layer_animator.h" | 28 #include "ui/gfx/compositor/layer_animator.h" |
| 27 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" | 29 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" |
| 28 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
| 29 #include "ui/gfx/transform.h" | 31 #include "ui/gfx/transform.h" |
| 30 | 32 |
| 31 namespace { | 33 namespace { |
| 32 | 34 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 NOTIMPLEMENTED(); | 152 NOTIMPLEMENTED(); |
| 151 } | 153 } |
| 152 | 154 |
| 153 void WorkspaceManager::SetWorkspaceSize(const gfx::Size& workspace_size) { | 155 void WorkspaceManager::SetWorkspaceSize(const gfx::Size& workspace_size) { |
| 154 if (workspace_size == workspace_size_) | 156 if (workspace_size == workspace_size_) |
| 155 return; | 157 return; |
| 156 workspace_size_ = workspace_size; | 158 workspace_size_ = workspace_size; |
| 157 SetWorkspaceBounds(); | 159 SetWorkspaceBounds(); |
| 158 } | 160 } |
| 159 | 161 |
| 160 void WorkspaceManager::OnScreenWorkAreaInsetsChanged() { | 162 void WorkspaceManager::OnMonitorWorkAreaInsetsChanged() { |
| 161 SetWorkspaceBounds(); | 163 SetWorkspaceBounds(); |
| 162 } | 164 } |
| 163 | 165 |
| 164 gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { | 166 gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { |
| 165 if (grid_size_ <= 1) | 167 if (grid_size_ <= 1) |
| 166 return bounds; | 168 return bounds; |
| 167 return AlignRectToGrid(bounds, grid_size_); | 169 return AlignRectToGrid(bounds, grid_size_); |
| 168 } | 170 } |
| 169 | 171 |
| 170 void WorkspaceManager::ShowStateChanged(aura::Window* window) { | 172 void WorkspaceManager::ShowStateChanged(aura::Window* window) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 active_workspace_ = workspace; | 281 active_workspace_ = workspace; |
| 280 if (active_workspace_) { | 282 if (active_workspace_) { |
| 281 SetVisibilityOfWorkspaceWindows(active_workspace_, | 283 SetVisibilityOfWorkspaceWindows(active_workspace_, |
| 282 last_active ? ANIMATE : DONT_ANIMATE, true); | 284 last_active ? ANIMATE : DONT_ANIMATE, true); |
| 283 UpdateShelfVisibility(); | 285 UpdateShelfVisibility(); |
| 284 } | 286 } |
| 285 | 287 |
| 286 is_overview_ = false; | 288 is_overview_ = false; |
| 287 } | 289 } |
| 288 | 290 |
| 289 gfx::Rect WorkspaceManager::GetWorkAreaBounds() { | 291 gfx::Rect WorkspaceManager::GetWorkAreaBounds() const { |
| 290 gfx::Rect bounds(workspace_size_); | 292 gfx::Rect bounds(workspace_size_); |
| 291 bounds.Inset(Shell::GetRootWindow()->screen()->work_area_insets()); | 293 const aura::MonitorManager* monitor_manager = |
| 294 aura::Env::GetInstance()->monitor_manager(); |
| 295 const aura::Monitor* monitor = |
| 296 monitor_manager->GetMonitorNearestWindow(contents_view_); |
| 297 bounds.Inset(monitor->work_area_insets()); |
| 292 return bounds; | 298 return bounds; |
| 293 } | 299 } |
| 294 | 300 |
| 295 // Returns the index of the workspace that contains the |window|. | 301 // Returns the index of the workspace that contains the |window|. |
| 296 int WorkspaceManager::GetWorkspaceIndexContaining(aura::Window* window) const { | 302 int WorkspaceManager::GetWorkspaceIndexContaining(aura::Window* window) const { |
| 297 for (Workspaces::const_iterator i = workspaces_.begin(); | 303 for (Workspaces::const_iterator i = workspaces_.begin(); |
| 298 i != workspaces_.end(); | 304 i != workspaces_.end(); |
| 299 ++i) { | 305 ++i) { |
| 300 if ((*i)->Contains(window)) | 306 if ((*i)->Contains(window)) |
| 301 return i - workspaces_.begin(); | 307 return i - workspaces_.begin(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 if (type == Workspace::TYPE_MAXIMIZED) | 363 if (type == Workspace::TYPE_MAXIMIZED) |
| 358 workspace = new MaximizedWorkspace(this); | 364 workspace = new MaximizedWorkspace(this); |
| 359 else | 365 else |
| 360 workspace = new ManagedWorkspace(this); | 366 workspace = new ManagedWorkspace(this); |
| 361 AddWorkspace(workspace); | 367 AddWorkspace(workspace); |
| 362 return workspace; | 368 return workspace; |
| 363 } | 369 } |
| 364 | 370 |
| 365 } // namespace internal | 371 } // namespace internal |
| 366 } // namespace ash | 372 } // namespace ash |
| OLD | NEW |