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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 Workspace* workspace = workspaces_[i]; | 85 Workspace* workspace = workspaces_[i]; |
86 for (size_t j = 0; j < workspace->windows().size(); ++j) | 86 for (size_t j = 0; j < workspace->windows().size(); ++j) |
87 workspace->windows()[j]->RemoveObserver(this); | 87 workspace->windows()[j]->RemoveObserver(this); |
88 } | 88 } |
89 std::vector<Workspace*> copy_to_delete(workspaces_); | 89 std::vector<Workspace*> copy_to_delete(workspaces_); |
90 STLDeleteElements(©_to_delete); | 90 STLDeleteElements(©_to_delete); |
91 } | 91 } |
92 | 92 |
93 bool WorkspaceManager::IsManagedWindow(aura::Window* window) const { | 93 bool WorkspaceManager::IsManagedWindow(aura::Window* window) const { |
94 return window->type() == aura::client::WINDOW_TYPE_NORMAL && | 94 return window->type() == aura::client::WINDOW_TYPE_NORMAL && |
95 !window->transient_parent(); | 95 !window->transient_parent() && ash::GetTrackedByWorkspace(window); |
96 } | 96 } |
97 | 97 |
98 bool WorkspaceManager::ShouldMaximize(aura::Window* window) const { | 98 bool WorkspaceManager::ShouldMaximize(aura::Window* window) const { |
99 return !window->GetProperty(aura::client::kShowStateKey) && | 99 return !window->GetProperty(aura::client::kShowStateKey) && |
100 open_new_windows_maximized_ && | 100 open_new_windows_maximized_ && |
101 contents_view_->bounds().width() < kOpenMaximizedThreshold; | 101 contents_view_->bounds().width() < kOpenMaximizedThreshold; |
102 } | 102 } |
103 | 103 |
104 void WorkspaceManager::AddWindow(aura::Window* window) { | 104 void WorkspaceManager::AddWindow(aura::Window* window) { |
105 DCHECK(IsManagedWindow(window)); | 105 DCHECK(IsManagedWindow(window)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { | 196 gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) { |
197 if (grid_size_ <= 1) | 197 if (grid_size_ <= 1) |
198 return bounds; | 198 return bounds; |
199 return AlignRectToGrid(bounds, grid_size_); | 199 return AlignRectToGrid(bounds, grid_size_); |
200 } | 200 } |
201 | 201 |
202 void WorkspaceManager::OnWindowPropertyChanged(aura::Window* window, | 202 void WorkspaceManager::OnWindowPropertyChanged(aura::Window* window, |
203 const void* key, | 203 const void* key, |
204 intptr_t old) { | 204 intptr_t old) { |
205 if (!IsManagedWindow(window)) | 205 if (key != aura::client::kShowStateKey || !IsManagedWindow(window)) |
206 return; | |
207 | |
208 if (key != aura::client::kShowStateKey) | |
209 return; | 206 return; |
210 | 207 |
211 DCHECK(FindBy(window)); | 208 DCHECK(FindBy(window)); |
212 | 209 |
213 Workspace::Type old_type = FindBy(window)->type(); | 210 Workspace::Type old_type = FindBy(window)->type(); |
214 Workspace::Type new_type = Workspace::TypeForWindow(window); | 211 Workspace::Type new_type = Workspace::TypeForWindow(window); |
215 if (new_type != old_type) { | 212 if (new_type != old_type) { |
216 OnTypeOfWorkspacedNeededChanged(window); | 213 OnTypeOfWorkspacedNeededChanged(window); |
217 } else if (new_type == Workspace::TYPE_MAXIMIZED) { | 214 } else if (new_type == Workspace::TYPE_MAXIMIZED) { |
218 // Even though the type didn't change, the window may have gone from | 215 // Even though the type didn't change, the window may have gone from |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 if (type == Workspace::TYPE_MAXIMIZED) | 413 if (type == Workspace::TYPE_MAXIMIZED) |
417 workspace = new MaximizedWorkspace(this); | 414 workspace = new MaximizedWorkspace(this); |
418 else | 415 else |
419 workspace = new ManagedWorkspace(this); | 416 workspace = new ManagedWorkspace(this); |
420 AddWorkspace(workspace); | 417 AddWorkspace(workspace); |
421 return workspace; | 418 return workspace; |
422 } | 419 } |
423 | 420 |
424 } // namespace internal | 421 } // namespace internal |
425 } // namespace ash | 422 } // namespace ash |
OLD | NEW |