diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-06 23:55:51 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-06 23:55:51 +0000 |
commit | 8daeb41bb826c0908d1b5a2132c90a068ecf2c46 (patch) | |
tree | ca30a7fc6fd52427ce228b787617fb9ce1bdecf0 /ui/aura | |
parent | ad0dfb76499ae73a0f52a06e905680d5cd72bf0b (diff) | |
download | chromium_src-8daeb41bb826c0908d1b5a2132c90a068ecf2c46.zip chromium_src-8daeb41bb826c0908d1b5a2132c90a068ecf2c46.tar.gz chromium_src-8daeb41bb826c0908d1b5a2132c90a068ecf2c46.tar.bz2 |
aura: Start updating aura to use EventProcessor for event dispatch.
Notable changes in this CL:
* A WindowTargeter implementation for finding the target Window for an event
(currently unused), with only a most basic test.
* Make RootWindow a ui::EventProcessor.
* Make RootWindowHostX11 a ui::EventSource.
Note that RootWindowHostX11 continues to dispatch events to the RootWindow using
RootWindowHostDelegate interface. This CL prepares much of the machinery for
switching to EventProcessor interface for event dispatch, but it is essentially a
no-op for now.
BUG=318879
R=ben@chromium.org
Review URL: https://codereview.chromium.org/108043005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239277 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r-- | ui/aura/aura.gyp | 3 | ||||
-rw-r--r-- | ui/aura/root_window.cc | 67 | ||||
-rw-r--r-- | ui/aura/root_window.h | 17 | ||||
-rw-r--r-- | ui/aura/root_window_host_x11.cc | 4 | ||||
-rw-r--r-- | ui/aura/root_window_host_x11.h | 6 | ||||
-rw-r--r-- | ui/aura/root_window_host_x11_unittest.cc | 51 | ||||
-rw-r--r-- | ui/aura/window.h | 2 | ||||
-rw-r--r-- | ui/aura/window_targeter.cc | 59 | ||||
-rw-r--r-- | ui/aura/window_targeter.h | 25 | ||||
-rw-r--r-- | ui/aura/window_targeter_unittest.cc | 54 | ||||
-rw-r--r-- | ui/aura/window_tree_host_delegate.h | 3 |
11 files changed, 246 insertions, 45 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index 82de6bf..64807a1 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -99,6 +99,8 @@ 'root_window.h', 'window.cc', 'window.h', + 'window_targeter.cc', + 'window_targeter.h', 'window_delegate.h', 'window_layer_type.h', 'window_observer.h', @@ -267,6 +269,7 @@ 'test/run_all_unittests.cc', 'test/test_suite.cc', 'test/test_suite.h', + 'window_targeter_unittest.cc', 'window_unittest.cc', ], 'conditions': [ diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index eace62e..3cf0630 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -21,6 +21,7 @@ #include "ui/aura/root_window_transformer.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" +#include "ui/aura/window_targeter.h" #include "ui/aura/window_tracker.h" #include "ui/aura/window_tree_host.h" #include "ui/base/hit_test.h" @@ -148,12 +149,15 @@ RootWindow::RootWindow(const CreateParams& params) mouse_pressed_handler_(NULL), mouse_moved_handler_(NULL), event_dispatch_target_(NULL), + old_dispatch_target_(NULL), synthesize_mouse_move_(false), move_hold_count_(0), repost_event_factory_(this), held_event_factory_(this) { window()->set_dispatcher(this); window()->SetName("RootWindow"); + window()->set_event_targeter( + scoped_ptr<ui::EventTargeter>(new WindowTargeter())); compositor_.reset(new ui::Compositor(host_->GetAcceleratedWidget())); DCHECK(compositor_.get()); @@ -332,7 +336,7 @@ void RootWindow::DispatchGestureEvent(ui::GestureEvent* event) { Window* target = GetGestureTarget(event); if (target) { event->ConvertLocationToTarget(window(), target); - DispatchDetails details = ProcessEvent(target, event); + DispatchDetails details = DispatchEvent(target, event); if (details.dispatcher_destroyed) return; } @@ -522,20 +526,7 @@ ui::EventDispatchDetails RootWindow::DispatchMouseEnterOrExit( mouse_moved_handler_, type, event.flags() | ui::EF_IS_SYNTHESIZED); - return ProcessEvent(mouse_moved_handler_, &translated_event); -} - -ui::EventDispatchDetails RootWindow::ProcessEvent(Window* target, - ui::Event* event) { - Window* old_target = event_dispatch_target_; - event_dispatch_target_ = target; - DispatchDetails details = DispatchEvent(target, event); - if (!details.dispatcher_destroyed) { - if (event_dispatch_target_ != target) - details.target_destroyed = true; - event_dispatch_target_ = old_target; - } - return details; + return DispatchEvent(mouse_moved_handler_, &translated_event); } ui::EventDispatchDetails RootWindow::ProcessGestures( @@ -548,7 +539,7 @@ ui::EventDispatchDetails RootWindow::ProcessGestures( for (size_t i = 0; i < gestures->size(); ++i) { ui::GestureEvent* event = gestures->get().at(i); event->ConvertLocationToTarget(window(), target); - details = ProcessEvent(target, event); + details = DispatchEvent(target, event); if (details.dispatcher_destroyed || details.target_destroyed) break; } @@ -634,7 +625,7 @@ void RootWindow::UpdateCapture(Window* old_capture, ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), gfx::Point(), 0); - DispatchDetails details = ProcessEvent(old_capture, &event); + DispatchDetails details = DispatchEvent(old_capture, &event); if (details.dispatcher_destroyed) return; @@ -669,12 +660,38 @@ void RootWindow::ReleaseNativeCapture() { } //////////////////////////////////////////////////////////////////////////////// +// RootWindow, ui::EventProcessor implementation: +ui::EventTarget* RootWindow::GetRootTarget() { + return window(); +} + +//////////////////////////////////////////////////////////////////////////////// // RootWindow, ui::EventDispatcherDelegate implementation: bool RootWindow::CanDispatchToTarget(ui::EventTarget* target) { return event_dispatch_target_ == target; } +ui::EventDispatchDetails RootWindow::PreDispatchEvent(ui::EventTarget* target, + ui::Event* event) { + old_dispatch_target_ = event_dispatch_target_; + event_dispatch_target_ = static_cast<Window*>(target); + return DispatchDetails(); +} + +ui::EventDispatchDetails RootWindow::PostDispatchEvent(ui::EventTarget* target, + const ui::Event& event) { + DispatchDetails details; + if (target != event_dispatch_target_) + details.target_destroyed = true; + event_dispatch_target_ = old_dispatch_target_; + old_dispatch_target_ = NULL; +#ifndef NDEBUG + DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); +#endif + return details; +} + //////////////////////////////////////////////////////////////////////////////// // RootWindow, ui::GestureEventHelper implementation: @@ -722,7 +739,7 @@ bool RootWindow::OnHostKeyEvent(ui::KeyEvent* event) { client::GetFocusClient(window())->FocusWindow(NULL); return false; } - details = ProcessEvent(focused_window ? focused_window : window(), event); + details = DispatchEvent(focused_window ? focused_window : window(), event); if (details.dispatcher_destroyed) return true; return event->handled(); @@ -757,7 +774,7 @@ bool RootWindow::OnHostScrollEvent(ui::ScrollEvent* event) { flags |= ui::EF_IS_NON_CLIENT; event->set_flags(flags); - details = ProcessEvent(target, event); + details = DispatchEvent(target, event); if (details.dispatcher_destroyed) return true; return event->handled(); @@ -790,7 +807,7 @@ void RootWindow::OnHostCancelMode() { ui::CancelModeEvent event; Window* focused_window = client::GetFocusClient(window())->GetFocusedWindow(); DispatchDetails details = - ProcessEvent(focused_window ? focused_window : window(), &event); + DispatchEvent(focused_window ? focused_window : window(), &event); if (details.dispatcher_destroyed) return; } @@ -852,6 +869,10 @@ const RootWindow* RootWindow::AsRootWindow() const { return this; } +ui::EventProcessor* RootWindow::GetEventProcessor() { + return this; +} + //////////////////////////////////////////////////////////////////////////////// // RootWindow, private: @@ -983,7 +1004,7 @@ ui::EventDispatchDetails RootWindow::DispatchMouseEventToTarget( event->ConvertLocationToTarget(window(), target); if (IsNonClientLocation(target, event->location())) event->set_flags(event->flags() | ui::EF_IS_NON_CLIENT); - return ProcessEvent(target, event); + return DispatchEvent(target, event); } return DispatchDetails(); } @@ -1030,7 +1051,7 @@ ui::EventDispatchDetails RootWindow::DispatchTouchEventImpl( if (!target && !window()->bounds().Contains(event->location())) { // If the initial touch is outside the root window, target the root. target = window(); - DispatchDetails details = ProcessEvent(target ? target : NULL, event); + DispatchDetails details = DispatchEvent(target ? target : NULL, event); if (details.dispatcher_destroyed) return details; result = event->result(); @@ -1043,7 +1064,7 @@ ui::EventDispatchDetails RootWindow::DispatchTouchEventImpl( } event->ConvertLocationToTarget(window(), target); - DispatchDetails details = ProcessEvent(target, event); + DispatchDetails details = DispatchEvent(target, event); if (details.dispatcher_destroyed) return details; result = event->result(); diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index 26274d45..d85e1d8 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -21,7 +21,8 @@ #include "ui/compositor/compositor.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/events/event_constants.h" -#include "ui/events/event_dispatcher.h" +#include "ui/events/event_processor.h" +#include "ui/events/event_targeter.h" #include "ui/events/gestures/gesture_recognizer.h" #include "ui/events/gestures/gesture_types.h" #include "ui/gfx/native_widget_types.h" @@ -50,9 +51,10 @@ class RootWindowHost; class RootWindowObserver; class RootWindowTransformer; class TestScreen; +class WindowTargeter; // RootWindow is responsible for hosting a set of windows. -class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate, +class AURA_EXPORT RootWindow : public ui::EventProcessor, public ui::GestureEventHelper, public ui::LayerAnimationObserver, public aura::client::CaptureDelegate, @@ -243,8 +245,6 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate, ui::EventDispatchDetails DispatchMouseEnterOrExit( const ui::MouseEvent& event, ui::EventType type) WARN_UNUSED_RESULT; - ui::EventDispatchDetails ProcessEvent(Window* target, - ui::Event* event) WARN_UNUSED_RESULT; ui::EventDispatchDetails ProcessGestures( ui::GestureRecognizer::Gestures* gestures) WARN_UNUSED_RESULT; @@ -271,8 +271,15 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate, virtual void SetNativeCapture() OVERRIDE; virtual void ReleaseNativeCapture() OVERRIDE; + // Overridden from ui::EventProcessor: + virtual ui::EventTarget* GetRootTarget() OVERRIDE; + // Overridden from ui::EventDispatcherDelegate. virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE; + virtual ui::EventDispatchDetails PreDispatchEvent(ui::EventTarget* target, + ui::Event* event) OVERRIDE; + virtual ui::EventDispatchDetails PostDispatchEvent( + ui::EventTarget* target, const ui::Event& event) OVERRIDE; // Overridden from ui::GestureEventHelper. virtual bool CanDispatchToConsumer(ui::GestureConsumer* consumer) OVERRIDE; @@ -302,6 +309,7 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate, virtual float GetDeviceScaleFactor() OVERRIDE; virtual RootWindow* AsRootWindow() OVERRIDE; virtual const RootWindow* AsRootWindow() const OVERRIDE; + virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; ui::EventDispatchDetails OnHostMouseEventImpl(ui::MouseEvent* event) WARN_UNUSED_RESULT; @@ -354,6 +362,7 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate, Window* mouse_pressed_handler_; Window* mouse_moved_handler_; Window* event_dispatch_target_; + Window* old_dispatch_target_; bool synthesize_mouse_move_; bool waiting_on_compositing_end_; diff --git a/ui/aura/root_window_host_x11.cc b/ui/aura/root_window_host_x11.cc index a4ac892..4fb0047 100644 --- a/ui/aura/root_window_host_x11.cc +++ b/ui/aura/root_window_host_x11.cc @@ -822,6 +822,10 @@ void RootWindowHostX11::OnRootWindowInitialized(RootWindow* root_window) { SetCrOSTapPaused(false); } +ui::EventProcessor* RootWindowHostX11::GetEventProcessor() { + return delegate_->GetEventProcessor(); +} + bool RootWindowHostX11::DispatchEventForRootWindow( const base::NativeEvent& event) { switch (event->type) { diff --git a/ui/aura/root_window_host_x11.h b/ui/aura/root_window_host_x11.h index 53bf46e..d4b3518 100644 --- a/ui/aura/root_window_host_x11.h +++ b/ui/aura/root_window_host_x11.h @@ -18,6 +18,7 @@ #include "ui/aura/env_observer.h" #include "ui/aura/window_tree_host.h" #include "ui/base/x/x11_util.h" +#include "ui/events/event_source.h" #include "ui/gfx/insets.h" #include "ui/gfx/rect.h" #include "ui/gfx/x/x11_atom_cache.h" @@ -34,6 +35,7 @@ class TouchEventCalibrate; class AURA_EXPORT RootWindowHostX11 : public RootWindowHost, public base::MessageLoop::Dispatcher, + public ui::EventSource, public EnvObserver { public: explicit RootWindowHostX11(const gfx::Rect& bounds); @@ -68,6 +70,10 @@ class AURA_EXPORT RootWindowHostX11 : public RootWindowHost, // EnvObserver overrides. virtual void OnWindowInitialized(Window* window) OVERRIDE; virtual void OnRootWindowInitialized(RootWindow* root_window) OVERRIDE; + + // ui::EventSource overrides. + virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; + private: class MouseMoveFilter; diff --git a/ui/aura/root_window_host_x11_unittest.cc b/ui/aura/root_window_host_x11_unittest.cc index 77e62fe..576707a 100644 --- a/ui/aura/root_window_host_x11_unittest.cc +++ b/ui/aura/root_window_host_x11_unittest.cc @@ -9,10 +9,15 @@ #include "ui/aura/root_window_host_x11.h" #include "ui/aura/test/aura_test_base.h" #include "ui/aura/window_tree_host_delegate.h" +#include "ui/events/event_processor.h" +#include "ui/events/event_target.h" +#include "ui/events/event_target_iterator.h" #include "ui/events/test/events_test_utils_x11.h" namespace { -class TestRootWindowHostDelegate : public aura::RootWindowHostDelegate { +class TestRootWindowHostDelegate : public aura::RootWindowHostDelegate, + public ui::EventProcessor, + public ui::EventTarget { public: TestRootWindowHostDelegate() : last_touch_type_(ui::ET_UNKNOWN), last_touch_id_(-1), @@ -20,17 +25,16 @@ class TestRootWindowHostDelegate : public aura::RootWindowHostDelegate { } virtual ~TestRootWindowHostDelegate() {} + // aura::RootWindowHostDelegate: virtual bool OnHostKeyEvent(ui::KeyEvent* event) OVERRIDE { return true; } - virtual bool OnHostMouseEvent(ui::MouseEvent* event) OVERRIDE { return true; } virtual bool OnHostScrollEvent(ui::ScrollEvent* event) OVERRIDE { return true; } - virtual bool OnHostTouchEvent(ui::TouchEvent* event) OVERRIDE { last_touch_id_ = event->touch_id(); last_touch_type_ = event->type(); @@ -39,32 +43,42 @@ class TestRootWindowHostDelegate : public aura::RootWindowHostDelegate { } virtual void OnHostCancelMode() OVERRIDE {} - - // Called when the windowing system activates the window. virtual void OnHostActivated() OVERRIDE {} - - // Called when system focus is changed to another window. virtual void OnHostLostWindowCapture() OVERRIDE {} - - // Called when the windowing system has mouse grab because it's performing a - // window move on our behalf, but we should still paint as if we're active. virtual void OnHostLostMouseGrab() OVERRIDE {} - virtual void OnHostPaint(const gfx::Rect& damage_rect) OVERRIDE {} - virtual void OnHostMoved(const gfx::Point& origin) OVERRIDE {} virtual void OnHostResized(const gfx::Size& size) OVERRIDE {} + virtual float GetDeviceScaleFactor() OVERRIDE { return 1.0f; } + virtual aura::RootWindow* AsRootWindow() OVERRIDE { return NULL; } + virtual const aura::RootWindow* AsRootWindow() const OVERRIDE { return NULL; } + virtual ui::EventProcessor* GetEventProcessor() OVERRIDE { + return this; + } - virtual float GetDeviceScaleFactor() OVERRIDE { - return 1.0f; + // ui::EventProcessor: + virtual ui::EventTarget* GetRootTarget() OVERRIDE { return this; } + virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE { + return true; } - virtual aura::RootWindow* AsRootWindow() OVERRIDE { - return NULL; + // ui::EventHandler: + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { + last_touch_id_ = event->touch_id(); + last_touch_type_ = event->type(); + last_touch_location_ = event->location(); + } + + // ui::EventTarget: + virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE { + return true; } - virtual const aura::RootWindow* AsRootWindow() const OVERRIDE { - return NULL; + virtual ui::EventTarget* GetParentTarget() OVERRIDE { return NULL; } + virtual scoped_ptr<ui::EventTargetIterator> + GetChildIterator() const OVERRIDE { + return scoped_ptr<ui::EventTargetIterator>(); } + virtual ui::EventTargeter* GetEventTargeter() OVERRIDE { return &targeter_; } ui::EventType last_touch_type() { return last_touch_type_; @@ -82,6 +96,7 @@ class TestRootWindowHostDelegate : public aura::RootWindowHostDelegate { ui::EventType last_touch_type_; int last_touch_id_; gfx::Point last_touch_location_; + ui::EventTargeter targeter_; DISALLOW_COPY_AND_ASSIGN(TestRootWindowHostDelegate); }; diff --git a/ui/aura/window.h b/ui/aura/window.h index c6dcd09..c104ae5 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -251,6 +251,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate, bool HasObserver(WindowObserver* observer); void set_ignore_events(bool ignore_events) { ignore_events_ = ignore_events; } + bool ignore_events() const { return ignore_events_; } // Sets the window to grab hits for mouse and touch to an area extending // -|mouse_insets| and -|touch_insets| pixels outside its bounds. This can be @@ -376,6 +377,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate, private: friend class test::WindowTestApi; friend class LayoutManager; + friend class WindowTargeter; friend class RootWindow; // Used when stacking windows. diff --git a/ui/aura/window_targeter.cc b/ui/aura/window_targeter.cc new file mode 100644 index 0000000..767a79d --- /dev/null +++ b/ui/aura/window_targeter.cc @@ -0,0 +1,59 @@ +// Copyright (c) 2013 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. + +#include "ui/aura/window_targeter.h" + +#include "ui/aura/client/event_client.h" +#include "ui/aura/client/focus_client.h" +#include "ui/aura/window.h" +#include "ui/aura/window_delegate.h" +#include "ui/events/event_target.h" + +namespace aura { + +WindowTargeter::WindowTargeter() {} +WindowTargeter::~WindowTargeter() {} + +ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root, + ui::Event* event) { + if (event->IsKeyEvent()) { + Window* window = static_cast<Window*>(root); + Window* root_window = window->GetRootWindow(); + const ui::KeyEvent& key = static_cast<const ui::KeyEvent&>(*event); + if (key.key_code() == ui::VKEY_UNKNOWN) + return NULL; + client::EventClient* event_client = client::GetEventClient(root_window); + client::FocusClient* focus_client = client::GetFocusClient(root_window); + Window* focused_window = focus_client->GetFocusedWindow(); + if (event_client && + !event_client->CanProcessEventsWithinSubtree(focused_window)) { + focus_client->FocusWindow(NULL); + return NULL; + } + return focused_window ? focused_window : window; + } + return EventTargeter::FindTargetForEvent(root, event); +} + +bool WindowTargeter::SubtreeShouldBeExploredForEvent( + ui::EventTarget* root, + const ui::LocatedEvent& event) { + Window* window = static_cast<Window*>(root); + if (!window->IsVisible()) + return false; + if (window->ignore_events()) + return false; + client::EventClient* client = client::GetEventClient(window->GetRootWindow()); + if (client && !client->CanProcessEventsWithinSubtree(window)) + return false; + + Window* parent = window->parent(); + if (parent && parent->delegate_ && !parent->delegate_-> + ShouldDescendIntoChildForEventHandling(window, event.location())) { + return false; + } + return window->bounds().Contains(event.location()); +} + +} // namespace aura diff --git a/ui/aura/window_targeter.h b/ui/aura/window_targeter.h new file mode 100644 index 0000000..ba69ed8 --- /dev/null +++ b/ui/aura/window_targeter.h @@ -0,0 +1,25 @@ +// Copyright (c) 2013 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. + +#include "ui/events/event_targeter.h" + +namespace aura { + +class WindowTargeter : public ui::EventTargeter { + public: + WindowTargeter(); + virtual ~WindowTargeter(); + + protected: + // ui::EventTargeter: + virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, + ui::Event* event) OVERRIDE; + virtual bool SubtreeShouldBeExploredForEvent( + ui::EventTarget* target, + const ui::LocatedEvent& event) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WindowTargeter); +}; + +} // namespace aura diff --git a/ui/aura/window_targeter_unittest.cc b/ui/aura/window_targeter_unittest.cc new file mode 100644 index 0000000..396c805 --- /dev/null +++ b/ui/aura/window_targeter_unittest.cc @@ -0,0 +1,54 @@ +// Copyright (c) 2013 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. + +#include "ui/aura/window_targeter.h" + +#include "ui/aura/test/aura_test_base.h" +#include "ui/aura/test/test_event_handler.h" +#include "ui/aura/test/test_window_delegate.h" +#include "ui/aura/window.h" + +namespace aura { + +class WindowTargeterTest : public test::AuraTestBase { + public: + WindowTargeterTest() {} + virtual ~WindowTargeterTest() {} + + Window* root_window() { return AuraTestBase::root_window(); } +}; + +TEST_F(WindowTargeterTest, Basic) { + test::TestWindowDelegate delegate; + scoped_ptr<Window> window(CreateNormalWindow(1, root_window(), &delegate)); + Window* one = CreateNormalWindow(2, window.get(), &delegate); + Window* two = CreateNormalWindow(3, window.get(), &delegate); + + window->SetBounds(gfx::Rect(0, 0, 100, 100)); + one->SetBounds(gfx::Rect(0, 0, 500, 100)); + two->SetBounds(gfx::Rect(501, 0, 500, 1000)); + + root_window()->Show(); + + test::TestEventHandler handler; + one->AddPreTargetHandler(&handler); + + ui::MouseEvent press(ui::ET_MOUSE_PRESSED, + gfx::Point(20, 20), + gfx::Point(20, 20), + ui::EF_NONE); + root_window()->GetDispatcher()->AsRootWindowHostDelegate()-> + OnHostMouseEvent(&press); + EXPECT_EQ(1, handler.num_mouse_events()); + + handler.Reset(); + ui::EventDispatchDetails details = + root_window()->GetDispatcher()->OnEventFromSource(&press); + EXPECT_FALSE(details.dispatcher_destroyed); + EXPECT_EQ(1, handler.num_mouse_events()); + + one->RemovePreTargetHandler(&handler); +} + +} // namespace aura diff --git a/ui/aura/window_tree_host_delegate.h b/ui/aura/window_tree_host_delegate.h index fc40a1f..ad08039 100644 --- a/ui/aura/window_tree_host_delegate.h +++ b/ui/aura/window_tree_host_delegate.h @@ -15,6 +15,7 @@ class Size; namespace ui { class Event; +class EventProcessor; class KeyEvent; class MouseEvent; class ScrollEvent; @@ -55,6 +56,8 @@ class AURA_EXPORT RootWindowHostDelegate { virtual RootWindow* AsRootWindow() = 0; virtual const RootWindow* AsRootWindow() const = 0; + virtual ui::EventProcessor* GetEventProcessor() = 0; + protected: virtual ~RootWindowHostDelegate() {} }; |