diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-05 02:34:06 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-05 02:34:06 +0000 |
commit | 9e599a93b7f032350fb16d4eed59c0ebc3b15db2 (patch) | |
tree | 9ca5511758c5034be4b402af9e1d55d9ecb64cf7 /ui/aura | |
parent | f1ccdf3d94a2aaa22c2b4d4371b9539a7324ee68 (diff) | |
download | chromium_src-9e599a93b7f032350fb16d4eed59c0ebc3b15db2.zip chromium_src-9e599a93b7f032350fb16d4eed59c0ebc3b15db2.tar.gz chromium_src-9e599a93b7f032350fb16d4eed59c0ebc3b15db2.tar.bz2 |
ozone: Use PlatformEventSource for dispatching events.
Notable changes:
* Convert EventFactoryOzone into a PlatformEventSource.
* Convert WindowTreeHostOzone into a PlatformEventDispatcher.
* The WindowTreeHostOzone looks at the location of the event for mouse, scroll
and touch-events to decide whether it should dispatch the event or not. It
expects the event-location it receives to be in the same coordinate space as
its bounds.
* Adds an ObserverList in MessagePumpOzone, and the EventFactoryOzone reaches
into the message-pump to trigger these observers. This is a short-term
workaround (the same is done for X11 in http://crrev.com/219743002/), until
the message-pump observers are converted into PlatformEventObservers.
* Have EventConverterEvdev take in a callback that can be used for dispatching
events it receives. The EventFactoryEvdev sets this callback to each of these
converters after creation.
* Change the asynchronous event-dispatch to be synchronous.
This set of changes allows dispatching events to multiple window-tree hosts (at
least in theory).
BUG=319986
R=rjkroege@chromium.org, spang@chromium.org
Review URL: https://codereview.chromium.org/223363003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r-- | ui/aura/window_event_dispatcher_unittest.cc | 17 | ||||
-rw-r--r-- | ui/aura/window_tree_host_ozone.cc | 17 | ||||
-rw-r--r-- | ui/aura/window_tree_host_ozone.h | 11 |
3 files changed, 19 insertions, 26 deletions
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc index 3ac9857..d0985b4 100644 --- a/ui/aura/window_event_dispatcher_unittest.cc +++ b/ui/aura/window_event_dispatcher_unittest.cc @@ -36,15 +36,6 @@ namespace aura { namespace { -bool PlatformSupportsMultipleHosts() { -#if defined(USE_OZONE) - // Creating multiple WindowTreeHostOzone instances is broken. - return false; -#else - return true; -#endif -} - // A delegate that always returns a non-client component for hit tests. class NonClientDelegate : public test::TestWindowDelegate { public: @@ -1363,8 +1354,6 @@ class ValidRootDuringDestructionWindowObserver : public aura::WindowObserver { // Verifies GetRootWindow() from ~Window returns a valid root. TEST_F(WindowEventDispatcherTest, ValidRootDuringDestruction) { - if (!PlatformSupportsMultipleHosts()) - return; bool got_destroying = false; bool has_valid_root = false; ValidRootDuringDestructionWindowObserver observer(&got_destroying, @@ -1478,8 +1467,6 @@ class DeleteHostFromHeldMouseEventDelegate // Verifies if a WindowTreeHost is deleted from dispatching a held mouse event // we don't crash. TEST_F(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) { - if (!PlatformSupportsMultipleHosts()) - return; // Should be deleted by |delegate|. WindowTreeHost* h2 = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)); h2->InitHost(); @@ -1948,8 +1935,6 @@ class MoveWindowHandler : public ui::EventHandler { // event being dispatched is moved to a different dispatcher in response to an // event in the inner loop. TEST_F(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) { - if (!PlatformSupportsMultipleHosts()) - return; scoped_ptr<WindowTreeHost> second_host( WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); second_host->InitHost(); @@ -2006,8 +1991,6 @@ class AlwaysMouseDownInputStateLookup : public InputStateLookup { TEST_F(WindowEventDispatcherTest, CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { - if (!PlatformSupportsMultipleHosts()) - return; test::EventCountDelegate delegate; scoped_ptr<Window> window(CreateTestWindowWithDelegate(&delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); diff --git a/ui/aura/window_tree_host_ozone.cc b/ui/aura/window_tree_host_ozone.cc index 013fae8..0a01e42 100644 --- a/ui/aura/window_tree_host_ozone.cc +++ b/ui/aura/window_tree_host_ozone.cc @@ -7,6 +7,7 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/base/cursor/ozone/cursor_factory_ozone.h" #include "ui/events/ozone/event_factory_ozone.h" +#include "ui/events/platform/platform_event_source.h" #include "ui/gfx/ozone/surface_factory_ozone.h" #include "ui/ozone/ozone_platform.h" @@ -26,20 +27,28 @@ WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds) gfx::SurfaceFactoryOzone::GetInstance(); widget_ = surface_factory->GetAcceleratedWidget(); - base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this); + ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); CreateCompositor(GetAcceleratedWidget()); } WindowTreeHostOzone::~WindowTreeHostOzone() { - base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0); + ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); DestroyCompositor(); DestroyDispatcher(); } -uint32_t WindowTreeHostOzone::Dispatch(const base::NativeEvent& ne) { +bool WindowTreeHostOzone::CanDispatchEvent(const ui::PlatformEvent& ne) { + CHECK(ne); + ui::Event* event = static_cast<ui::Event*>(ne); + if (event->IsMouseEvent() || event->IsScrollEvent() || event->IsTouchEvent()) + return bounds_.Contains(static_cast<ui::LocatedEvent*>(event)->location()); + return true; +} + +uint32_t WindowTreeHostOzone::DispatchEvent(const ui::PlatformEvent& ne) { ui::Event* event = static_cast<ui::Event*>(ne); ui::EventDispatchDetails details ALLOW_UNUSED = SendEventToProcessor(event); - return POST_DISPATCH_NONE; + return ui::POST_DISPATCH_STOP_PROPAGATION; } gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() { diff --git a/ui/aura/window_tree_host_ozone.h b/ui/aura/window_tree_host_ozone.h index dadae63c..0e1f469 100644 --- a/ui/aura/window_tree_host_ozone.h +++ b/ui/aura/window_tree_host_ozone.h @@ -8,9 +8,9 @@ #include <vector> #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_pump_dispatcher.h" #include "ui/aura/window_tree_host.h" #include "ui/events/event_source.h" +#include "ui/events/platform/platform_event_dispatcher.h" #include "ui/gfx/insets.h" #include "ui/gfx/rect.h" @@ -18,16 +18,17 @@ namespace aura { class WindowTreeHostOzone : public WindowTreeHost, public ui::EventSource, - public base::MessagePumpDispatcher { + public ui::PlatformEventDispatcher { public: explicit WindowTreeHostOzone(const gfx::Rect& bounds); virtual ~WindowTreeHostOzone(); private: - // Overridden from Dispatcher overrides: - virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; + // ui::PlatformEventDispatcher: + virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; + virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; - // WindowTreeHost Overrides. + // WindowTreeHost: virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; |