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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 Workspace* workspace = workspaces_[i]; | 81 Workspace* workspace = workspaces_[i]; |
82 for (size_t j = 0; j < workspace->windows().size(); ++j) | 82 for (size_t j = 0; j < workspace->windows().size(); ++j) |
83 workspace->windows()[j]->RemoveObserver(this); | 83 workspace->windows()[j]->RemoveObserver(this); |
84 } | 84 } |
85 std::vector<Workspace*> copy_to_delete(workspaces_); | 85 std::vector<Workspace*> copy_to_delete(workspaces_); |
86 STLDeleteElements(©_to_delete); | 86 STLDeleteElements(©_to_delete); |
87 } | 87 } |
88 | 88 |
89 bool WorkspaceManager::IsManagedWindow(aura::Window* window) const { | 89 bool WorkspaceManager::IsManagedWindow(aura::Window* window) const { |
90 return window->type() == aura::client::WINDOW_TYPE_NORMAL && | 90 return window->type() == aura::client::WINDOW_TYPE_NORMAL && |
91 !window->transient_parent(); | 91 !window->transient_parent() && ash::GetTrackedByWorkspace(window); |
92 } | 92 } |
93 | 93 |
94 void WorkspaceManager::AddWindow(aura::Window* window) { | 94 void WorkspaceManager::AddWindow(aura::Window* window) { |
95 DCHECK(IsManagedWindow(window)); | 95 DCHECK(IsManagedWindow(window)); |
96 | 96 |
97 Workspace* current_workspace = FindBy(window); | 97 Workspace* current_workspace = FindBy(window); |
98 if (current_workspace) { | 98 if (current_workspace) { |
99 // Already know about this window. Make sure the workspace is active. | 99 // Already know about this window. Make sure the workspace is active. |
100 if (active_workspace_ != current_workspace) { | 100 if (active_workspace_ != current_workspace) { |
101 if (active_workspace_) | 101 if (active_workspace_) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { | 180 gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { |
181 if (grid_size_ <= 1) | 181 if (grid_size_ <= 1) |
182 return bounds; | 182 return bounds; |
183 return AlignRectToGrid(bounds, grid_size_); | 183 return AlignRectToGrid(bounds, grid_size_); |
184 } | 184 } |
185 | 185 |
186 void WorkspaceManager::OnWindowPropertyChanged(aura::Window* window, | 186 void WorkspaceManager::OnWindowPropertyChanged(aura::Window* window, |
187 const void* key, | 187 const void* key, |
188 intptr_t old) { | 188 intptr_t old) { |
189 if (!IsManagedWindow(window)) | 189 if (key != aura::client::kShowStateKey || !IsManagedWindow(window)) |
190 return; | |
191 | |
192 if (key != aura::client::kShowStateKey) | |
193 return; | 190 return; |
194 | 191 |
195 DCHECK(FindBy(window)); | 192 DCHECK(FindBy(window)); |
196 | 193 |
197 Workspace::Type old_type = FindBy(window)->type(); | 194 Workspace::Type old_type = FindBy(window)->type(); |
198 Workspace::Type new_type = Workspace::TypeForWindow(window); | 195 Workspace::Type new_type = Workspace::TypeForWindow(window); |
199 if (new_type != old_type) { | 196 if (new_type != old_type) { |
200 OnTypeOfWorkspacedNeededChanged(window); | 197 OnTypeOfWorkspacedNeededChanged(window); |
201 } else if (new_type == Workspace::TYPE_MAXIMIZED) { | 198 } else if (new_type == Workspace::TYPE_MAXIMIZED) { |
202 // Even though the type didn't change, the window may have gone from | 199 // Even though the type didn't change, the window may have gone from |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 if (type == Workspace::TYPE_MAXIMIZED) | 398 if (type == Workspace::TYPE_MAXIMIZED) |
402 workspace = new MaximizedWorkspace(this); | 399 workspace = new MaximizedWorkspace(this); |
403 else | 400 else |
404 workspace = new ManagedWorkspace(this); | 401 workspace = new ManagedWorkspace(this); |
405 AddWorkspace(workspace); | 402 AddWorkspace(workspace); |
406 return workspace; | 403 return workspace; |
407 } | 404 } |
408 | 405 |
409 } // namespace internal | 406 } // namespace internal |
410 } // namespace ash | 407 } // namespace ash |
OLD | NEW |