diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-23 00:48:20 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-23 00:48:20 +0000 |
commit | 7a890e443e0bacc7825545d365dc1efeafe621f6 (patch) | |
tree | ec25818f5956b6bd1d082921aae227496f9ee533 /ash/shell | |
parent | acdb39f340af733f8733db2f8fc668964c45f946 (diff) | |
download | chromium_src-7a890e443e0bacc7825545d365dc1efeafe621f6.zip chromium_src-7a890e443e0bacc7825545d365dc1efeafe621f6.tar.gz chromium_src-7a890e443e0bacc7825545d365dc1efeafe621f6.tar.bz2 |
Support 2nd launcher on ash_shell
BUG=166119
TEST=none
Review URL: https://chromiumcodereview.appspot.com/12018034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178187 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shell')
-rw-r--r-- | ash/shell/content_client/shell_browser_main_parts.cc | 5 | ||||
-rw-r--r-- | ash/shell/window_watcher.cc | 64 | ||||
-rw-r--r-- | ash/shell/window_watcher.h | 14 |
3 files changed, 64 insertions, 19 deletions
diff --git a/ash/shell/content_client/shell_browser_main_parts.cc b/ash/shell/content_client/shell_browser_main_parts.cc index a3f5c8d..00bc3e3 100644 --- a/ash/shell/content_client/shell_browser_main_parts.cc +++ b/ash/shell/content_client/shell_browser_main_parts.cc @@ -27,6 +27,7 @@ #include "ui/base/ui_base_paths.h" #include "ui/compositor/compositor.h" #include "ui/compositor/test/compositor_test_support.h" +#include "ui/gfx/screen.h" #include "ui/views/focus/accelerator_handler.h" #include "ui/views/test/test_views_delegate.h" @@ -98,6 +99,8 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { ash::Shell::GetInstance()->set_browser_context(browser_context_.get()); window_watcher_.reset(new ash::shell::WindowWatcher); + gfx::Screen* screen = Shell::GetInstance()->GetScreen(); + screen->AddObserver(window_watcher_.get()); delegate->SetWatcher(window_watcher_.get()); ash::shell::InitWindowTypeLauncher(); @@ -114,6 +117,8 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { void ShellBrowserMainParts::PostMainMessageLoopRun() { browser_context_.reset(); + gfx::Screen* screen = Shell::GetInstance()->GetScreen(); + screen->RemoveObserver(window_watcher_.get()); window_watcher_.reset(); ash::Shell::DeleteInstance(); diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc index 75a3b96..0711208 100644 --- a/ash/shell/window_watcher.cc +++ b/ash/shell/window_watcher.cc @@ -4,12 +4,14 @@ #include "ash/shell/window_watcher.h" +#include "ash/display/display_controller.h" #include "ash/launcher/launcher.h" #include "ash/launcher/launcher_model.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" +#include "ui/gfx/display.h" namespace ash { namespace shell { @@ -17,15 +19,9 @@ 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 { @@ -37,23 +33,51 @@ class WindowWatcher::WorkspaceWindowWatcher : public aura::WindowObserver { window->RemoveObserver(watcher_); } + void RootWindowAdded(aura::RootWindow* root) { + aura::Window* panel_container = ash::Shell::GetContainer( + root, + internal::kShellWindowId_PanelContainer); + panel_container->AddObserver(watcher_); + + aura::Window* container = Launcher::ForWindow(root)->window_container(); + container->AddObserver(this); + for (size_t i = 0; i < container->children().size(); ++i) + container->children()[i]->AddObserver(watcher_); + } + + void RootWindowRemoved(aura::RootWindow* root) { + aura::Window* panel_container = ash::Shell::GetContainer( + root, + internal::kShellWindowId_PanelContainer); + panel_container->RemoveObserver(watcher_); + + aura::Window* container = Launcher::ForWindow(root)->window_container(); + container->RemoveObserver(this); + for (size_t i = 0; i < container->children().size(); ++i) + container->children()[i]->RemoveObserver(watcher_); + } + private: WindowWatcher* watcher_; DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowWatcher); }; -WindowWatcher::WindowWatcher() - : window_(Launcher::ForPrimaryDisplay()->window_container()), - panel_container_(ash::Shell::GetContainer( - window_->GetRootWindow(), - internal::kShellWindowId_PanelContainer)) { +WindowWatcher::WindowWatcher() { workspace_window_watcher_.reset(new WorkspaceWindowWatcher(this)); - panel_container_->AddObserver(this); + Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); + for (Shell::RootWindowList::iterator iter = root_windows.begin(); + iter != root_windows.end(); ++ iter) { + workspace_window_watcher_->RootWindowAdded(*iter); + } } WindowWatcher::~WindowWatcher() { - panel_container_->RemoveObserver(this); + Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); + for (Shell::RootWindowList::iterator iter = root_windows.begin(); + iter != root_windows.end(); ++ iter) { + workspace_window_watcher_->RootWindowRemoved(*iter); + } } aura::Window* WindowWatcher::GetWindowByID(ash::LauncherID id) { @@ -111,5 +135,19 @@ void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { } } +void WindowWatcher::OnDisplayBoundsChanged(const gfx::Display& display) { +} + +void WindowWatcher::OnDisplayAdded(const gfx::Display& new_display) { + aura::RootWindow* root = Shell::GetInstance()->display_controller()-> + GetRootWindowForDisplayId(new_display.id()); + workspace_window_watcher_->RootWindowAdded(root); +} + +void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) { + // All windows in the display has already been removed, so no need to + // remove observers. +} + } // namespace shell } // namespace ash diff --git a/ash/shell/window_watcher.h b/ash/shell/window_watcher.h index ee81b5a..7a2c7c0 100644 --- a/ash/shell/window_watcher.h +++ b/ash/shell/window_watcher.h @@ -12,6 +12,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "ui/aura/window_observer.h" +#include "ui/gfx/display_observer.h" namespace aura { class Window; @@ -24,7 +25,8 @@ namespace shell { // WindowWatcher is responsible for listening for newly created windows and // creating items on the Launcher for them. -class WindowWatcher : public aura::WindowObserver { +class WindowWatcher : public aura::WindowObserver, + public gfx::DisplayObserver { public: WindowWatcher(); virtual ~WindowWatcher(); @@ -36,16 +38,16 @@ class WindowWatcher : public aura::WindowObserver { virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE; + // gfx::DisplayObserver overrides: + virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; + virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; + virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; + private: class WorkspaceWindowWatcher; typedef std::map<ash::LauncherID, aura::Window*> IDToWindow; - // Window watching for newly created windows to be added to. - aura::Window* window_; - - aura::Window* panel_container_; - // Maps from window to the id we gave it. IDToWindow id_to_window_; |