Chromium Code Reviews| Index: ash/wm/workspace/workspace_manager.cc |
| diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc |
| index af598e8956af08951a6fcde93b6937a956cb944a..9f0f8a8e89f5e4a87664ca0394eb1192fefc9221 100644 |
| --- a/ash/wm/workspace/workspace_manager.cc |
| +++ b/ash/wm/workspace/workspace_manager.cc |
| @@ -264,6 +264,32 @@ Window* WorkspaceManager::GetParentForNewWindow(Window* window) { |
| return desktop_workspace()->window(); |
| } |
| +bool WorkspaceManager::CycleToWorkspace(Direction direction) { |
| + aura::Window* active_window = active_workspace_->GetActiveWindow(); |
| + |
| + Workspaces::const_iterator workspace_i(FindWorkspace(active_workspace_)); |
| + int workspace_offset = 0; |
| + if (direction == WORKSPACE_ABOVE) { |
| + workspace_offset = 1; |
| + if (workspace_i == workspaces_.end() - 1) |
| + return false; |
| + } else { |
| + workspace_offset = -1; |
| + if (workspace_i == workspaces_.begin()) |
| + return false; |
| + } |
| + |
| + Workspaces::const_iterator next_workspace_i(workspace_i + workspace_offset); |
| + SetActiveWorkspace(*next_workspace_i, SWITCH_CYCLE_WORKSPACE, |
| + base::TimeDelta()); |
| + |
| + // The activation controller will pick a window from the just activated |
| + // workspace to activate as a result of DeactivateWindow(). |
| + if (active_window) |
| + wm::DeactivateWindow(active_window); |
|
sky
2012/11/28 15:15:34
I don't understand this, why do you need to to do
pkotwicz
2012/11/29 01:01:46
This is a hack. It has the effect of activating a
|
| + return true; |
| +} |
| + |
| void WorkspaceManager::DoInitialAnimation() { |
| if (active_workspace_->is_maximized()) { |
| RootWindowController* root_controller = GetRootWindowController( |
| @@ -279,6 +305,10 @@ void WorkspaceManager::DoInitialAnimation() { |
| ShowWorkspace(active_workspace_, active_workspace_, SWITCH_INITIAL); |
| } |
| +aura::Window* WorkspaceManager::GetActiveWorkspaceWindow() const { |
| + return active_workspace_->window(); |
| +} |
| + |
| void WorkspaceManager::OnAppTerminating() { |
| app_terminating_ = true; |
| } |
| @@ -307,10 +337,15 @@ void WorkspaceManager::SetActiveWorkspace(Workspace* workspace, |
| pending_workspaces_.erase(workspace); |
| - // Adjust the z-order. No need to adjust the z-order for the desktop since |
| - // it always stays at the bottom. |
| - if (workspace != desktop_workspace() && |
| - FindWorkspace(workspace) == workspaces_.end()) { |
| + // Adjust the z-order such that the active workspace is at the top of the |
| + // stack. The following exceptions apply: |
| + // - Do not adjust the desktop's z-order since it should stay at the bottom. |
| + // - Do not adjust the z-order when cycling through windows such that cycling |
| + // is linear. |
| + if (workspace != desktop_workspace() && reason != SWITCH_CYCLE_WORKSPACE) { |
| + Workspaces::iterator workspace_i = FindWorkspace(workspace); |
| + if (workspace_i != workspaces_.end()) |
| + workspaces_.erase(workspace_i); |
| contents_view_->StackChildAbove(workspace->window(), |
| workspaces_.back()->window()); |
| workspaces_.push_back(workspace); |
| @@ -382,7 +417,7 @@ void WorkspaceManager::MoveWorkspaceToPendingOrDelete( |
| DCHECK_NE(desktop_workspace(), workspace); |
| if (workspace == active_workspace_) |
| - SelectNextWorkspace(reason); |
| + SelectWorkspaceBelow(reason); |
| base::AutoReset<bool> setter(&in_move_, true); |
| @@ -427,15 +462,14 @@ void WorkspaceManager::MoveChildrenToDesktop(aura::Window* window, |
| } |
| } |
| -void WorkspaceManager::SelectNextWorkspace(SwitchReason reason) { |
| - DCHECK_NE(active_workspace_, desktop_workspace()); |
| - |
| +void WorkspaceManager::SelectWorkspaceBelow(SwitchReason reason) { |
| Workspaces::const_iterator workspace_i(FindWorkspace(active_workspace_)); |
| - Workspaces::const_iterator next_workspace_i(workspace_i + 1); |
| - if (next_workspace_i != workspaces_.end()) |
| - SetActiveWorkspace(*next_workspace_i, reason, base::TimeDelta()); |
| - else |
| - SetActiveWorkspace(*(workspace_i - 1), reason, base::TimeDelta()); |
| + if (workspace_i == workspaces_.begin()) { |
| + SetActiveWorkspace(active_workspace_, reason, base::TimeDelta()); |
| + } else { |
| + Workspaces::const_iterator workspace_below_i(workspace_i - 1); |
| + SetActiveWorkspace(*workspace_below_i, reason, base::TimeDelta()); |
| + } |
| } |
| void WorkspaceManager::ScheduleDelete(Workspace* workspace) { |