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

Unified Diff: ui/aura_shell/workspace/workspace_manager.cc

Issue 8430024: Add WorkspaceObserver to observe changes in workspace state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comments Created 9 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
« no previous file with comments | « ui/aura_shell/workspace/workspace_manager.h ('k') | ui/aura_shell/workspace/workspace_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/workspace/workspace_manager.cc
diff --git a/ui/aura_shell/workspace/workspace_manager.cc b/ui/aura_shell/workspace/workspace_manager.cc
index aa777a4d23e350800c8c460c3d6560f02d81379b..ba4f21430312d8b8e3954ac2492dbcd887638b19 100644
--- a/ui/aura_shell/workspace/workspace_manager.cc
+++ b/ui/aura_shell/workspace/workspace_manager.cc
@@ -13,6 +13,7 @@
#include "ui/aura/screen_aura.h"
#include "ui/aura/window.h"
#include "ui/aura_shell/workspace/workspace.h"
+#include "ui/aura_shell/workspace/workspace_observer.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/layer_animator.h"
#include "ui/gfx/screen.h"
@@ -146,22 +147,25 @@ void WorkspaceManager::RotateWindows(aura::Window* source,
workspaces_[source_ws_index]->RotateWindows(source, target);
} else {
aura::Window* insert = source;
+ aura::Window* target_to_insert = target;
if (source_ws_index < target_ws_index) {
for (int i = target_ws_index; i >= source_ws_index; --i) {
insert = workspaces_[i]->ShiftWindows(
- insert, source, target, Workspace::SHIFT_TO_LEFT);
+ insert, source, target_to_insert, Workspace::SHIFT_TO_LEFT);
// |target| can only be in the 1st workspace.
- target = NULL;
+ target_to_insert = NULL;
}
} else {
for (int i = target_ws_index; i <= source_ws_index; ++i) {
insert = workspaces_[i]->ShiftWindows(
- insert, source, target, Workspace::SHIFT_TO_RIGHT);
+ insert, source, target_to_insert, Workspace::SHIFT_TO_RIGHT);
// |target| can only be in the 1st workspace.
- target = NULL;
+ target_to_insert = NULL;
}
}
}
+ FOR_EACH_OBSERVER(WorkspaceObserver, observers_,
+ WindowMoved(this, source, target));
}
void WorkspaceManager::SetWorkspaceSize(const gfx::Size& workspace_size) {
@@ -171,6 +175,14 @@ void WorkspaceManager::SetWorkspaceSize(const gfx::Size& workspace_size) {
LayoutWorkspaces();
}
+void WorkspaceManager::AddObserver(WorkspaceObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void WorkspaceManager::RemoveObserver(WorkspaceObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
////////////////////////////////////////////////////////////////////////////////
// WorkspaceManager, private:
@@ -187,19 +199,32 @@ void WorkspaceManager::RemoveWorkspace(Workspace* workspace) {
workspaces_.end(),
workspace);
DCHECK(i != workspaces_.end());
- if (workspace == active_workspace_)
+ Workspace* old = NULL;
+
+ if (workspace == active_workspace_) {
+ old = active_workspace_;
active_workspace_ = NULL;
+ }
workspaces_.erase(i);
LayoutWorkspaces();
+
+ if (old) {
+ FOR_EACH_OBSERVER(WorkspaceObserver, observers_,
+ ActiveWorkspaceChanged(this, old));
+ }
}
void WorkspaceManager::SetActiveWorkspace(Workspace* workspace) {
DCHECK(std::find(workspaces_.begin(), workspaces_.end(),
workspace) != workspaces_.end());
+ Workspace* old = active_workspace_;
active_workspace_ = workspace;
is_overview_ = false;
UpdateViewport();
+
+ FOR_EACH_OBSERVER(WorkspaceObserver, observers_,
+ ActiveWorkspaceChanged(this, old));
}
gfx::Rect WorkspaceManager::GetWorkAreaBounds(
« no previous file with comments | « ui/aura_shell/workspace/workspace_manager.h ('k') | ui/aura_shell/workspace/workspace_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698