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 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 pending_workspaces_.insert(workspace); | 255 pending_workspaces_.insert(workspace); |
256 return workspace->window(); | 256 return workspace->window(); |
257 } | 257 } |
258 | 258 |
259 if (!GetTrackedByWorkspace(window) || GetPersistsAcrossAllWorkspaces(window)) | 259 if (!GetTrackedByWorkspace(window) || GetPersistsAcrossAllWorkspaces(window)) |
260 return active_workspace_->window(); | 260 return active_workspace_->window(); |
261 | 261 |
262 return desktop_workspace()->window(); | 262 return desktop_workspace()->window(); |
263 } | 263 } |
264 | 264 |
265 bool WorkspaceManager::CycleToWorkspace(CycleDirection direction) { | |
266 aura::Window* active_window = wm::GetActiveWindow(); | |
267 if (!active_workspace_->window()->Contains(active_window)) | |
268 active_window = NULL; | |
269 | |
270 Workspaces::const_iterator workspace_i(FindWorkspace(active_workspace_)); | |
271 int workspace_offset = 0; | |
272 if (direction == CYCLE_PREVIOUS) { | |
273 workspace_offset = 1; | |
274 if (workspace_i == workspaces_.end() - 1) | |
275 return false; | |
276 } else { | |
277 workspace_offset = -1; | |
278 if (workspace_i == workspaces_.begin()) | |
279 return false; | |
280 } | |
281 | |
282 Workspaces::const_iterator next_workspace_i(workspace_i + workspace_offset); | |
283 SetActiveWorkspace(*next_workspace_i, SWITCH_OTHER, base::TimeDelta()); | |
284 | |
285 // The activation controller will pick a window from the just activated | |
286 // workspace to activate as a result of DeactivateWindow(). | |
287 if (active_window) | |
sky
2012/11/30 02:32:16
Add a TODO here, we shouldn't need to do this.
| |
288 wm::DeactivateWindow(active_window); | |
289 return true; | |
290 } | |
291 | |
265 void WorkspaceManager::DoInitialAnimation() { | 292 void WorkspaceManager::DoInitialAnimation() { |
266 if (active_workspace_->is_maximized()) { | 293 if (active_workspace_->is_maximized()) { |
267 RootWindowController* root_controller = GetRootWindowController( | 294 RootWindowController* root_controller = GetRootWindowController( |
268 contents_view_->GetRootWindow()); | 295 contents_view_->GetRootWindow()); |
269 if (root_controller) { | 296 if (root_controller) { |
270 aura::Window* background = root_controller->GetContainer( | 297 aura::Window* background = root_controller->GetContainer( |
271 kShellWindowId_DesktopBackgroundContainer); | 298 kShellWindowId_DesktopBackgroundContainer); |
272 background->Show(); | 299 background->Show(); |
273 ShowOrHideDesktopBackground(background, SWITCH_INITIAL, | 300 ShowOrHideDesktopBackground(background, SWITCH_INITIAL, |
274 base::TimeDelta(), false); | 301 base::TimeDelta(), false); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 new_workspace->window()->Show(); | 760 new_workspace->window()->Show(); |
734 ReparentWindow(window, new_workspace->window(), NULL); | 761 ReparentWindow(window, new_workspace->window(), NULL); |
735 if (is_active) { | 762 if (is_active) { |
736 SetActiveWorkspace(new_workspace, SWITCH_TRACKED_BY_WORKSPACE_CHANGED, | 763 SetActiveWorkspace(new_workspace, SWITCH_TRACKED_BY_WORKSPACE_CHANGED, |
737 base::TimeDelta()); | 764 base::TimeDelta()); |
738 } | 765 } |
739 } | 766 } |
740 | 767 |
741 } // namespace internal | 768 } // namespace internal |
742 } // namespace ash | 769 } // namespace ash |
OLD | NEW |