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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/desktop.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura_shell/workspace/workspace_manager.h" | 10 #include "ui/aura_shell/workspace/workspace_manager.h" |
11 #include "ui/gfx/compositor/layer.h" | 11 #include "ui/gfx/compositor/layer.h" |
12 #include "ui/gfx/compositor/layer_animator.h" | |
13 | 12 |
14 namespace { | 13 namespace { |
15 // Horizontal margin between windows. | 14 // Horizontal margin between windows. |
16 const int kWindowHorizontalMargin = 10; | 15 const int kWindowHorizontalMargin = 10; |
17 | 16 |
18 // Maximum number of windows a workspace can have. | 17 // Maximum number of windows a workspace can have. |
19 size_t g_max_windows_per_workspace = 2; | 18 size_t g_max_windows_per_workspace = 2; |
20 } | 19 } |
21 | 20 |
22 namespace aura_shell { | 21 namespace aura_shell { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 aura::Window* window, | 204 aura::Window* window, |
206 const gfx::Point& origin, | 205 const gfx::Point& origin, |
207 bool animate) { | 206 bool animate) { |
208 if (window->show_state() == ui::SHOW_STATE_FULLSCREEN) | 207 if (window->show_state() == ui::SHOW_STATE_FULLSCREEN) |
209 window->Fullscreen(); | 208 window->Fullscreen(); |
210 else if (window->show_state() == ui::SHOW_STATE_MAXIMIZED) | 209 else if (window->show_state() == ui::SHOW_STATE_MAXIMIZED) |
211 window->Maximize(); | 210 window->Maximize(); |
212 else { | 211 else { |
213 gfx::Rect bounds = window->GetTargetBounds(); | 212 gfx::Rect bounds = window->GetTargetBounds(); |
214 bounds.set_origin(origin); | 213 bounds.set_origin(origin); |
215 if (animate) { | 214 if (animate) |
216 ui::LayerAnimator::ScopedSettings settings( | 215 window->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); |
217 window->layer()->GetAnimator()); | 216 window->SetBounds(bounds); |
218 window->SetBounds(bounds); | |
219 } else { | |
220 window->SetBounds(bounds); | |
221 } | |
222 } | 217 } |
223 } | 218 } |
224 | 219 |
225 int Workspace::GetTotalWindowsWidth() const { | 220 int Workspace::GetTotalWindowsWidth() const { |
226 int total_width = 0; | 221 int total_width = 0; |
227 for (aura::Window::Windows::const_iterator i = windows_.begin(); | 222 for (aura::Window::Windows::const_iterator i = windows_.begin(); |
228 i != windows_.end(); | 223 i != windows_.end(); |
229 ++i) { | 224 ++i) { |
230 if (total_width) | 225 if (total_width) |
231 total_width += kWindowHorizontalMargin; | 226 total_width += kWindowHorizontalMargin; |
232 // TODO(oshima): use restored bounds. | 227 // TODO(oshima): use restored bounds. |
233 total_width += (*i)->bounds().width(); | 228 total_width += (*i)->bounds().width(); |
234 } | 229 } |
235 return total_width; | 230 return total_width; |
236 } | 231 } |
237 | 232 |
238 // static | 233 // static |
239 size_t Workspace::SetMaxWindowsCount(size_t max) { | 234 size_t Workspace::SetMaxWindowsCount(size_t max) { |
240 int old = g_max_windows_per_workspace; | 235 int old = g_max_windows_per_workspace; |
241 g_max_windows_per_workspace = max; | 236 g_max_windows_per_workspace = max; |
242 return old; | 237 return old; |
243 } | 238 } |
244 | 239 |
245 } // namespace aura_shell | 240 } // namespace aura_shell |
OLD | NEW |