Commit 1423331f authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

mus: Fix event processing for touch events in unified mode

This refines my earlier work done in: http://crrev.com/c/842467

Move event target nulling and root location use to WindowTreeClient, to ensure events reach MusUnifiedEventTargeter.
Otherwise, WindowEventDispatcher::GetInitialEventTarget will use the touch gesture recognizer's target (returned by GetPriorityTargetInRootWindow) before performing the mirror display transformation on the event's location.

Inline DispatchEventToTarget for additional clarity.

Bug: 805714
Test: Mus touch events work in Chrome OS's unified desktop mode.
Change-Id: Ic4844c85cc24a9f9885e7705ff27cb57b305d245
Reviewed-on: https://chromium-review.googlesource.com/887250
Commit-Queue: Michael Wasserman <msw@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532030}
parent c50b0d29
...@@ -31,20 +31,9 @@ class MusUnifiedEventTargeter : public aura::WindowTargeter { ...@@ -31,20 +31,9 @@ class MusUnifiedEventTargeter : public aura::WindowTargeter {
ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
ui::Event* event) override { ui::Event* event) override {
if (root == src_root_) { if (root == src_root_ && !event->target()) {
delegate_->SetCurrentEventTargeterSourceHost(src_root_->GetHost()); delegate_->SetCurrentEventTargeterSourceHost(src_root_->GetHost());
if (event->IsLocatedEvent()) {
// Mus uses the event's root location (relative to the physical display)
// to find the target window's local coordinates, but it incorrectly
// assumes that the root location is relative to the unified display.
// Pass the root location (now relative to the unified display) into the
// event dispatch pipeline, that finds local coordinates for the target.
ui::LocatedEvent* located_event = static_cast<ui::LocatedEvent*>(event);
located_event->set_location_f(located_event->root_location_f());
}
if (event->target())
ui::Event::DispatcherApi(event).set_target(nullptr);
ignore_result( ignore_result(
dst_root_->GetHost()->event_sink()->OnEventFromSource(event)); dst_root_->GetHost()->event_sink()->OnEventFromSource(event));
......
...@@ -166,17 +166,6 @@ std::unique_ptr<ui::Event> MapEvent(const ui::Event& event) { ...@@ -166,17 +166,6 @@ std::unique_ptr<ui::Event> MapEvent(const ui::Event& event) {
return ui::Event::Clone(event); return ui::Event::Clone(event);
} }
// Set the |target| to be the target window of this |event| and send it to
// the EventSink.
void DispatchEventToTarget(ui::Event* event, WindowMus* target) {
ui::Event::DispatcherApi dispatch_helper(event);
// Ignore the target for key events. They need to go to the focused window,
// which may have changed by the time we process the event.
if (!event->IsKeyEvent())
dispatch_helper.set_target(target->GetWindow());
GetWindowTreeHostMus(target)->SendEventToSink(event);
}
// Use for acks from mus that are expected to always succeed and if they don't // Use for acks from mus that are expected to always succeed and if they don't
// a crash is triggered. // a crash is triggered.
void OnAckMustSucceed(const base::Location& from_here, bool success) { void OnAckMustSucceed(const base::Location& from_here, bool success) {
...@@ -1483,7 +1472,6 @@ void WindowTreeClient::OnWindowInputEvent( ...@@ -1483,7 +1472,6 @@ void WindowTreeClient::OnWindowInputEvent(
std::unique_ptr<ui::Event> event, std::unique_ptr<ui::Event> event,
bool matches_pointer_watcher) { bool matches_pointer_watcher) {
DCHECK(event); DCHECK(event);
WindowMus* window = GetWindowByServerId(window_id); // May be null. WindowMus* window = GetWindowByServerId(window_id); // May be null.
if (matches_pointer_watcher && has_pointer_watcher_) { if (matches_pointer_watcher && has_pointer_watcher_) {
...@@ -1549,17 +1537,24 @@ void WindowTreeClient::OnWindowInputEvent( ...@@ -1549,17 +1537,24 @@ void WindowTreeClient::OnWindowInputEvent(
#endif #endif
WindowMus* display_root_window = GetWindowByServerId(display_root_window_id); WindowMus* display_root_window = GetWindowByServerId(display_root_window_id);
if (display_root_window && window && event->IsLocatedEvent() && if (display_root_window && event->IsLocatedEvent() &&
display::Screen::GetScreen()->GetPrimaryDisplay().id() == display::Screen::GetScreen()->GetPrimaryDisplay().id() ==
display::kUnifiedDisplayId) { display::kUnifiedDisplayId) {
// Dispatch to the root window of the display supplying the event. This // In Ash's unified desktop mode, each physical display mirrors part of a
// allows Ash to determine the event position in the unified desktop mode, // single virtual display. Dispatch events to the root window of the mirror
// where each physical display mirrors part of a single virtual display. // display supplying the event, using locations relative to that display.
// This paralells the behavior of unified desktop mode in classic Ash mode. // Use a null target to ensure events reach the MusUnifiedEventTargeter.
DispatchEventToTarget(event_to_dispatch, display_root_window); // This paralells the behavior of unified desktop mode in classic Ash.
} else { ui::Event::DispatcherApi(event_to_dispatch).set_target(nullptr);
DispatchEventToTarget(event_to_dispatch, window); ui::LocatedEvent* located_event = event_to_dispatch->AsLocatedEvent();
} located_event->set_location_f(located_event->root_location_f());
window = display_root_window;
} else if (!event->IsKeyEvent()) {
// Set |window| as the target, except for key events. Key events go to the
// focused window, which may have changed by the time we process the event.
ui::Event::DispatcherApi(event_to_dispatch).set_target(window->GetWindow());
}
GetWindowTreeHostMus(window)->SendEventToSink(event_to_dispatch);
ack_handler.set_handled(event_to_dispatch->handled()); ack_handler.set_handled(event_to_dispatch->handled());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment