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/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 WorkspaceManager::~WorkspaceManager() { | 64 WorkspaceManager::~WorkspaceManager() { |
65 std::vector<Workspace*> copy_to_delete(workspaces_); | 65 std::vector<Workspace*> copy_to_delete(workspaces_); |
66 STLDeleteElements(©_to_delete); | 66 STLDeleteElements(©_to_delete); |
67 } | 67 } |
68 | 68 |
69 // static | 69 // static |
70 bool WorkspaceManager::ShouldManageWindow(aura::Window* window) { | 70 bool WorkspaceManager::ShouldManageWindow(aura::Window* window) { |
71 return window->type() == aura::client::WINDOW_TYPE_NORMAL && | 71 return window->type() == aura::client::WINDOW_TYPE_NORMAL && |
72 !window->transient_parent() && | 72 !window->transient_parent() && |
73 ash::GetTrackedByWorkspace(window) && | 73 ash::GetTrackedByWorkspace(window) && |
74 !ash::GetPersistsAcrossAllWorkspaces(window); | 74 (!ash::GetPersistsAcrossAllWorkspaces(window) || |
| 75 wm::IsWindowMaximized(window)); |
75 } | 76 } |
76 | 77 |
77 bool WorkspaceManager::Contains(aura::Window* window) const { | 78 bool WorkspaceManager::Contains(aura::Window* window) const { |
78 return FindBy(window) != NULL; | 79 return FindBy(window) != NULL; |
79 } | 80 } |
80 | 81 |
81 bool WorkspaceManager::IsInMaximizedMode() const { | 82 bool WorkspaceManager::IsInMaximizedMode() const { |
82 return active_workspace_ && | 83 return active_workspace_ && |
83 active_workspace_->type() == Workspace::TYPE_MAXIMIZED; | 84 active_workspace_->type() == Workspace::TYPE_MAXIMIZED; |
84 } | 85 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 window_overlaps_launcher = true; | 164 window_overlaps_launcher = true; |
164 } | 165 } |
165 if (has_maximized_window) | 166 if (has_maximized_window) |
166 return WINDOW_STATE_MAXIMIZED; | 167 return WINDOW_STATE_MAXIMIZED; |
167 | 168 |
168 return window_overlaps_launcher ? WINDOW_STATE_WINDOW_OVERLAPS_SHELF : | 169 return window_overlaps_launcher ? WINDOW_STATE_WINDOW_OVERLAPS_SHELF : |
169 WINDOW_STATE_DEFAULT; | 170 WINDOW_STATE_DEFAULT; |
170 } | 171 } |
171 | 172 |
172 void WorkspaceManager::ShowStateChanged(aura::Window* window) { | 173 void WorkspaceManager::ShowStateChanged(aura::Window* window) { |
173 if (!ShouldManageWindow(window) || !FindBy(window)) | 174 Workspace* workspace = FindBy(window); |
| 175 if (!workspace) |
174 return; | 176 return; |
175 | 177 if (!ShouldManageWindow(window)) { |
176 Workspace::Type old_type = FindBy(window)->type(); | 178 RemoveWindow(window); |
177 Workspace::Type new_type = Workspace::TypeForWindow(window); | 179 } else { |
178 if (new_type != old_type) | 180 Workspace::Type old_type = workspace->type(); |
179 OnTypeOfWorkspacedNeededChanged(window); | 181 Workspace::Type new_type = Workspace::TypeForWindow(window); |
| 182 if (new_type != old_type) |
| 183 OnTypeOfWorkspacedNeededChanged(window); |
| 184 } |
180 UpdateShelfVisibility(); | 185 UpdateShelfVisibility(); |
181 } | 186 } |
182 | 187 |
183 //////////////////////////////////////////////////////////////////////////////// | 188 //////////////////////////////////////////////////////////////////////////////// |
184 // WorkspaceManager, private: | 189 // WorkspaceManager, private: |
185 | 190 |
186 void WorkspaceManager::AddWorkspace(Workspace* workspace) { | 191 void WorkspaceManager::AddWorkspace(Workspace* workspace) { |
187 DCHECK(std::find(workspaces_.begin(), workspaces_.end(), | 192 DCHECK(std::find(workspaces_.begin(), workspaces_.end(), |
188 workspace) == workspaces_.end()); | 193 workspace) == workspaces_.end()); |
189 if (active_workspace_) { | 194 if (active_workspace_) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 return workspace; | 347 return workspace; |
343 } | 348 } |
344 | 349 |
345 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) { | 350 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) { |
346 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty()) | 351 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty()) |
347 delete workspace; | 352 delete workspace; |
348 } | 353 } |
349 | 354 |
350 } // namespace internal | 355 } // namespace internal |
351 } // namespace ash | 356 } // namespace ash |
OLD | NEW |