Commit 53aafaa1 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fix a few more conversions in TouchExplorationController

1. a few more places where we need to go from dip back to screen (e.g. when dispatching events as part of pass through).
2. InOneFingerPassThrough was taking the event location and subtracting a |passthrough_offset_|. However, it appears downstream there was a syntax or semantic error as the parens were off. We were subtracting the event location *after* being converted to screen with the pass through offset which is in dips.

Bug: 862830
Change-Id: I2ca08e2e785e23aae980ea1138f8f57876808b34
Reviewed-on: https://chromium-review.googlesource.com/1135656Reviewed-by: default avatarKevin Schoedel <kpschoedel@chromium.org>
Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575082}
parent 84ab6c62
......@@ -593,8 +593,8 @@ ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough(
}
// |event| locations are in DIP; see |RewriteEvent|. We need to dispatch
// screen coordinates.
gfx::PointF location_f(ConvertDIPToScreenInPixels(event.location_f()) -
passthrough_offset_);
gfx::PointF location_f(
ConvertDIPToScreenInPixels(event.location_f() - passthrough_offset_));
std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent(
event.type(), gfx::Point(), event.time_stamp(), event.pointer_details()));
new_event->set_location_f(location_f);
......@@ -701,21 +701,20 @@ void TouchExplorationController::SendSimulatedClickOrTap() {
}
void TouchExplorationController::SendSimulatedTap() {
gfx::PointF screen_point(ConvertDIPToScreenInPixels(anchor_point_dip_));
std::unique_ptr<ui::TouchEvent> touch_press;
touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(),
Now(),
initial_press_->pointer_details()));
touch_press->set_location_f(screen_point);
touch_press->set_root_location_f(screen_point);
touch_press->set_location_f(anchor_point_dip_);
touch_press->set_root_location_f(anchor_point_dip_);
DispatchEvent(touch_press.get());
std::unique_ptr<ui::TouchEvent> touch_release;
touch_release.reset(new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(),
Now(),
initial_press_->pointer_details()));
touch_release->set_location_f(screen_point);
touch_release->set_root_location_f(screen_point);
touch_release->set_location_f(anchor_point_dip_);
touch_release->set_root_location_f(anchor_point_dip_);
DispatchEvent(touch_release.get());
}
......@@ -898,6 +897,13 @@ void TouchExplorationController::OnPassthroughTimerFired() {
void TouchExplorationController::DispatchEvent(ui::Event* event) {
SetTouchAccessibilityFlag(event);
if (event->IsLocatedEvent()) {
ui::LocatedEvent* located_event = event->AsLocatedEvent();
gfx::PointF screen_point(
ConvertDIPToScreenInPixels(located_event->location_f()));
located_event->set_location_f(screen_point);
located_event->set_root_location_f(screen_point);
}
ignore_result(
root_window_->GetHost()->dispatcher()->OnEventFromSource(event));
}
......
......@@ -583,8 +583,8 @@ ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough(
}
// |event| locations are in DIP; see |RewriteEvent|. We need to dispatch
// screen coordinates.
gfx::PointF location_f(ConvertDIPToScreenInPixels(event.location_f()) -
passthrough_offset_);
gfx::PointF location_f(
ConvertDIPToScreenInPixels(event.location_f() - passthrough_offset_));
std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent(
event.type(), gfx::Point(), event.time_stamp(), event.pointer_details()));
new_event->set_location_f(location_f);
......@@ -687,21 +687,20 @@ void TouchExplorationController::SendSimulatedClickOrTap() {
}
void TouchExplorationController::SendSimulatedTap() {
gfx::PointF screen_point(ConvertDIPToScreenInPixels(anchor_point_dip_));
std::unique_ptr<ui::TouchEvent> touch_press;
touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(),
Now(),
initial_press_->pointer_details()));
touch_press->set_location_f(screen_point);
touch_press->set_root_location_f(screen_point);
touch_press->set_location_f(anchor_point_dip_);
touch_press->set_root_location_f(anchor_point_dip_);
DispatchEvent(touch_press.get());
std::unique_ptr<ui::TouchEvent> touch_release;
touch_release.reset(new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(),
Now(),
initial_press_->pointer_details()));
touch_release->set_location_f(screen_point);
touch_release->set_root_location_f(screen_point);
touch_release->set_location_f(anchor_point_dip_);
touch_release->set_root_location_f(anchor_point_dip_);
DispatchEvent(touch_release.get());
}
......@@ -857,6 +856,13 @@ void TouchExplorationController::OnPassthroughTimerFired() {
void TouchExplorationController::DispatchEvent(ui::Event* event) {
SetTouchAccessibilityFlag(event);
if (event->IsLocatedEvent()) {
ui::LocatedEvent* located_event = event->AsLocatedEvent();
gfx::PointF screen_point(
ConvertDIPToScreenInPixels(located_event->location_f()));
located_event->set_location_f(screen_point);
located_event->set_root_location_f(screen_point);
}
ignore_result(
root_window_->GetHost()->dispatcher()->OnEventFromSource(event));
}
......
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