Index: ui/aura/window_event_dispatcher.cc |
diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc |
index 6cd3c43e2dad9addd866098702afd9b64af79343..9dfb2e6238b0104f6bcf017559b8987e24d5cebf 100644 |
--- a/ui/aura/window_event_dispatcher.cc |
+++ b/ui/aura/window_event_dispatcher.cc |
@@ -27,6 +27,7 @@ |
#include "ui/base/hit_test.h" |
#include "ui/compositor/dip_util.h" |
#include "ui/events/event.h" |
+#include "ui/events/event_targeter.h" |
#include "ui/events/event_utils.h" |
#include "ui/events/gestures/gesture_recognizer.h" |
#include "ui/events/gestures/gesture_types.h" |
@@ -80,8 +81,10 @@ WindowEventDispatcher::WindowEventDispatcher(WindowTreeHost* host) |
held_event_factory_(this) { |
ui::GestureRecognizer::Get()->AddGestureEventHelper(this); |
Env::GetInstance()->AddObserver(this); |
- if (Env::GetInstance()->mode() == Env::Mode::MUS) |
+ if (Env::GetInstance()->mode() == Env::Mode::MUS) { |
mus_mouse_location_updater_ = base::MakeUnique<MusMouseLocationUpdater>(); |
+ event_targeter_ = base::MakeUnique<WindowTargeter>(); |
+ } |
} |
WindowEventDispatcher::~WindowEventDispatcher() { |
@@ -416,8 +419,40 @@ void WindowEventDispatcher::ReleaseNativeCapture() { |
//////////////////////////////////////////////////////////////////////////////// |
// WindowEventDispatcher, ui::EventProcessor implementation: |
-ui::EventTarget* WindowEventDispatcher::GetRootTarget() { |
- return window(); |
+ui::EventTarget* WindowEventDispatcher::GetRootForEvent(ui::Event* event) { |
+ if (Env::GetInstance()->mode() == Env::Mode::LOCAL) |
+ return window(); |
+ |
+ if (!event->target()) |
+ return window(); |
+ |
+ ui::EventTarget* target = event->target(); |
+ ui::EventTarget* ancestor_with_targeter = target; |
+ for (ui::EventTarget* ancestor = target->GetParentTarget(); ancestor; |
+ ancestor = ancestor->GetParentTarget()) { |
+ if (ancestor->GetEventTargeter()) |
+ ancestor_with_targeter = ancestor; |
+ if (ancestor == window()) |
+ break; |
+ } |
+ |
+ if (ancestor_with_targeter != target && event->IsLocatedEvent()) { |
+ gfx::Point location = event->AsLocatedEvent()->location(); |
+ gfx::Point root_location = event->AsLocatedEvent()->root_location(); |
+ Window::ConvertPointToTarget(static_cast<Window*>(target), |
+ static_cast<Window*>(ancestor_with_targeter), |
+ &location); |
+ Window::ConvertPointToTarget(static_cast<Window*>(target), |
+ static_cast<Window*>(ancestor_with_targeter), |
+ &root_location); |
+ event->AsLocatedEvent()->set_location(location); |
+ event->AsLocatedEvent()->set_root_location(root_location); |
+ } |
+ return ancestor_with_targeter; |
+} |
+ |
+ui::EventTargeter* WindowEventDispatcher::GetDefaultEventTargeter() { |
+ return event_targeter_.get(); |
} |
void WindowEventDispatcher::OnEventProcessingStarted(ui::Event* event) { |