summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 18:59:03 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 18:59:03 +0000
commit2d6eb74a95f9aa8edb777edc03e6915354bdd96f (patch)
tree4aa3c19921720fb0ff020335128f9ce46c956fde
parentd0b28895943cb6ac3a37920268ac93347b81b1c9 (diff)
downloadchromium_src-2d6eb74a95f9aa8edb777edc03e6915354bdd96f.zip
chromium_src-2d6eb74a95f9aa8edb777edc03e6915354bdd96f.tar.gz
chromium_src-2d6eb74a95f9aa8edb777edc03e6915354bdd96f.tar.bz2
Rename RootWindowObserver -> WindowTreeHostObserver.
Move observer management and notification to WTH. R=sky@chromium.org http://crbug.com/348874 Review URL: https://codereview.chromium.org/186423002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255108 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--apps/shell/browser/shell_browser_main_parts.cc17
-rw-r--r--apps/shell/browser/shell_browser_main_parts.h9
-rw-r--r--ash/cancel_mode.cc2
-rw-r--r--ash/display/display_controller.cc15
-rw-r--r--ash/display/display_controller.h9
-rw-r--r--ash/display/mirror_window_controller.cc23
-rw-r--r--ash/display/mirror_window_controller.h9
-rw-r--r--ash/display/virtual_keyboard_window_controller.cc26
-rw-r--r--ash/root_window_controller.cc4
-rw-r--r--ash/root_window_controller.h6
-rw-r--r--ash/wm/boot_splash_screen_chromeos.cc8
-rw-r--r--ash/wm/boot_splash_screen_chromeos.h4
-rw-r--r--ash/wm/lock_state_controller.cc10
-rw-r--r--ash/wm/lock_state_controller.h9
-rw-r--r--chrome/browser/chromeos/events/event_rewriter.cc9
-rw-r--r--chrome/browser/chromeos/events/event_rewriter.h8
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc15
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.h11
-rw-r--r--content/browser/web_contents/web_contents_view_aura.cc19
-rw-r--r--mojo/examples/aura_demo/window_tree_host_mojo.cc2
-rw-r--r--ui/aura/aura.gyp1
-rw-r--r--ui/aura/remote_window_tree_host_win.cc2
-rw-r--r--ui/aura/root_window_observer.h44
-rw-r--r--ui/aura/test/test_screen.cc2
-rw-r--r--ui/aura/window_event_dispatcher.cc31
-rw-r--r--ui/aura/window_event_dispatcher.h17
-rw-r--r--ui/aura/window_tree_host.cc31
-rw-r--r--ui/aura/window_tree_host.h11
-rw-r--r--ui/aura/window_tree_host_delegate.h1
-rw-r--r--ui/aura/window_tree_host_observer.h39
-rw-r--r--ui/aura/window_tree_host_win.cc9
-rw-r--r--ui/aura/window_tree_host_x11.cc12
-rw-r--r--ui/aura/window_tree_host_x11_unittest.cc1
-rw-r--r--ui/aura/window_unittest.cc1
-rw-r--r--ui/views/examples/content_client/examples_browser_main_parts.cc4
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.cc24
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.h18
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc5
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc12
-rw-r--r--ui/wm/test/wm_test_helper.h3
40 files changed, 217 insertions, 266 deletions
diff --git a/apps/shell/browser/shell_browser_main_parts.cc b/apps/shell/browser/shell_browser_main_parts.cc
index 05cb0e7..559c3c9 100644
--- a/apps/shell/browser/shell_browser_main_parts.cc
+++ b/apps/shell/browser/shell_browser_main_parts.cc
@@ -24,6 +24,7 @@
#include "ui/aura/env.h"
#include "ui/aura/test/test_screen.h"
#include "ui/aura/window_event_dispatcher.h"
+#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/screen.h"
@@ -140,7 +141,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
// TODO(jamescook): For demo purposes create a window with a WebView just
// to ensure that the content module is properly initialized.
webview_window_.reset(CreateWebViewWindow(browser_context_.get(),
- wm_test_helper_->dispatcher()->window()));
+ wm_test_helper_->host()->window()));
webview_window_->Show();
}
}
@@ -164,8 +165,8 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() {
aura::Env::DeleteInstance();
}
-void ShellBrowserMainParts::OnWindowTreeHostCloseRequested(
- const aura::WindowEventDispatcher* dispatcher) {
+void ShellBrowserMainParts::OnHostCloseRequested(
+ const aura::WindowTreeHost* host) {
extension_system_->CloseApp();
base::MessageLoop::current()->PostTask(FROM_HERE,
base::MessageLoop::QuitClosure());
@@ -180,17 +181,17 @@ void ShellBrowserMainParts::CreateRootWindow() {
// Set up basic pieces of views::corewm.
wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600)));
// Ensure the X window gets mapped.
- wm_test_helper_->dispatcher()->host()->Show();
+ wm_test_helper_->host()->Show();
// Watch for the user clicking the close box.
- wm_test_helper_->dispatcher()->AddRootWindowObserver(this);
+ wm_test_helper_->host()->AddObserver(this);
}
void ShellBrowserMainParts::DestroyRootWindow() {
// We should close widget before destroying root window.
webview_window_.reset();
devtools_delegate_->Stop();
- wm_test_helper_->dispatcher()->RemoveRootWindowObserver(this);
- wm_test_helper_->dispatcher()->PrepareForShutdown();
+ wm_test_helper_->host()->RemoveObserver(this);
+ wm_test_helper_->host()->dispatcher()->PrepareForShutdown();
wm_test_helper_.reset();
ui::ShutdownInputMethodForTesting();
}
@@ -198,7 +199,7 @@ void ShellBrowserMainParts::DestroyRootWindow() {
void ShellBrowserMainParts::CreateViewsDelegate() {
DCHECK(!views::ViewsDelegate::views_delegate);
views::ViewsDelegate::views_delegate =
- new ShellViewsDelegate(wm_test_helper_->dispatcher()->window());
+ new ShellViewsDelegate(wm_test_helper_->host()->window());
}
void ShellBrowserMainParts::DestroyViewsDelegate() {
diff --git a/apps/shell/browser/shell_browser_main_parts.h b/apps/shell/browser/shell_browser_main_parts.h
index d8746d8..fb40160e 100644
--- a/apps/shell/browser/shell_browser_main_parts.h
+++ b/apps/shell/browser/shell_browser_main_parts.h
@@ -9,7 +9,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_main_parts.h"
-#include "ui/aura/root_window_observer.h"
+#include "ui/aura/window_tree_host_observer.h"
namespace aura {
class TestScreen;
@@ -46,7 +46,7 @@ class ShellExtensionsClient;
// Handles initialization of AppShell.
class ShellBrowserMainParts : public content::BrowserMainParts,
- public aura::RootWindowObserver {
+ public aura::WindowTreeHostObserver {
public:
explicit ShellBrowserMainParts(
const content::MainFunctionParams& parameters);
@@ -69,9 +69,8 @@ class ShellBrowserMainParts : public content::BrowserMainParts,
virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE;
- // aura::RootWindowObserver overrides:
- virtual void OnWindowTreeHostCloseRequested(
- const aura::WindowEventDispatcher* dispatcher) OVERRIDE;
+ // aura::WindowTreeHostObserver overrides:
+ virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE;
private:
// Creates the window that hosts the apps.
diff --git a/ash/cancel_mode.cc b/ash/cancel_mode.cc
index 8ef7eb1..9d5456da 100644
--- a/ash/cancel_mode.cc
+++ b/ash/cancel_mode.cc
@@ -15,7 +15,7 @@ void DispatchCancelMode() {
Shell::GetAllRootWindowControllers());
for (Shell::RootWindowControllerList::const_iterator i = controllers.begin();
i != controllers.end(); ++i) {
- (*i)->dispatcher()->AsWindowTreeHostDelegate()->OnHostCancelMode();
+ (*i)->host()->dispatcher()->AsWindowTreeHostDelegate()->OnHostCancelMode();
}
}
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 2b85a39..7a3d786 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -613,15 +613,12 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller);
}
-void DisplayController::OnWindowTreeHostResized(
- const aura::WindowEventDispatcher* dispatcher) {
+void DisplayController::OnHostResized(const aura::WindowTreeHost* host) {
gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow(
- const_cast<aura::Window*>(dispatcher->window()));
+ const_cast<aura::Window*>(host->window()));
internal::DisplayManager* display_manager = GetDisplayManager();
- if (display_manager->UpdateDisplayBounds(
- display.id(),
- dispatcher->host()->GetBounds())) {
+ if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) {
mirror_window_controller_->UpdateWindow();
cursor_window_controller_->UpdateContainer();
}
@@ -708,9 +705,9 @@ aura::WindowTreeHost* DisplayController::AddWindowTreeHostForDisplay(
bounds_in_native);
host->window()->SetName(base::StringPrintf("RootWindow-%d", host_count++));
host->compositor()->SetBackgroundColor(SK_ColorBLACK);
- // No need to remove RootWindowObserver because
- // the DisplayController object outlives WindowEventDispatcher objects.
- host->dispatcher()->AddRootWindowObserver(this);
+ // No need to remove our observer observer because the DisplayController
+ // outlives the host.
+ host->AddObserver(this);
internal::InitRootWindowSettings(host->window())->display_id = display.id();
host->InitHost();
diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h
index 565b9be..aee2104 100644
--- a/ash/display/display_controller.h
+++ b/ash/display/display_controller.h
@@ -16,8 +16,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/time/time.h"
-#include "ui/aura/root_window_observer.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host_observer.h"
#include "ui/gfx/display_observer.h"
#include "ui/gfx/point.h"
@@ -50,7 +50,7 @@ class VirtualKeyboardWindowController;
// DisplayController owns and maintains RootWindows for each attached
// display, keeping them in sync with display configuration changes.
class ASH_EXPORT DisplayController : public gfx::DisplayObserver,
- public aura::RootWindowObserver,
+ public aura::WindowTreeHostObserver,
public internal::DisplayManager::Delegate {
public:
class ASH_EXPORT Observer {
@@ -149,9 +149,8 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver,
virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
- // RootWindowObserver overrides:
- virtual void OnWindowTreeHostResized(
- const aura::WindowEventDispatcher* root) OVERRIDE;
+ // aura::WindowTreeHostObserver overrides:
+ virtual void OnHostResized(const aura::WindowTreeHost* host) OVERRIDE;
// aura::DisplayManager::Delegate overrides:
virtual void CreateOrUpdateNonDesktopDisplay(
diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc
index 7902048..a766e7d 100644
--- a/ash/display/mirror_window_controller.cc
+++ b/ash/display/mirror_window_controller.cc
@@ -88,11 +88,10 @@ void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) {
host_->window()->SetName(
base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++));
host_->compositor()->SetBackgroundColor(SK_ColorBLACK);
- // No need to remove RootWindowObserver because the DisplayController object
- // outlives WindowEventDispatcher objects.
- host_->dispatcher()->AddRootWindowObserver(
- Shell::GetInstance()->display_controller());
- host_->dispatcher()->AddRootWindowObserver(this);
+ // No need to remove the observer because the DisplayController outlives the
+ // host.
+ host_->AddObserver(Shell::GetInstance()->display_controller());
+ host_->AddObserver(this);
// TODO(oshima): TouchHUD is using idkey.
InitRootWindowSettings(host_->window())->display_id = display_info.id();
host_->InitHost();
@@ -146,20 +145,16 @@ void MirrorWindowController::Close() {
aura::client::SetCaptureClient(host_->window(), NULL);
delete capture_client;
- host_->dispatcher()->RemoveRootWindowObserver(
- Shell::GetInstance()->display_controller());
- host_->dispatcher()->RemoveRootWindowObserver(this);
+ host_->RemoveObserver(Shell::GetInstance()->display_controller());
+ host_->RemoveObserver(this);
host_.reset();
}
}
-void MirrorWindowController::OnWindowTreeHostResized(
- const aura::WindowEventDispatcher* dispatcher) {
- // Do not use |old_size| as it contains RootWindow's (but not host's) size,
- // and this parameter wil be removed soon.
- if (mirror_window_host_size_ == dispatcher->host()->GetBounds().size())
+void MirrorWindowController::OnHostResized(const aura::WindowTreeHost* host) {
+ if (mirror_window_host_size_ == host->GetBounds().size())
return;
- mirror_window_host_size_ = dispatcher->host()->GetBounds().size();
+ mirror_window_host_size_ = host->GetBounds().size();
reflector_->OnMirroringCompositorResized();
host_->SetRootWindowTransformer(CreateRootWindowTransformer().Pass());
Shell::GetInstance()->display_controller()->cursor_window_controller()->
diff --git a/ash/display/mirror_window_controller.h b/ash/display/mirror_window_controller.h
index a0a770c..c70e9d8 100644
--- a/ash/display/mirror_window_controller.h
+++ b/ash/display/mirror_window_controller.h
@@ -9,8 +9,8 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "ui/aura/root_window_observer.h"
#include "ui/aura/window_tree_host.h"
+#include "ui/aura/window_tree_host_observer.h"
#include "ui/gfx/display.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"
@@ -36,7 +36,7 @@ class DisplayInfo;
// An object that copies the content of the primary root window to a
// mirror window. This also draws a mouse cursor as the mouse cursor
// is typically drawn by the window system.
-class ASH_EXPORT MirrorWindowController : public aura::RootWindowObserver {
+class ASH_EXPORT MirrorWindowController : public aura::WindowTreeHostObserver {
public:
MirrorWindowController();
virtual ~MirrorWindowController();
@@ -52,9 +52,8 @@ class ASH_EXPORT MirrorWindowController : public aura::RootWindowObserver {
// Close the mirror window.
void Close();
- // aura::RootWindowObserver overrides:
- virtual void OnWindowTreeHostResized(
- const aura::WindowEventDispatcher* root) OVERRIDE;
+ // aura::WindowTreeHostObserver overrides:
+ virtual void OnHostResized(const aura::WindowTreeHost* host) OVERRIDE;
aura::WindowTreeHost* host() const { return host_.get(); }
diff --git a/ash/display/virtual_keyboard_window_controller.cc b/ash/display/virtual_keyboard_window_controller.cc
index 4197992..bef3b45 100644
--- a/ash/display/virtual_keyboard_window_controller.cc
+++ b/ash/display/virtual_keyboard_window_controller.cc
@@ -48,30 +48,27 @@ void VirtualKeyboardWindowController::UpdateWindow(
base::StringPrintf("VirtualKeyboardRootWindow-%d",
virtual_keyboard_host_count++));
- // No need to remove RootWindowObserver because
- // the DisplayController object outlives RootWindow objects.
- host->dispatcher()->AddRootWindowObserver(
- Shell::GetInstance()->display_controller());
+ // No need to remove WindowTreeHostObserver because the DisplayController
+ // outlives the host.
+ host->AddObserver(Shell::GetInstance()->display_controller());
InitRootWindowSettings(host->window())->display_id = display_info.id();
host->InitHost();
RootWindowController::CreateForVirtualKeyboardDisplay(host);
root_window_controller_.reset(GetRootWindowController(host->window()));
- root_window_controller_->dispatcher()->host()->Show();
+ root_window_controller_->host()->Show();
root_window_controller_->ActivateKeyboard(
Shell::GetInstance()->keyboard_controller());
FlipDisplay();
} else {
- aura::WindowEventDispatcher* dispatcher =
- root_window_controller_->dispatcher();
- GetRootWindowSettings(dispatcher->window())->display_id =
- display_info.id();
- dispatcher->host()->SetBounds(display_info.bounds_in_native());
+ aura::WindowTreeHost* host = root_window_controller_->host();
+ GetRootWindowSettings(host->window())->display_id = display_info.id();
+ host->SetBounds(display_info.bounds_in_native());
}
}
void VirtualKeyboardWindowController::Close() {
if (root_window_controller_.get()) {
- root_window_controller_->dispatcher()->RemoveRootWindowObserver(
+ root_window_controller_->host()->RemoveObserver(
Shell::GetInstance()->display_controller());
root_window_controller_->Shutdown();
root_window_controller_.reset();
@@ -88,12 +85,11 @@ void VirtualKeyboardWindowController::FlipDisplay() {
display_manager->SetDisplayRotation(
display_manager->non_desktop_display().id(), gfx::Display::ROTATE_180);
- aura::WindowEventDispatcher* dispatcher =
- root_window_controller_->dispatcher();
+ aura::WindowTreeHost* host = root_window_controller_->host();
scoped_ptr<aura::RootWindowTransformer> transformer(
- internal::CreateRootWindowTransformerForDisplay(dispatcher->window(),
+ internal::CreateRootWindowTransformerForDisplay(host->window(),
display_manager->non_desktop_display()));
- dispatcher->host()->SetRootWindowTransformer(transformer.Pass());
+ host->SetRootWindowTransformer(transformer.Pass());
}
} // namespace internal
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 55196b4..92fe388 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -355,7 +355,7 @@ void RootWindowController::Shutdown() {
internal::GetRootWindowSettings(root_window())->display_id =
gfx::Display::kInvalidDisplayID;
// And this root window should no longer process events.
- dispatcher()->PrepareForShutdown();
+ host()->dispatcher()->PrepareForShutdown();
system_background_.reset();
aura::client::SetScreenPositionClient(root_window(), NULL);
@@ -797,7 +797,7 @@ void RootWindowController::CreateSystemBackground(
switches::kAshCopyHostBackgroundAtBoot) ||
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshAnimateFromBootSplashScreen)))
- boot_splash_screen_.reset(new BootSplashScreen(dispatcher()));
+ boot_splash_screen_.reset(new BootSplashScreen(host()));
#endif
}
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
index 468dcfa..d347d81 100644
--- a/ash/root_window_controller.h
+++ b/ash/root_window_controller.h
@@ -111,10 +111,8 @@ class ASH_EXPORT RootWindowController : public ShellObserver {
aura::Window* root_window() { return host_->window(); }
const aura::Window* root_window() const { return host_->window(); }
- aura::WindowEventDispatcher* dispatcher() { return host_->dispatcher(); }
- const aura::WindowEventDispatcher* dispatcher() const {
- return host_->dispatcher();
- }
+ aura::WindowTreeHost* host() { return host_.get(); }
+ const aura::WindowTreeHost* host() const { return host_.get(); }
RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
diff --git a/ash/wm/boot_splash_screen_chromeos.cc b/ash/wm/boot_splash_screen_chromeos.cc
index 4a48052..67ecd6d 100644
--- a/ash/wm/boot_splash_screen_chromeos.cc
+++ b/ash/wm/boot_splash_screen_chromeos.cc
@@ -51,13 +51,13 @@ class BootSplashScreen::CopyHostContentLayerDelegate
DISALLOW_COPY_AND_ASSIGN(CopyHostContentLayerDelegate);
};
-BootSplashScreen::BootSplashScreen(aura::WindowEventDispatcher* dispatcher)
- : layer_delegate_(new CopyHostContentLayerDelegate(dispatcher->host())),
+BootSplashScreen::BootSplashScreen(aura::WindowTreeHost* host)
+ : layer_delegate_(new CopyHostContentLayerDelegate(host)),
layer_(new ui::Layer(ui::LAYER_TEXTURED)) {
layer_->set_delegate(layer_delegate_.get());
- ui::Layer* root_layer = dispatcher->window()->layer();
- layer_->SetBounds(gfx::Rect(dispatcher->window()->bounds().size()));
+ ui::Layer* root_layer = host->window()->layer();
+ layer_->SetBounds(gfx::Rect(host->window()->bounds().size()));
root_layer->Add(layer_.get());
root_layer->StackAtTop(layer_.get());
}
diff --git a/ash/wm/boot_splash_screen_chromeos.h b/ash/wm/boot_splash_screen_chromeos.h
index fcf97e3..7ba2809 100644
--- a/ash/wm/boot_splash_screen_chromeos.h
+++ b/ash/wm/boot_splash_screen_chromeos.h
@@ -12,7 +12,7 @@
#include "base/time/time.h"
namespace aura {
-class WindowEventDispatcher;
+class WindowTreeHost;
}
namespace ui {
@@ -30,7 +30,7 @@ namespace internal {
// animate the transition between the splash screen and the login screen.
class BootSplashScreen {
public:
- explicit BootSplashScreen(aura::WindowEventDispatcher* dispatcher);
+ explicit BootSplashScreen(aura::WindowTreeHost* host);
~BootSplashScreen();
// Begins animating |layer_|'s opacity to 0 over |duration|.
diff --git a/ash/wm/lock_state_controller.cc b/ash/wm/lock_state_controller.cc
index 9897d40..9675bab 100644
--- a/ash/wm/lock_state_controller.cc
+++ b/ash/wm/lock_state_controller.cc
@@ -167,13 +167,11 @@ LockStateController::LockStateController()
shutdown_after_lock_(false),
animating_lock_(false),
can_cancel_lock_animation_(false) {
- Shell::GetPrimaryRootWindow()->GetHost()->dispatcher()->AddRootWindowObserver(
- this);
+ Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this);
}
LockStateController::~LockStateController() {
- Shell::GetPrimaryRootWindow()->GetHost()->dispatcher()->
- RemoveRootWindowObserver(this);
+ Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this);
}
void LockStateController::SetDelegate(LockStateControllerDelegate* delegate) {
@@ -290,8 +288,8 @@ void LockStateController::SetLockScreenDisplayedCallback(
lock_screen_displayed_callback_ = callback;
}
-void LockStateController::OnWindowTreeHostCloseRequested(
- const aura::WindowEventDispatcher* dispatcher) {
+void LockStateController::OnHostCloseRequested(
+ const aura::WindowTreeHost* host) {
Shell::GetInstance()->delegate()->Exit();
}
diff --git a/ash/wm/lock_state_controller.h b/ash/wm/lock_state_controller.h
index 5a70ad4..6330d68 100644
--- a/ash/wm/lock_state_controller.h
+++ b/ash/wm/lock_state_controller.h
@@ -14,7 +14,7 @@
#include "base/observer_list.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
-#include "ui/aura/root_window_observer.h"
+#include "ui/aura/window_tree_host_observer.h"
namespace gfx {
class Rect;
@@ -68,7 +68,7 @@ class ASH_EXPORT LockStateControllerDelegate {
// called at the end of the animation, lock UI is deleted, system unlocks, and
// OnLockStateChanged is called. It leads to
// StartUnlockAnimationAfterUIDestroyed.
-class ASH_EXPORT LockStateController : public aura::RootWindowObserver,
+class ASH_EXPORT LockStateController : public aura::WindowTreeHostObserver,
public ShellObserver {
public:
// Amount of time that the power button needs to be held before we lock the
@@ -197,9 +197,8 @@ class ASH_EXPORT LockStateController : public aura::RootWindowObserver,
// Callback is guaranteed to be called once and then discarded.
void SetLockScreenDisplayedCallback(const base::Closure& callback);
- // RootWindowObserver override:
- virtual void OnWindowTreeHostCloseRequested(
- const aura::WindowEventDispatcher* dispatcher) OVERRIDE;
+ // aura::WindowTreeHostObserver override:
+ virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE;
// ShellObserver overrides:
virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
diff --git a/chrome/browser/chromeos/events/event_rewriter.cc b/chrome/browser/chromeos/events/event_rewriter.cc
index 567cb99..b6899e9 100644
--- a/chrome/browser/chromeos/events/event_rewriter.cc
+++ b/chrome/browser/chromeos/events/event_rewriter.cc
@@ -143,8 +143,7 @@ EventRewriter::EventRewriter()
pref_service_for_testing_(NULL) {
// The ash shell isn't instantiated for our unit tests.
if (ash::Shell::HasInstance()) {
- ash::Shell::GetPrimaryRootWindow()->GetHost()->dispatcher()->
- AddRootWindowObserver(this);
+ ash::Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this);
}
base::MessageLoopForUI::current()->AddObserver(this);
if (base::SysInfo::IsRunningOnChromeOS()) {
@@ -156,8 +155,7 @@ EventRewriter::EventRewriter()
EventRewriter::~EventRewriter() {
base::MessageLoopForUI::current()->RemoveObserver(this);
if (ash::Shell::HasInstance()) {
- ash::Shell::GetPrimaryRootWindow()->GetHost()->dispatcher()->
- RemoveRootWindowObserver(this);
+ ash::Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this);
}
if (base::SysInfo::IsRunningOnChromeOS()) {
XInputHierarchyChangedEventListener::GetInstance()->RemoveObserver(this);
@@ -196,8 +194,7 @@ void EventRewriter::RewriteForTesting(XEvent* event) {
Rewrite(event);
}
-void EventRewriter::OnKeyboardMappingChanged(
- const aura::WindowEventDispatcher* dispatcher) {
+void EventRewriter::OnKeyboardMappingChanged(const aura::WindowTreeHost* host) {
RefreshKeycodes();
}
diff --git a/chrome/browser/chromeos/events/event_rewriter.h b/chrome/browser/chromeos/events/event_rewriter.h
index 967058b..c4a97b1 100644
--- a/chrome/browser/chromeos/events/event_rewriter.h
+++ b/chrome/browser/chromeos/events/event_rewriter.h
@@ -15,7 +15,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_pump_observer.h"
#include "chrome/browser/chromeos/device_hierarchy_observer.h"
-#include "ui/aura/root_window_observer.h"
+#include "ui/aura/window_tree_host_observer.h"
#include "ui/events/keycodes/keyboard_codes.h"
class PrefService;
@@ -31,7 +31,7 @@ namespace input_method {
class XKeyboard;
}
-class EventRewriter : public aura::RootWindowObserver,
+class EventRewriter : public aura::WindowTreeHostObserver,
public DeviceHierarchyObserver,
public base::MessagePumpObserver {
public:
@@ -69,9 +69,9 @@ class EventRewriter : public aura::RootWindowObserver,
friend class EventRewriterAshTest;
friend class EventRewriterTest;
- // aura::RootWindowObserver overrides:
+ // aura::WindowTreeHostObserver overrides:
virtual void OnKeyboardMappingChanged(
- const aura::WindowEventDispatcher* dispatcher) OVERRIDE;
+ const aura::WindowTreeHost* host) OVERRIDE;
// base::MessagePumpObserver overrides:
virtual base::EventStatus WillProcessEvent(
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 7fd951d..e0b07da 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -3151,12 +3151,11 @@ void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus,
}
////////////////////////////////////////////////////////////////////////////////
-// RenderWidgetHostViewAura, aura::RootWindowObserver implementation:
+// RenderWidgetHostViewAura, aura::WindowTreeHostObserver implementation:
-void RenderWidgetHostViewAura::OnWindowTreeHostMoved(
- const aura::WindowEventDispatcher* dispatcher,
- const gfx::Point& new_origin) {
- TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnWindowTreeHostMoved",
+void RenderWidgetHostViewAura::OnHostMoved(const aura::WindowTreeHost* host,
+ const gfx::Point& new_origin) {
+ TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved",
"new_origin", new_origin.ToString());
UpdateScreenInfo(window_);
@@ -3309,7 +3308,7 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
window_observer_.reset();
if (window_->GetHost())
- window_->GetHost()->dispatcher()->RemoveRootWindowObserver(this);
+ window_->GetHost()->RemoveObserver(this);
UnlockMouse();
if (popup_parent_host_view_) {
DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
@@ -3492,7 +3491,7 @@ void RenderWidgetHostViewAura::AddOnCommitCallbackAndDisableLocks(
}
void RenderWidgetHostViewAura::AddedToRootWindow() {
- window_->GetHost()->dispatcher()->AddRootWindowObserver(this);
+ window_->GetHost()->AddObserver(this);
UpdateScreenInfo(window_);
aura::client::CursorClient* cursor_client =
@@ -3533,7 +3532,7 @@ void RenderWidgetHostViewAura::RemovingFromRootWindow() {
DetachFromInputMethod();
- window_->GetHost()->dispatcher()->RemoveRootWindowObserver(this);
+ window_->GetHost()->RemoveObserver(this);
ui::Compositor* compositor = GetCompositor();
if (current_surface_.get()) {
// We can't get notification for commits after this point, which would
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
index e8e95dd..1198ff0 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -32,8 +32,8 @@
#include "ui/aura/client/activation_delegate.h"
#include "ui/aura/client/cursor_client_observer.h"
#include "ui/aura/client/focus_change_observer.h"
-#include "ui/aura/root_window_observer.h"
#include "ui/aura/window_delegate.h"
+#include "ui/aura/window_tree_host_observer.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_observer.h"
@@ -88,7 +88,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
public ui::CompositorVSyncManager::Observer,
public ui::TextInputClient,
public gfx::DisplayObserver,
- public aura::RootWindowObserver,
+ public aura::WindowTreeHostObserver,
public aura::WindowDelegate,
public aura::client::ActivationDelegate,
public aura::client::ActivationChangeObserver,
@@ -324,10 +324,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
virtual void OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) OVERRIDE;
- // Overridden from aura::RootWindowObserver:
- virtual void OnWindowTreeHostMoved(
- const aura::WindowEventDispatcher* dispatcher,
- const gfx::Point& new_origin) OVERRIDE;
+ // Overridden from aura::WindowTreeHostObserver:
+ virtual void OnHostMoved(const aura::WindowTreeHost* host,
+ const gfx::Point& new_origin) OVERRIDE;
// SoftwareFrameManagerClient implementation:
virtual void SoftwareFrameWasFreed(
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index 2d53cf02..d1c7829 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -48,10 +48,10 @@
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/env.h"
-#include "ui/aura/root_window_observer.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_observer.h"
+#include "ui/aura/window_tree_host_observer.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/base/dragdrop/drag_drop_types.h"
@@ -446,7 +446,7 @@ int ConvertAuraEventFlagsToWebInputEventModifiers(int aura_event_flags) {
} // namespace
class WebContentsViewAura::WindowObserver
- : public aura::WindowObserver, public aura::RootWindowObserver {
+ : public aura::WindowObserver, public aura::WindowTreeHostObserver {
public:
explicit WindowObserver(WebContentsViewAura* view)
: view_(view),
@@ -462,7 +462,7 @@ class WebContentsViewAura::WindowObserver
virtual ~WindowObserver() {
view_->window_->RemoveObserver(this);
if (view_->window_->GetHost())
- view_->window_->GetHost()->dispatcher()->RemoveRootWindowObserver(this);
+ view_->window_->GetHost()->RemoveObserver(this);
if (parent_)
parent_->RemoveObserver(this);
@@ -593,7 +593,7 @@ class WebContentsViewAura::WindowObserver
virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE {
if (window == view_->window_) {
- window->GetHost()->dispatcher()->AddRootWindowObserver(this);
+ window->GetHost()->AddObserver(this);
#if defined(OS_WIN)
if (!window->GetRootWindow()->HasObserver(this))
window->GetRootWindow()->AddObserver(this);
@@ -603,7 +603,7 @@ class WebContentsViewAura::WindowObserver
virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE {
if (window == view_->window_) {
- window->GetHost()->dispatcher()->RemoveRootWindowObserver(this);
+ window->GetHost()->RemoveObserver(this);
#if defined(OS_WIN)
window->GetRootWindow()->RemoveObserver(this);
@@ -617,12 +617,11 @@ class WebContentsViewAura::WindowObserver
}
}
- // Overridden RootWindowObserver:
- virtual void OnWindowTreeHostMoved(
- const aura::WindowEventDispatcher* dispatcher,
- const gfx::Point& new_origin) OVERRIDE {
+ // Overridden WindowTreeHostObserver:
+ virtual void OnHostMoved(const aura::WindowTreeHost* host,
+ const gfx::Point& new_origin) OVERRIDE {
TRACE_EVENT1("ui",
- "WebContentsViewAura::WindowObserver::OnWindowTreeHostMoved",
+ "WebContentsViewAura::WindowObserver::OnHostMoved",
"new_origin", new_origin.ToString());
// This is for the desktop case (i.e. Aura desktop).
diff --git a/mojo/examples/aura_demo/window_tree_host_mojo.cc b/mojo/examples/aura_demo/window_tree_host_mojo.cc
index c867b47..266d923 100644
--- a/mojo/examples/aura_demo/window_tree_host_mojo.cc
+++ b/mojo/examples/aura_demo/window_tree_host_mojo.cc
@@ -164,7 +164,7 @@ void WindowTreeHostMojo::OnBoundsChanged(const Rect& bounds) {
bounds.size().width(), bounds.size().height());
if (delegate_)
window()->SetBounds(gfx::Rect(bounds_.size()));
- NotifyHostResized(bounds_.size());
+ OnHostResized(bounds_.size());
}
void WindowTreeHostMojo::OnDestroyed() {
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 376723b..43f81ef 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -110,6 +110,7 @@
'window_tree_host_delegate.h',
'window_tree_host_mac.mm',
'window_tree_host_mac.h',
+ 'window_tree_host_observer.h',
'window_tree_host_ozone.cc',
'window_tree_host_ozone.h',
'window_tree_host_win.cc',
diff --git a/ui/aura/remote_window_tree_host_win.cc b/ui/aura/remote_window_tree_host_win.cc
index 92a37c2..7669fae 100644
--- a/ui/aura/remote_window_tree_host_win.cc
+++ b/ui/aura/remote_window_tree_host_win.cc
@@ -399,7 +399,7 @@ gfx::Rect RemoteWindowTreeHostWin::GetBounds() const {
void RemoteWindowTreeHostWin::SetBounds(const gfx::Rect& bounds) {
window_size_ = bounds.size();
- NotifyHostResized(bounds.size());
+ OnHostResized(bounds.size());
}
gfx::Insets RemoteWindowTreeHostWin::GetInsets() const {
diff --git a/ui/aura/root_window_observer.h b/ui/aura/root_window_observer.h
deleted file mode 100644
index 081b577..0000000
--- a/ui/aura/root_window_observer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_AURA_ROOT_WINDOW_OBSERVER_H_
-#define UI_AURA_ROOT_WINDOW_OBSERVER_H_
-
-#include "ui/aura/aura_export.h"
-
-namespace gfx {
-class Point;
-}
-
-namespace aura {
-class Window;
-class WindowEventDispatcher;
-
-// TODO(beng): Rename to WindowTreeHostObserver
-class AURA_EXPORT RootWindowObserver {
- public:
- // Invoked after the RootWindow's host has been resized.
- virtual void OnWindowTreeHostResized(
- const WindowEventDispatcher* dispatcher) {}
-
- // Invoked after the RootWindow's host has been moved on screen.
- virtual void OnWindowTreeHostMoved(const WindowEventDispatcher* dispatcher,
- const gfx::Point& new_origin) {}
-
- // Invoked when the native windowing system sends us a request to close our
- // window.
- virtual void OnWindowTreeHostCloseRequested(
- const WindowEventDispatcher* dispatcher) {}
-
- // Invoked when the keyboard mapping has changed.
- virtual void OnKeyboardMappingChanged(
- const WindowEventDispatcher* dispatcher) {}
-
- protected:
- virtual ~RootWindowObserver() {}
-};
-
-} // namespace aura
-
-#endif // UI_AURA_ROOT_WINDOW_OBSERVER_H_
diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc
index 2fced68..e5158ae 100644
--- a/ui/aura/test/test_screen.cc
+++ b/ui/aura/test/test_screen.cc
@@ -42,7 +42,7 @@ WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() {
void TestScreen::SetDeviceScaleFactor(float device_scale_factor) {
gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
- host_->NotifyHostResized(bounds_in_pixel.size());
+ host_->OnHostResized(bounds_in_pixel.size());
}
void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) {
diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc
index 98d268e..c317e15 100644
--- a/ui/aura/window_event_dispatcher.cc
+++ b/ui/aura/window_event_dispatcher.cc
@@ -17,7 +17,6 @@
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
-#include "ui/aura/root_window_observer.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_targeter.h"
@@ -232,26 +231,6 @@ void WindowEventDispatcher::OnWindowTransformed(Window* window,
}
}
-void WindowEventDispatcher::OnKeyboardMappingChanged() {
- FOR_EACH_OBSERVER(RootWindowObserver, observers_,
- OnKeyboardMappingChanged(this));
-}
-
-void WindowEventDispatcher::OnWindowTreeHostCloseRequested() {
- FOR_EACH_OBSERVER(RootWindowObserver, observers_,
- OnWindowTreeHostCloseRequested(this));
-}
-
-void WindowEventDispatcher::AddRootWindowObserver(
- RootWindowObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void WindowEventDispatcher::RemoveRootWindowObserver(
- RootWindowObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event,
Window* window,
ui::EventResult result) {
@@ -621,14 +600,6 @@ void WindowEventDispatcher::OnHostLostMouseGrab() {
mouse_moved_handler_ = NULL;
}
-void WindowEventDispatcher::OnHostMoved(const gfx::Point& origin) {
- TRACE_EVENT1("ui", "WindowEventDispatcher::OnHostMoved",
- "origin", origin.ToString());
-
- FOR_EACH_OBSERVER(RootWindowObserver, observers_,
- OnWindowTreeHostMoved(this, origin));
-}
-
void WindowEventDispatcher::OnHostResized(const gfx::Size& size) {
TRACE_EVENT1("ui", "WindowEventDispatcher::OnHostResized",
"size", size.ToString());
@@ -636,8 +607,6 @@ void WindowEventDispatcher::OnHostResized(const gfx::Size& size) {
DispatchDetails details = DispatchHeldEvents();
if (details.dispatcher_destroyed)
return;
- FOR_EACH_OBSERVER(RootWindowObserver, observers_,
- OnWindowTreeHostResized(this));
// Constrain the mouse position within the new root Window size.
gfx::Point point;
diff --git a/ui/aura/window_event_dispatcher.h b/ui/aura/window_event_dispatcher.h
index d1b6bfa..9fe917b 100644
--- a/ui/aura/window_event_dispatcher.h
+++ b/ui/aura/window_event_dispatcher.h
@@ -113,20 +113,6 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor,
// |last_moust_location()|.
void OnWindowTransformed(Window* window, bool contained_mouse);
- // Invoked when the keyboard mapping (in X11 terms: the mapping between
- // key-codes and key-syms) has changed.
- void OnKeyboardMappingChanged();
-
- // The system windowing system has sent a request that we close our window.
- void OnWindowTreeHostCloseRequested();
-
- // Add/remove observer. There is no need to remove the observer if
- // the root window is being deleted. In particular, you SHOULD NOT remove
- // in |WindowObserver::OnWindowDestroying| of the observer observing
- // the root window because it is too late to remove it.
- void AddRootWindowObserver(RootWindowObserver* observer);
- void RemoveRootWindowObserver(RootWindowObserver* observer);
-
// Gesture Recognition -------------------------------------------------------
// When a touch event is dispatched to a Window, it may want to process the
@@ -234,7 +220,6 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor,
virtual void OnHostActivated() OVERRIDE;
virtual void OnHostLostWindowCapture() OVERRIDE;
virtual void OnHostLostMouseGrab() OVERRIDE;
- virtual void OnHostMoved(const gfx::Point& origin) OVERRIDE;
virtual void OnHostResized(const gfx::Size& size) OVERRIDE;
virtual void OnCursorMovedToRootLocation(
const gfx::Point& root_location) OVERRIDE;
@@ -270,8 +255,6 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor,
// Touch ids that are currently down.
uint32 touch_ids_down_;
- ObserverList<RootWindowObserver> observers_;
-
Window* mouse_pressed_handler_;
Window* mouse_moved_handler_;
Window* event_dispatch_target_;
diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc
index ebaf15c..cefafb4 100644
--- a/ui/aura/window_tree_host.cc
+++ b/ui/aura/window_tree_host.cc
@@ -4,6 +4,7 @@
#include "ui/aura/window_tree_host.h"
+#include "base/debug/trace_event.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window_transformer.h"
@@ -11,6 +12,7 @@
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_targeter.h"
#include "ui/aura/window_tree_host_delegate.h"
+#include "ui/aura/window_tree_host_observer.h"
#include "ui/base/view_prop.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h"
@@ -104,6 +106,14 @@ void WindowTreeHost::InitCompositor() {
new SimpleRootWindowTransformer(window(), gfx::Transform()));
}
+void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void WindowTreeHost::RemoveObserver(WindowTreeHostObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
void WindowTreeHost::SetRootWindowTransformer(
scoped_ptr<RootWindowTransformer> transformer) {
transformer_ = transformer.Pass();
@@ -253,7 +263,15 @@ void WindowTreeHost::CreateCompositor(
delegate_ = dispatcher();
}
-void WindowTreeHost::NotifyHostResized(const gfx::Size& new_size) {
+void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) {
+ TRACE_EVENT1("ui", "WindowTreeHost::OnHostMoved",
+ "origin", new_location.ToString());
+
+ FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_,
+ OnHostMoved(this, new_location));
+}
+
+void WindowTreeHost::OnHostResized(const gfx::Size& new_size) {
// The compositor should have the same size as the native root window host.
// Get the latest scale from display because it might have been changed.
compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
@@ -263,9 +281,20 @@ void WindowTreeHost::NotifyHostResized(const gfx::Size& new_size) {
// The layer, and the observers should be notified of the
// transformed size of the root window.
UpdateRootWindowSize(layer_size);
+ FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_, OnHostResized(this));
delegate_->OnHostResized(layer_size);
}
+void WindowTreeHost::OnHostCloseRequested() {
+ FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_,
+ OnHostCloseRequested(this));
+}
+
+void WindowTreeHost::OnKeyboardMappingChanged() {
+ FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_,
+ OnKeyboardMappingChanged(this));
+}
+
void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location,
const gfx::Point& host_location) {
MoveCursorToNative(host_location);
diff --git a/ui/aura/window_tree_host.h b/ui/aura/window_tree_host.h
index 71e990e..bcf517e 100644
--- a/ui/aura/window_tree_host.h
+++ b/ui/aura/window_tree_host.h
@@ -30,6 +30,7 @@ namespace aura {
class RootWindowTransformer;
class WindowEventDispatcher;
class WindowTreeHostDelegate;
+class WindowTreeHostObserver;
// WindowTreeHost bridges between a native window and the embedded RootWindow.
// It provides the accelerated widget and maps events from the native os to
@@ -52,6 +53,9 @@ class AURA_EXPORT WindowTreeHost {
Window* window() { return window_; }
const Window* window() const { return window_; }
+ void AddObserver(WindowTreeHostObserver* observer);
+ void RemoveObserver(WindowTreeHostObserver* observer);
+
WindowEventDispatcher* dispatcher() {
return const_cast<WindowEventDispatcher*>(
const_cast<const WindowTreeHost*>(this)->dispatcher());
@@ -178,7 +182,10 @@ class AURA_EXPORT WindowTreeHost {
// Returns the location of the RootWindow on native screen.
virtual gfx::Point GetLocationOnNativeScreen() const = 0;
- void NotifyHostResized(const gfx::Size& new_size);
+ void OnHostMoved(const gfx::Point& new_location);
+ void OnHostResized(const gfx::Size& new_size);
+ void OnHostCloseRequested();
+ void OnKeyboardMappingChanged();
// Sets the currently displayed cursor.
virtual void SetCursorNative(gfx::NativeCursor cursor) = 0;
@@ -203,6 +210,8 @@ class AURA_EXPORT WindowTreeHost {
// the dtor).
Window* window_; // Owning.
+ ObserverList<WindowTreeHostObserver> observers_;
+
scoped_ptr<WindowEventDispatcher> dispatcher_;
scoped_ptr<ui::Compositor> compositor_;
diff --git a/ui/aura/window_tree_host_delegate.h b/ui/aura/window_tree_host_delegate.h
index 203f016..c5ba407 100644
--- a/ui/aura/window_tree_host_delegate.h
+++ b/ui/aura/window_tree_host_delegate.h
@@ -42,7 +42,6 @@ class AURA_EXPORT WindowTreeHostDelegate {
// window move on our behalf, but we should still paint as if we're active.
virtual void OnHostLostMouseGrab() = 0;
- virtual void OnHostMoved(const gfx::Point& origin) = 0;
virtual void OnHostResized(const gfx::Size& size) = 0;
virtual void OnCursorMovedToRootLocation(const gfx::Point& root_location) = 0;
diff --git a/ui/aura/window_tree_host_observer.h b/ui/aura/window_tree_host_observer.h
new file mode 100644
index 0000000..96841f8
--- /dev/null
+++ b/ui/aura/window_tree_host_observer.h
@@ -0,0 +1,39 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_WINDOW_TREE_HOST_OBSERVER_H_
+#define UI_AURA_WINDOW_TREE_HOST_OBSERVER_H_
+
+#include "ui/aura/aura_export.h"
+
+namespace gfx {
+class Point;
+}
+
+namespace aura {
+class Window;
+class WindowTreeHost;
+
+class AURA_EXPORT WindowTreeHostObserver {
+ public:
+ // Called when the host's client size has changed.
+ virtual void OnHostResized(const WindowTreeHost* host) {}
+
+ // Called when the host is moved on screen.
+ virtual void OnHostMoved(const WindowTreeHost* host,
+ const gfx::Point& new_origin) {}
+
+ // Called when the native window system sends the host request to close.
+ virtual void OnHostCloseRequested(const WindowTreeHost* host) {}
+
+ // Called when the keyboard mapping has changed.
+ virtual void OnKeyboardMappingChanged(const WindowTreeHost* host) {}
+
+ protected:
+ virtual ~WindowTreeHostObserver() {}
+};
+
+} // namespace aura
+
+#endif // UI_AURA_WINDOW_TREE_HOST_OBSERVER_H_
diff --git a/ui/aura/window_tree_host_win.cc b/ui/aura/window_tree_host_win.cc
index 33d50e6..eb3af31 100644
--- a/ui/aura/window_tree_host_win.cc
+++ b/ui/aura/window_tree_host_win.cc
@@ -131,14 +131,14 @@ void WindowTreeHostWin::SetBounds(const gfx::Rect& bounds) {
window_rect.bottom - window_rect.top,
SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION);
- // Explicity call NotifyHostResized when the scale has changed because
+ // Explicity call OnHostResized when the scale has changed because
// the window size may not have changed.
float current_scale = compositor()->device_scale_factor();
float new_scale = gfx::Screen::GetScreenFor(
delegate_->AsDispatcher()->window())->GetDisplayNearestWindow(
delegate_->AsDispatcher()->window()).device_scale_factor();
if (current_scale != new_scale)
- NotifyHostResized(bounds.size());
+ OnHostResized(bounds.size());
}
gfx::Insets WindowTreeHostWin::GetInsets() const {
@@ -282,8 +282,7 @@ LRESULT WindowTreeHostWin::OnNCActivate(UINT message,
}
void WindowTreeHostWin::OnMove(const gfx::Point& point) {
- if (delegate_)
- delegate_->OnHostMoved(point);
+ OnHostMoved(point);
}
void WindowTreeHostWin::OnPaint(HDC dc) {
@@ -299,7 +298,7 @@ void WindowTreeHostWin::OnSize(UINT param, const gfx::Size& size) {
// Minimizing resizes the window to 0x0 which causes our layout to go all
// screwy, so we just ignore it.
if (delegate_ && param != SIZE_MINIMIZED)
- NotifyHostResized(size);
+ OnHostResized(size);
}
namespace test {
diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc
index aa8d0c2..2ecefb4 100644
--- a/ui/aura/window_tree_host_x11.cc
+++ b/ui/aura/window_tree_host_x11.cc
@@ -457,9 +457,9 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
ConfineCursorToRootWindow();
}
if (size_changed)
- NotifyHostResized(bounds.size());
+ OnHostResized(bounds.size());
if (origin_changed)
- delegate_->OnHostMoved(bounds_.origin());
+ OnHostMoved(bounds_.origin());
break;
}
case GenericEvent:
@@ -469,7 +469,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]);
if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) {
// We have received a close message from the window manager.
- delegate_->AsDispatcher()->OnWindowTreeHostCloseRequested();
+ OnHostCloseRequested();
} else if (message_type == atom_cache_.GetAtom("_NET_WM_PING")) {
XEvent reply_event = *xev;
reply_event.xclient.window = x_root_window_;
@@ -487,7 +487,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
case MappingModifier:
case MappingKeyboard:
XRefreshKeyboardMapping(&xev->xmapping);
- delegate_->AsDispatcher()->OnKeyboardMappingChanged();
+ OnKeyboardMappingChanged();
break;
case MappingPointer:
ui::DeviceDataManager::GetInstance()->UpdateButtonMap();
@@ -600,9 +600,9 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
bounds_ = bounds;
UpdateIsInternalDisplay();
if (origin_changed)
- delegate_->OnHostMoved(bounds.origin());
+ OnHostMoved(bounds.origin());
if (size_changed || current_scale != new_scale) {
- NotifyHostResized(bounds.size());
+ OnHostResized(bounds.size());
} else {
delegate_->AsDispatcher()->window()->SchedulePaintInRect(
delegate_->AsDispatcher()->window()->bounds());
diff --git a/ui/aura/window_tree_host_x11_unittest.cc b/ui/aura/window_tree_host_x11_unittest.cc
index 2fbdd46..c1e5579 100644
--- a/ui/aura/window_tree_host_x11_unittest.cc
+++ b/ui/aura/window_tree_host_x11_unittest.cc
@@ -30,7 +30,6 @@ class TestWindowTreeHostDelegate : public aura::WindowTreeHostDelegate,
virtual void OnHostActivated() OVERRIDE {}
virtual void OnHostLostWindowCapture() OVERRIDE {}
virtual void OnHostLostMouseGrab() OVERRIDE {}
- virtual void OnHostMoved(const gfx::Point& origin) OVERRIDE {}
virtual void OnHostResized(const gfx::Size& size) OVERRIDE {}
virtual void OnCursorMovedToRootLocation(
const gfx::Point& root_location) OVERRIDE {}
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index 6f0864b..d0e0bd2 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -18,7 +18,6 @@
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/client/visibility_client.h"
#include "ui/aura/client/window_tree_client.h"
-#include "ui/aura/root_window_observer.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_window_delegate.h"
diff --git a/ui/views/examples/content_client/examples_browser_main_parts.cc b/ui/views/examples/content_client/examples_browser_main_parts.cc
index 7ac7e3f..fadf23e 100644
--- a/ui/views/examples/content_client/examples_browser_main_parts.cc
+++ b/ui/views/examples/content_client/examples_browser_main_parts.cc
@@ -60,9 +60,9 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() {
// Set up basic pieces of views::corewm.
wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600)));
// Ensure the X window gets mapped.
- wm_test_helper_->dispatcher()->host()->Show();
+ wm_test_helper_->host()->Show();
// Ensure Aura knows where to open new windows.
- window_context = wm_test_helper_->dispatcher()->window();
+ window_context = wm_test_helper_->host()->window();
#elif defined(USE_AURA)
aura::Env::CreateInstance();
gfx::Screen::SetScreenInstance(
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index f6ecab3..40b7225 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -315,7 +315,7 @@ void DesktopNativeWidgetAura::OnHostClosed() {
aura::client::SetActivationClient(host_->window(), NULL);
focus_client_.reset();
- host_->dispatcher()->RemoveRootWindowObserver(this);
+ host_->RemoveObserver(this);
host_.reset(); // Uses input_method_event_filter_ at destruction.
// WindowEventDispatcher owns |desktop_window_tree_host_|.
desktop_window_tree_host_ = NULL;
@@ -482,9 +482,9 @@ void DesktopNativeWidgetAura::InitNativeWidget(
static_cast<aura::client::FocusClient*>(focus_client_.get())->
FocusWindow(content_window_);
- OnWindowTreeHostResized(host_->dispatcher());
+ OnHostResized(host());
- host_->dispatcher()->AddRootWindowObserver(this);
+ host_->AddObserver(this);
window_tree_client_.reset(
new DesktopNativeWidgetAuraWindowTreeClient(host_->window()));
@@ -1130,22 +1130,21 @@ int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) {
}
////////////////////////////////////////////////////////////////////////////////
-// DesktopNativeWidgetAura, aura::RootWindowObserver implementation:
+// DesktopNativeWidgetAura, aura::WindowTreeHostObserver implementation:
-void DesktopNativeWidgetAura::OnWindowTreeHostCloseRequested(
- const aura::WindowEventDispatcher* dispatcher) {
+void DesktopNativeWidgetAura::OnHostCloseRequested(
+ const aura::WindowTreeHost* host) {
Close();
}
-void DesktopNativeWidgetAura::OnWindowTreeHostResized(
- const aura::WindowEventDispatcher* dispatcher) {
+void DesktopNativeWidgetAura::OnHostResized(const aura::WindowTreeHost* host) {
// Don't update the bounds of the child layers when animating closed. If we
// did it would force a paint, which we don't want. We don't want the paint
// as we can't assume any of the children are valid.
if (desktop_window_tree_host_->IsAnimatingClosed())
return;
- gfx::Rect new_bounds = gfx::Rect(dispatcher->window()->bounds().size());
+ gfx::Rect new_bounds = gfx::Rect(host->window()->bounds().size());
content_window_->SetBounds(new_bounds);
// Can be NULL at start.
if (content_window_container_)
@@ -1153,10 +1152,9 @@ void DesktopNativeWidgetAura::OnWindowTreeHostResized(
native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
}
-void DesktopNativeWidgetAura::OnWindowTreeHostMoved(
- const aura::WindowEventDispatcher* dispatcher,
- const gfx::Point& new_origin) {
- TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnWindowTreeHostMoved",
+void DesktopNativeWidgetAura::OnHostMoved(const aura::WindowTreeHost* host,
+ const gfx::Point& new_origin) {
+ TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnHostMoved",
"new_origin", new_origin.ToString());
native_widget_delegate_->OnNativeWidgetMove();
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
index ba8262e..b4df719 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
@@ -10,13 +10,14 @@
#include "ui/aura/client/activation_delegate.h"
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/aura/client/focus_change_observer.h"
-#include "ui/aura/root_window_observer.h"
#include "ui/aura/window_delegate.h"
+#include "ui/aura/window_tree_host_observer.h"
#include "ui/base/cursor/cursor.h"
#include "ui/views/ime/input_method_delegate.h"
#include "ui/views/widget/native_widget_private.h"
namespace aura {
+class WindowEventDispatcher;
class WindowTreeHost;
namespace client {
class DragDropClient;
@@ -57,7 +58,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
public aura::client::FocusChangeObserver,
public views::internal::InputMethodDelegate,
public aura::client::DragDropDelegate,
- public aura::RootWindowObserver {
+ public aura::WindowTreeHostObserver {
public:
explicit DesktopNativeWidgetAura(internal::NativeWidgetDelegate* delegate);
virtual ~DesktopNativeWidgetAura();
@@ -228,14 +229,11 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
virtual void OnDragExited() OVERRIDE;
virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
- // Overridden from aura::RootWindowObserver:
- virtual void OnWindowTreeHostCloseRequested(
- const aura::WindowEventDispatcher* dispatcher) OVERRIDE;
- virtual void OnWindowTreeHostResized(
- const aura::WindowEventDispatcher* dispatcher) OVERRIDE;
- virtual void OnWindowTreeHostMoved(
- const aura::WindowEventDispatcher* dispatcher,
- const gfx::Point& new_origin) OVERRIDE;
+ // Overridden from aura::WindowTreeHostObserver:
+ virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE;
+ virtual void OnHostResized(const aura::WindowTreeHost* host) OVERRIDE;
+ virtual void OnHostMoved(const aura::WindowTreeHost* host,
+ const gfx::Point& new_origin) OVERRIDE;
private:
friend class FocusManagerEventHandler;
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
index 8375e6d..b88e3a5 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
@@ -809,8 +809,7 @@ void DesktopWindowTreeHostWin::HandleEndWMSizeMove() {
void DesktopWindowTreeHostWin::HandleMove() {
native_widget_delegate_->OnNativeWidgetMove();
- if (delegate_)
- delegate_->OnHostMoved(GetBounds().origin());
+ OnHostMoved(GetBounds().origin());
}
void DesktopWindowTreeHostWin::HandleWorkAreaChanged() {
@@ -828,7 +827,7 @@ void DesktopWindowTreeHostWin::HandleVisibilityChanged(bool visible) {
void DesktopWindowTreeHostWin::HandleClientSizeChanged(
const gfx::Size& new_size) {
if (delegate_)
- NotifyHostResized(new_size);
+ OnHostResized(new_size);
}
void DesktopWindowTreeHostWin::HandleFrameChanged() {
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index 785a816..514a2bd 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -367,7 +367,7 @@ void DesktopWindowTreeHostX11::SetSize(const gfx::Size& size) {
XResizeWindow(xdisplay_, xwindow_, size.width(), size.height());
bounds_.set_size(size);
if (size_changed)
- NotifyHostResized(size);
+ OnHostResized(size);
}
void DesktopWindowTreeHostX11::StackAtTop() {
@@ -797,7 +797,7 @@ void DesktopWindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
if (origin_changed)
native_widget_delegate_->AsWidget()->OnNativeWidgetMove();
if (size_changed)
- NotifyHostResized(bounds.size());
+ OnHostResized(bounds.size());
else
compositor()->ScheduleRedrawRect(gfx::Rect(bounds.size()));
}
@@ -1376,9 +1376,9 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
previous_bounds_ = bounds_;
bounds_ = bounds;
if (size_changed)
- NotifyHostResized(bounds.size());
+ OnHostResized(bounds.size());
if (origin_changed)
- delegate_->OnHostMoved(bounds_.origin());
+ OnHostMoved(bounds_.origin());
ResetWindowRegion();
break;
}
@@ -1489,7 +1489,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
Atom protocol = static_cast<Atom>(xev->xclient.data.l[0]);
if (protocol == atom_cache_.GetAtom("WM_DELETE_WINDOW")) {
// We have received a close message from the window manager.
- dispatcher_->OnWindowTreeHostCloseRequested();
+ OnHostCloseRequested();
} else if (protocol == atom_cache_.GetAtom("_NET_WM_PING")) {
XEvent reply_event = *xev;
reply_event.xclient.window = x_root_window_;
@@ -1520,7 +1520,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
case MappingModifier:
case MappingKeyboard:
XRefreshKeyboardMapping(&xev->xmapping);
- dispatcher_->OnKeyboardMappingChanged();
+ OnKeyboardMappingChanged();
break;
case MappingPointer:
ui::DeviceDataManager::GetInstance()->UpdateButtonMap();
diff --git a/ui/wm/test/wm_test_helper.h b/ui/wm/test/wm_test_helper.h
index 832a557..d6720c0 100644
--- a/ui/wm/test/wm_test_helper.h
+++ b/ui/wm/test/wm_test_helper.h
@@ -12,7 +12,6 @@
namespace aura {
class Window;
-class WindowEventDispatcher;
class WindowTreeHost;
namespace client {
class DefaultActivationClient;
@@ -43,7 +42,7 @@ class WMTestHelper : public aura::client::WindowTreeClient {
explicit WMTestHelper(const gfx::Size& default_window_size);
virtual ~WMTestHelper();
- aura::WindowEventDispatcher* dispatcher() { return host_->dispatcher(); }
+ aura::WindowTreeHost* host() { return host_.get(); }
// Overridden from client::WindowTreeClient:
virtual aura::Window* GetDefaultParent(aura::Window* context,