Initial crack at new workspace behavior. Each workspace now has its
own window. This complicates usage of shell window ids a bit.
I need to sort out animations (I've disabled them for the moment when
this is enabled).
BUG=137342
TEST=none
[email protected]
Review URL: https://chromiumcodereview.appspot.com/10830365
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152322 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc
index dfd54ff..a85d8f6c 100644
--- a/ash/shell/window_watcher.cc
+++ b/ash/shell/window_watcher.cc
@@ -13,17 +13,45 @@
namespace ash {
namespace shell {
+class WindowWatcher::WorkspaceWindowWatcher : public aura::WindowObserver {
+ public:
+ explicit WorkspaceWindowWatcher(WindowWatcher* watcher) : watcher_(watcher) {
+ watcher_->window_->AddObserver(this);
+ for (size_t i = 0; i < watcher_->window_->children().size(); ++i)
+ watcher_->window_->children()[i]->AddObserver(watcher_);
+ }
+
+ virtual ~WorkspaceWindowWatcher() {
+ watcher_->window_->RemoveObserver(this);
+ for (size_t i = 0; i < watcher_->window_->children().size(); ++i)
+ watcher_->window_->children()[i]->RemoveObserver(watcher_);
+ }
+
+ virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE {
+ new_window->AddObserver(watcher_);
+ }
+
+ virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE {
+ DCHECK(window->children().empty());
+ window->RemoveObserver(watcher_);
+ }
+
+ private:
+ WindowWatcher* watcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowWatcher);
+};
+
WindowWatcher::WindowWatcher()
: window_(ash::Shell::GetInstance()->launcher()->window_container()),
panel_container_(ash::Shell::GetContainer(
Shell::GetPrimaryRootWindow(),
internal::kShellWindowId_PanelContainer)) {
- window_->AddObserver(this);
+ workspace_window_watcher_.reset(new WorkspaceWindowWatcher(this));
panel_container_->AddObserver(this);
}
WindowWatcher::~WindowWatcher() {
- window_->RemoveObserver(this);
panel_container_->RemoveObserver(this);
}