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 "ash/wm/workspace/workspace.h" | 5 #include "ash/wm/workspace/workspace.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/wm/property_util.h" | 9 #include "ash/wm/property_util.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Maximum number of windows a workspace can have. | 24 // Maximum number of windows a workspace can have. |
25 size_t g_max_windows_per_workspace = 2; | 25 size_t g_max_windows_per_workspace = 2; |
26 | 26 |
27 // Returns the bounds of the window that should be used to calculate | 27 // Returns the bounds of the window that should be used to calculate |
28 // the layout. It uses the restore bounds if exits, or | 28 // the layout. It uses the restore bounds if exits, or |
29 // the target bounds of the window. The target bounds is the | 29 // the target bounds of the window. The target bounds is the |
30 // final destination of |window| if the window's layer is animating, | 30 // final destination of |window| if the window's layer is animating, |
31 // or the current bounds of the window of no animation is currently | 31 // or the current bounds of the window of no animation is currently |
32 // in progress. | 32 // in progress. |
33 gfx::Rect GetLayoutBounds(aura::Window* window) { | 33 gfx::Rect GetLayoutBounds(aura::Window* window) { |
34 const gfx::Rect* restore_bounds = aura_shell::GetRestoreBounds(window); | 34 const gfx::Rect* restore_bounds = ash::GetRestoreBounds(window); |
35 return restore_bounds ? *restore_bounds : window->GetTargetBounds(); | 35 return restore_bounds ? *restore_bounds : window->GetTargetBounds(); |
36 } | 36 } |
37 | 37 |
38 // Returns the width of the window that should be used to calculate | 38 // Returns the width of the window that should be used to calculate |
39 // the layout. See |GetLayoutBounds| for more details. | 39 // the layout. See |GetLayoutBounds| for more details. |
40 int GetLayoutWidth(aura::Window* window) { | 40 int GetLayoutWidth(aura::Window* window) { |
41 return GetLayoutBounds(window).width(); | 41 return GetLayoutBounds(window).width(); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 namespace aura_shell { | 46 namespace ash { |
47 namespace internal { | 47 namespace internal { |
48 | 48 |
49 Workspace::Workspace(WorkspaceManager* manager) | 49 Workspace::Workspace(WorkspaceManager* manager) |
50 : workspace_manager_(manager) { | 50 : workspace_manager_(manager) { |
51 workspace_manager_->AddWorkspace(this); | 51 workspace_manager_->AddWorkspace(this); |
52 } | 52 } |
53 | 53 |
54 Workspace::~Workspace() { | 54 Workspace::~Workspace() { |
55 workspace_manager_->RemoveWorkspace(this); | 55 workspace_manager_->RemoveWorkspace(this); |
56 } | 56 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 windows_.erase(std::find(windows_.begin(), windows_.end(), window)); | 89 windows_.erase(std::find(windows_.begin(), windows_.end(), window)); |
90 Layout(NULL); | 90 Layout(NULL); |
91 } | 91 } |
92 | 92 |
93 bool Workspace::Contains(aura::Window* window) const { | 93 bool Workspace::Contains(aura::Window* window) const { |
94 return std::find(windows_.begin(), windows_.end(), window) != windows_.end(); | 94 return std::find(windows_.begin(), windows_.end(), window) != windows_.end(); |
95 } | 95 } |
96 | 96 |
97 aura::Window* Workspace::FindRotateWindowForLocation( | 97 aura::Window* Workspace::FindRotateWindowForLocation( |
98 const gfx::Point& position) { | 98 const gfx::Point& position) { |
99 aura::Window* active = aura_shell::GetActiveWindow(); | 99 aura::Window* active = ash::GetActiveWindow(); |
100 if (GetTotalWindowsWidth() < bounds_.width()) { | 100 if (GetTotalWindowsWidth() < bounds_.width()) { |
101 // If all windows fit to the width of the workspace, it returns the | 101 // If all windows fit to the width of the workspace, it returns the |
102 // window which contains |position|'s x coordinate. | 102 // window which contains |position|'s x coordinate. |
103 for (aura::Window::Windows::const_iterator i = windows_.begin(); | 103 for (aura::Window::Windows::const_iterator i = windows_.begin(); |
104 i != windows_.end(); | 104 i != windows_.end(); |
105 ++i) { | 105 ++i) { |
106 if (active == *i) | 106 if (active == *i) |
107 continue; | 107 continue; |
108 gfx::Rect bounds = (*i)->GetTargetBounds(); | 108 gfx::Rect bounds = (*i)->GetTargetBounds(); |
109 if (bounds.x() < position.x() && position.x() < bounds.right()) | 109 if (bounds.x() < position.x() && position.x() < bounds.right()) |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 276 } |
277 | 277 |
278 // static | 278 // static |
279 size_t Workspace::SetMaxWindowsCount(size_t max) { | 279 size_t Workspace::SetMaxWindowsCount(size_t max) { |
280 int old = g_max_windows_per_workspace; | 280 int old = g_max_windows_per_workspace; |
281 g_max_windows_per_workspace = max; | 281 g_max_windows_per_workspace = max; |
282 return old; | 282 return old; |
283 } | 283 } |
284 | 284 |
285 } // namespace internal | 285 } // namespace internal |
286 } // namespace aura_shell | 286 } // namespace ash |
OLD | NEW |