Index: ui/aura/mus/window_tree_client.cc |
diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc |
index 6609d5390926a9659bd315cbf384311c78ab7ec9..90573b1a8b3865925cb9790e1e4f175a1a9f288f 100644 |
--- a/ui/aura/mus/window_tree_client.cc |
+++ b/ui/aura/mus/window_tree_client.cc |
@@ -278,8 +278,9 @@ void WindowTreeClient::ConnectViaWindowTreeFactory() { |
SetWindowTree(std::move(window_tree)); |
} |
-void WindowTreeClient::ConnectAsWindowManager() { |
+void WindowTreeClient::ConnectAsWindowManager(bool dispatch_from_host) { |
DCHECK(window_manager_delegate_); |
+ dispatch_from_host_ = dispatch_from_host; |
ui::mojom::WindowManagerWindowTreeFactoryPtr factory; |
connector_->BindInterface(ui::mojom::kServiceName, &factory); |
@@ -1252,7 +1253,16 @@ void WindowTreeClient::OnWindowInputEvent(uint32_t event_id, |
// TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or |
// ui::TouchEvent once we have proper support for pointer events. |
std::unique_ptr<ui::Event> mapped_event = MapEvent(*event.get()); |
- DispatchEventToTarget(mapped_event.get(), window); |
+ if (dispatch_from_host_ && mapped_event->IsLocatedEvent()) { |
+ gfx::Point host_location = mapped_event->AsLocatedEvent()->location(); |
+ aura::Window::ConvertPointToTarget(window->GetWindow(), |
+ window->GetWindow()->GetHost()->window(), |
+ &host_location); |
+ mapped_event->AsLocatedEvent()->set_location(host_location); |
+ GetWindowTreeHostMus(window)->SendEventToSink(mapped_event.get()); |
+ } else { |
+ DispatchEventToTarget(mapped_event.get(), window); |
+ } |
ack_handler.set_handled(mapped_event->handled()); |
} |