| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/workspace/workspace.h" | 5 #include "ui/aura_shell/workspace/workspace.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "ui/aura/desktop.h" | 10 #include "ui/aura/desktop.h" |
| 9 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 10 #include "ui/aura_shell/workspace/workspace_manager.h" | 12 #include "ui/aura_shell/workspace/workspace_manager.h" |
| 11 #include "ui/gfx/compositor/layer.h" | 13 #include "ui/gfx/compositor/layer.h" |
| 12 #include "ui/gfx/compositor/layer_animator.h" | 14 #include "ui/gfx/compositor/layer_animator.h" |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 // Horizontal margin between windows. | 17 // Horizontal margin between windows. |
| 16 const int kWindowHorizontalMargin = 10; | 18 const int kWindowHorizontalMargin = 10; |
| 17 | 19 |
| 18 // Maximum number of windows a workspace can have. | 20 // Maximum number of windows a workspace can have. |
| 19 size_t g_max_windows_per_workspace = 2; | 21 size_t g_max_windows_per_workspace = 2; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace aura_shell { | 24 namespace aura_shell { |
| 25 namespace internal { |
| 23 | 26 |
| 24 Workspace::Workspace(WorkspaceManager* manager) | 27 Workspace::Workspace(WorkspaceManager* manager) |
| 25 : workspace_manager_(manager) { | 28 : workspace_manager_(manager) { |
| 26 workspace_manager_->AddWorkspace(this); | 29 workspace_manager_->AddWorkspace(this); |
| 27 } | 30 } |
| 28 | 31 |
| 29 Workspace::~Workspace() { | 32 Workspace::~Workspace() { |
| 30 workspace_manager_->RemoveWorkspace(this); | 33 workspace_manager_->RemoveWorkspace(this); |
| 31 } | 34 } |
| 32 | 35 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 void Workspace::MoveWindowTo( | 207 void Workspace::MoveWindowTo( |
| 205 aura::Window* window, | 208 aura::Window* window, |
| 206 const gfx::Point& origin, | 209 const gfx::Point& origin, |
| 207 bool animate) { | 210 bool animate) { |
| 208 if (window->show_state() == ui::SHOW_STATE_FULLSCREEN) | 211 if (window->show_state() == ui::SHOW_STATE_FULLSCREEN) |
| 209 window->Fullscreen(); | 212 window->Fullscreen(); |
| 210 else if (window->show_state() == ui::SHOW_STATE_MAXIMIZED) | 213 else if (window->show_state() == ui::SHOW_STATE_MAXIMIZED) |
| 211 window->Maximize(); | 214 window->Maximize(); |
| 212 else { | 215 else { |
| 213 gfx::Rect bounds = window->GetTargetBounds(); | 216 gfx::Rect bounds = window->GetTargetBounds(); |
| 214 bounds.set_origin(origin); | 217 gfx::Rect work_area = GetWorkAreaBounds(); |
| 218 // Make sure the window isn't bigger than the workspace size. |
| 219 bounds.SetRect(origin.x(), origin.y(), |
| 220 std::min(work_area.width(), bounds.width()), |
| 221 std::min(work_area.height(), bounds.height())); |
| 215 if (animate) { | 222 if (animate) { |
| 216 ui::LayerAnimator::ScopedSettings settings( | 223 ui::LayerAnimator::ScopedSettings settings( |
| 217 window->layer()->GetAnimator()); | 224 window->layer()->GetAnimator()); |
| 218 window->SetBounds(bounds); | 225 window->SetBounds(bounds); |
| 219 } else { | 226 } else { |
| 220 window->SetBounds(bounds); | 227 window->SetBounds(bounds); |
| 221 } | 228 } |
| 222 } | 229 } |
| 223 } | 230 } |
| 224 | 231 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 235 return total_width; | 242 return total_width; |
| 236 } | 243 } |
| 237 | 244 |
| 238 // static | 245 // static |
| 239 size_t Workspace::SetMaxWindowsCount(size_t max) { | 246 size_t Workspace::SetMaxWindowsCount(size_t max) { |
| 240 int old = g_max_windows_per_workspace; | 247 int old = g_max_windows_per_workspace; |
| 241 g_max_windows_per_workspace = max; | 248 g_max_windows_per_workspace = max; |
| 242 return old; | 249 return old; |
| 243 } | 250 } |
| 244 | 251 |
| 252 } // namespace internal |
| 245 } // namespace aura_shell | 253 } // namespace aura_shell |
| OLD | NEW |