Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2650)

Unified Diff: ash/wm/workspace/workspace_manager.cc

Issue 11417150: Implement workspace scrubbing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0a0c5267b6371a3a7d9cdafcc9c7c5b35c0a747b 100644
--- a/ash/wm/workspace/workspace_manager.cc
+++ b/ash/wm/workspace/workspace_manager.cc
@@ -131,11 +131,14 @@ WorkspaceManager::~WorkspaceManager() {
// destroyed.
std::for_each(workspaces_.begin(), workspaces_.end(),
std::mem_fun(&Workspace::ReleaseWindow));
+ std::for_each(hidden_workspaces_.begin(), hidden_workspaces_.end(),
+ std::mem_fun(&Workspace::ReleaseWindow));
std::for_each(pending_workspaces_.begin(), pending_workspaces_.end(),
std::mem_fun(&Workspace::ReleaseWindow));
std::for_each(to_delete_.begin(), to_delete_.end(),
std::mem_fun(&Workspace::ReleaseWindow));
STLDeleteElements(&workspaces_);
+ STLDeleteElements(&hidden_workspaces_);
STLDeleteElements(&pending_workspaces_);
STLDeleteElements(&to_delete_);
}
@@ -264,6 +267,35 @@ Window* WorkspaceManager::GetParentForNewWindow(Window* window) {
return desktop_workspace()->window();
}
+bool WorkspaceManager::CycleToNextUnhiddenWorkspace() {
+ if (active_workspace_ == desktop_workspace())
+ return false;
+
+ aura::Window* active_window = active_workspace_->GetActiveWindow();
+ MoveWorkspaceToHiddenOrDelete(active_workspace_, NULL, SWITCH_OTHER);
+
+ // 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);
+ return true;
+}
+
+bool WorkspaceManager::CycleToNextHiddenWorkspace() {
+ if (hidden_workspaces_.empty())
+ return false;
+
+ aura::Window* active_window = active_workspace_->GetActiveWindow();
+ SetActiveWorkspace(hidden_workspaces_.back(), SWITCH_OTHER,
+ 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);
+ return true;
+}
+
void WorkspaceManager::DoInitialAnimation() {
if (active_workspace_->is_maximized()) {
RootWindowController* root_controller = GetRootWindowController(
@@ -279,6 +311,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;
}
@@ -305,6 +341,10 @@ void WorkspaceManager::SetActiveWorkspace(Workspace* workspace,
if (active_workspace_ == workspace)
return;
+ Workspaces::iterator it = std::find(
+ hidden_workspaces_.begin(), hidden_workspaces_.end(), workspace);
+ if (it != hidden_workspaces_.end())
+ hidden_workspaces_.erase(it);
pending_workspaces_.erase(workspace);
// Adjust the z-order. No need to adjust the z-order for the desktop since
@@ -371,7 +411,7 @@ Workspace* WorkspaceManager::CreateWorkspace(bool maximized) {
return new Workspace(this, contents_view_, maximized);
}
-void WorkspaceManager::MoveWorkspaceToPendingOrDelete(
+void WorkspaceManager::MoveWorkspaceToHiddenOrDelete(
Workspace* workspace,
Window* stack_beneath,
SwitchReason reason) {
@@ -388,19 +428,26 @@ void WorkspaceManager::MoveWorkspaceToPendingOrDelete(
MoveChildrenToDesktop(workspace->window(), stack_beneath);
+ bool workspace_previously_active = false;
{
Workspaces::iterator workspace_i(FindWorkspace(workspace));
- if (workspace_i != workspaces_.end())
+ if (workspace_i != workspaces_.end()) {
workspaces_.erase(workspace_i);
+ workspace_previously_active = true;
+ }
}
if (workspace->window()->children().empty()) {
if (workspace == unminimizing_workspace_)
unminimizing_workspace_ = NULL;
+ Workspaces::iterator hidden_i = std::find(
+ hidden_workspaces_.begin(), hidden_workspaces_.end(), workspace);
+ if (hidden_i != hidden_workspaces_.end())
+ hidden_workspaces_.erase(hidden_i);
pending_workspaces_.erase(workspace);
ScheduleDelete(workspace);
- } else {
- pending_workspaces_.insert(workspace);
+ } else if (workspace_previously_active) {
+ hidden_workspaces_.push_back(workspace);
}
}
@@ -620,15 +667,15 @@ void WorkspaceManager::OnWillRemoveWindowFromWorkspace(Workspace* workspace,
void WorkspaceManager::OnWindowRemovedFromWorkspace(Workspace* workspace,
Window* child) {
- if (workspace->ShouldMoveToPending())
- MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED);
+ if (workspace->ShouldMoveToHidden())
+ MoveWorkspaceToHiddenOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED);
}
void WorkspaceManager::OnWorkspaceChildWindowVisibilityChanged(
Workspace* workspace,
Window* child) {
- if (workspace->ShouldMoveToPending()) {
- MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_VISIBILITY_CHANGED);
+ if (workspace->ShouldMoveToHidden()) {
+ MoveWorkspaceToHiddenOrDelete(workspace, NULL, SWITCH_VISIBILITY_CHANGED);
} else {
if (child->TargetVisibility())
RearrangeVisibleWindowOnShow(child);
@@ -654,8 +701,8 @@ void WorkspaceManager::OnWorkspaceWindowShowStateChanged(
// |child| better still be in |workspace| else things have gone wrong.
DCHECK_EQ(workspace, child->GetProperty(kWorkspaceKey));
if (wm::IsWindowMinimized(child)) {
- if (workspace->ShouldMoveToPending())
- MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_MINIMIZED);
+ if (workspace->ShouldMoveToHidden())
+ MoveWorkspaceToHiddenOrDelete(workspace, NULL, SWITCH_MINIMIZED);
DCHECK(!old_layer);
} else {
// Set of cases to deal with:
@@ -681,7 +728,7 @@ void WorkspaceManager::OnWorkspaceWindowShowStateChanged(
new_workspace = desktop_workspace();
SetActiveWorkspace(new_workspace, SWITCH_MAXIMIZED_OR_RESTORED,
duration);
- MoveWorkspaceToPendingOrDelete(workspace, child,
+ MoveWorkspaceToHiddenOrDelete(workspace, child,
SWITCH_MAXIMIZED_OR_RESTORED);
if (FindWorkspace(workspace) == workspaces_.end())
workspace = NULL;

Powered by Google App Engine
This is Rietveld 408576698