diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-28 10:07:38 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-28 10:07:38 +0000 |
commit | 2f262033a848841959f2d35d40f3d97b703e9684 (patch) | |
tree | 3f4ca60422ea84530991cc3c405e10a523446d68 /mojo | |
parent | a4b8e0898b53e7e57f27ee1726cf66a37a4660d3 (diff) | |
download | chromium_src-2f262033a848841959f2d35d40f3d97b703e9684.zip chromium_src-2f262033a848841959f2d35d40f3d97b703e9684.tar.gz chromium_src-2f262033a848841959f2d35d40f3d97b703e9684.tar.bz2 |
Invert the ownership relationship between WindowEventDispatcher and WindowTreeHost.
Prior to this change, WindowEventDispatcher owns WindowTreeHost. Code wishing to own an aura::Window hierarchy must create a WindowEventDispatcher, which will either create a default WTH implementation or use the one supplied by the caller.
This relationship made more sense long ago in the days when WED was called RootWindow, and served a purpose broader than just event dispatch bookkeeping. Those days are gone. For code using Aura, it makes more sense for them to create the WTH directly. I predict this may permit some simplification of shutdown code in some situations, since I think it is more intuitive to think of the destruction cascade initiating at the object that most closely binds to the platform accelerated widget. Today, ownership of the window tree sits with WED, which must destroy the window tree and the host.
This CL attempts to make as few changes as possible to invert the ownership. The effect of this is that there is a bunch of code left that probably only needs a WTH but instead has a WED. I will get around to cleaning these up in a future CL.
http://crbug.com/308843
R=sky@chromium.org
Review URL: https://codereview.chromium.org/180003006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254071 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/examples/aura_demo/aura_demo.cc | 20 | ||||
-rw-r--r-- | mojo/examples/launcher/launcher.cc | 30 |
2 files changed, 20 insertions, 30 deletions
diff --git a/mojo/examples/aura_demo/aura_demo.cc b/mojo/examples/aura_demo/aura_demo.cc index a9bf880..a65036a 100644 --- a/mojo/examples/aura_demo/aura_demo.cc +++ b/mojo/examples/aura_demo/aura_demo.cc @@ -22,7 +22,6 @@ #include "ui/aura/env.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" -#include "ui/aura/window_event_dispatcher.h" #include "ui/base/hit_test.h" #include "ui/gfx/canvas.h" @@ -134,28 +133,24 @@ class AuraDemo : public Application { private: void HostContextCreated() { - aura::WindowEventDispatcher::CreateParams params( - gfx::Rect(window_tree_host_->bounds().size())); - params.host = window_tree_host_.get(); - dispatcher_.reset(new aura::WindowEventDispatcher(params)); - window_tree_host_->set_delegate(dispatcher_.get()); - dispatcher_->host()->InitHost(); + window_tree_host_->InitHost(); - window_tree_client_.reset(new DemoWindowTreeClient(dispatcher_->window())); + window_tree_client_.reset( + new DemoWindowTreeClient(window_tree_host_->window())); delegate1_.reset(new DemoWindowDelegate(SK_ColorBLUE)); window1_ = new aura::Window(delegate1_.get()); window1_->Init(aura::WINDOW_LAYER_TEXTURED); window1_->SetBounds(gfx::Rect(100, 100, 400, 400)); window1_->Show(); - dispatcher_->window()->AddChild(window1_); + window_tree_host_->window()->AddChild(window1_); delegate2_.reset(new DemoWindowDelegate(SK_ColorRED)); window2_ = new aura::Window(delegate2_.get()); window2_->Init(aura::WINDOW_LAYER_TEXTURED); window2_->SetBounds(gfx::Rect(200, 200, 350, 350)); window2_->Show(); - dispatcher_->window()->AddChild(window2_); + window_tree_host_->window()->AddChild(window2_); delegate21_.reset(new DemoWindowDelegate(SK_ColorGREEN)); window21_ = new aura::Window(delegate21_.get()); @@ -164,7 +159,7 @@ class AuraDemo : public Application { window21_->Show(); window2_->AddChild(window21_); - dispatcher_->host()->Show(); + window_tree_host_->Show(); } scoped_ptr<DemoScreen> screen_; @@ -179,8 +174,7 @@ class AuraDemo : public Application { aura::Window* window2_; aura::Window* window21_; - scoped_ptr<WindowTreeHostMojo> window_tree_host_; - scoped_ptr<aura::WindowEventDispatcher> dispatcher_; + scoped_ptr<aura::WindowTreeHost> window_tree_host_; }; } // namespace examples diff --git a/mojo/examples/launcher/launcher.cc b/mojo/examples/launcher/launcher.cc index 5e19f84..a86bb25 100644 --- a/mojo/examples/launcher/launcher.cc +++ b/mojo/examples/launcher/launcher.cc @@ -221,14 +221,14 @@ class LauncherImpl : public Application, // Overridden from Launcher: virtual void Show() OVERRIDE { - if (!dispatcher_.get()) { + if (!window_tree_host_.get()) { pending_show_ = true; return; } - dispatcher_->host()->Show(); + window_tree_host_->Show(); } virtual void Hide() OVERRIDE { - dispatcher_->host()->Hide(); + window_tree_host_->Hide(); } // Overridden from URLReceiver: @@ -238,25 +238,22 @@ class LauncherImpl : public Application, } void HostContextCreated() { - aura::WindowEventDispatcher::CreateParams params(gfx::Rect(450, 60)); - params.host = window_tree_host_.get(); - dispatcher_.reset(new aura::WindowEventDispatcher(params)); - window_tree_host_->set_delegate(dispatcher_.get()); - dispatcher_->host()->InitHost(); - dispatcher_->window()->SetBounds(gfx::Rect(450, 60)); + window_tree_host_->InitHost(); + window_tree_host_->window()->SetBounds(gfx::Rect(450, 60)); focus_client_.reset(new aura::test::TestFocusClient()); - aura::client::SetFocusClient(dispatcher_->window(), focus_client_.get()); + aura::client::SetFocusClient(window_tree_host_->window(), + focus_client_.get()); activation_client_.reset( - new aura::client::DefaultActivationClient(dispatcher_->window())); + new aura::client::DefaultActivationClient(window_tree_host_->window())); capture_client_.reset( - new aura::client::DefaultCaptureClient(dispatcher_->window())); - ime_filter_.reset(new MinimalInputEventFilter(dispatcher_->window())); + new aura::client::DefaultCaptureClient(window_tree_host_->window())); + ime_filter_.reset(new MinimalInputEventFilter(window_tree_host_->window())); window_tree_client_.reset( - new LauncherWindowTreeClient(dispatcher_->window())); + new LauncherWindowTreeClient(window_tree_host_->window())); - launcher_controller_.InitInWindow(dispatcher_->window()); + launcher_controller_.InitInWindow(window_tree_host_->window()); if (pending_show_) { pending_show_ = false; @@ -274,8 +271,7 @@ class LauncherImpl : public Application, LauncherController launcher_controller_; RemotePtr<LauncherClient> launcher_client_; - scoped_ptr<WindowTreeHostMojo> window_tree_host_; - scoped_ptr<aura::WindowEventDispatcher> dispatcher_; + scoped_ptr<aura::WindowTreeHost> window_tree_host_; bool pending_show_; }; |