Commit 25073f6c authored by Yuki Awano's avatar Yuki Awano Committed by Commit Bot

Fix coordinate conversions in TouchExplorationController

- Touch event comes with coordinate where its origin is its root window
  host.

  Hardware. Confirm that ChromeVox works well on it, e.g. you can
  activate an element on the screen, etc.

Bug: 887222
Test: Enable spoken feedback on touch controller of Hangout Meet
Change-Id: I6bd6b50f13405c493659ad91f24d35974d5c72ce
Reviewed-on: https://chromium-review.googlesource.com/c/1282688Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Yuki Awano <yawano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600612}
parent 62162751
...@@ -101,14 +101,11 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent( ...@@ -101,14 +101,11 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
if (event.type() == ui::ET_TOUCH_PRESSED) if (event.type() == ui::ET_TOUCH_PRESSED)
seen_press_ = true; seen_press_ = true;
// Touch events come through in screen pixels, but untransformed. This is the // Touch events come through in screen pixels.
// raw coordinate not yet mapped to the root window's coordinate system or the
// screen. Convert it into the root window's coordinate system, in DIP which
// is what the rest of this class expects.
gfx::Point location = touch_event.location(); gfx::Point location = touch_event.location();
gfx::Point root_location = touch_event.root_location(); gfx::Point root_location = touch_event.root_location();
root_window_->GetHost()->ConvertScreenInPixelsToDIP(&location); root_window_->GetHost()->ConvertPixelsToDIP(&location);
root_window_->GetHost()->ConvertScreenInPixelsToDIP(&root_location); root_window_->GetHost()->ConvertPixelsToDIP(&root_location);
if (!exclude_bounds_.IsEmpty()) { if (!exclude_bounds_.IsEmpty()) {
bool in_exclude_area = exclude_bounds_.Contains(location); bool in_exclude_area = exclude_bounds_.Contains(location);
...@@ -473,7 +470,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration( ...@@ -473,7 +470,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration(
// Rewrite as a mouse-move event. // Rewrite as a mouse-move event.
// |event| locations are in DIP; see |RewriteEvent|. We need to dispatch // |event| locations are in DIP; see |RewriteEvent|. We need to dispatch
// |screen coords. // |screen coords.
gfx::PointF location_f(ConvertDIPToScreenInPixels(event.location_f())); gfx::PointF location_f(ConvertDIPToPixels(event.location_f()));
*rewritten_event = CreateMouseMoveEvent(location_f, event.flags()); *rewritten_event = CreateMouseMoveEvent(location_f, event.flags());
last_touch_exploration_ = std::make_unique<ui::TouchEvent>(event); last_touch_exploration_ = std::make_unique<ui::TouchEvent>(event);
if (anchor_point_state_ != ANCHOR_POINT_EXPLICITLY_SET) if (anchor_point_state_ != ANCHOR_POINT_EXPLICITLY_SET)
...@@ -507,7 +504,7 @@ ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( ...@@ -507,7 +504,7 @@ ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough(
// |event| locations are in DIP; see |RewriteEvent|. We need to dispatch // |event| locations are in DIP; see |RewriteEvent|. We need to dispatch
// screen coordinates. // screen coordinates.
gfx::PointF location_f( gfx::PointF location_f(
ConvertDIPToScreenInPixels(event.location_f() - passthrough_offset_)); ConvertDIPToPixels(event.location_f() - passthrough_offset_));
std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent(
event.type(), gfx::Point(), event.time_stamp(), event.pointer_details())); event.type(), gfx::Point(), event.time_stamp(), event.pointer_details()));
new_event->set_location_f(location_f); new_event->set_location_f(location_f);
...@@ -535,7 +532,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( ...@@ -535,7 +532,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress(
// TODO(dmazzoni): fix for multiple displays. http://crbug.com/616793 // TODO(dmazzoni): fix for multiple displays. http://crbug.com/616793
// |event| locations are in DIP; see |RewriteEvent|. We need to dispatch // |event| locations are in DIP; see |RewriteEvent|. We need to dispatch
// screen coordinates. // screen coordinates.
gfx::PointF location_f(ConvertDIPToScreenInPixels(anchor_point_dip_)); gfx::PointF location_f(ConvertDIPToPixels(anchor_point_dip_));
new_event->set_location_f(location_f); new_event->set_location_f(location_f);
new_event->set_root_location_f(location_f); new_event->set_root_location_f(location_f);
new_event->set_flags(event.flags()); new_event->set_flags(event.flags());
...@@ -786,8 +783,7 @@ void TouchExplorationController::DispatchEvent(ui::Event* event) { ...@@ -786,8 +783,7 @@ void TouchExplorationController::DispatchEvent(ui::Event* event) {
SetTouchAccessibilityFlag(event); SetTouchAccessibilityFlag(event);
if (event->IsLocatedEvent()) { if (event->IsLocatedEvent()) {
ui::LocatedEvent* located_event = event->AsLocatedEvent(); ui::LocatedEvent* located_event = event->AsLocatedEvent();
gfx::PointF screen_point( gfx::PointF screen_point(ConvertDIPToPixels(located_event->location_f()));
ConvertDIPToScreenInPixels(located_event->location_f()));
located_event->set_location_f(screen_point); located_event->set_location_f(screen_point);
located_event->set_root_location_f(screen_point); located_event->set_root_location_f(screen_point);
} }
...@@ -1148,10 +1144,10 @@ float TouchExplorationController::GetSplitTapTouchSlop() { ...@@ -1148,10 +1144,10 @@ float TouchExplorationController::GetSplitTapTouchSlop() {
return gesture_detector_config_.touch_slop * 3; return gesture_detector_config_.touch_slop * 3;
} }
gfx::PointF TouchExplorationController::ConvertDIPToScreenInPixels( gfx::PointF TouchExplorationController::ConvertDIPToPixels(
const gfx::PointF& location_f) { const gfx::PointF& location_f) {
gfx::Point location(gfx::ToFlooredPoint(location_f)); gfx::Point location(gfx::ToFlooredPoint(location_f));
root_window_->GetHost()->ConvertDIPToScreenInPixels(&location); root_window_->GetHost()->ConvertDIPToPixels(&location);
return gfx::PointF(location); return gfx::PointF(location);
} }
......
...@@ -327,8 +327,9 @@ class ASH_EXPORT TouchExplorationController ...@@ -327,8 +327,9 @@ class ASH_EXPORT TouchExplorationController
// fingers in place is a bit harder. // fingers in place is a bit harder.
float GetSplitTapTouchSlop(); float GetSplitTapTouchSlop();
// Convert a gfx::PointF from DIP back to raw screen coordinates. // Convert a gfx::PointF from DIP back to raw screen coordinates. Origin is
gfx::PointF ConvertDIPToScreenInPixels(const gfx::PointF& location); // based on its root window host.
gfx::PointF ConvertDIPToPixels(const gfx::PointF& location);
enum State { enum State {
// No fingers are down and no events are pending. // No fingers are down and no events are pending.
...@@ -485,7 +486,7 @@ class ASH_EXPORT TouchExplorationController ...@@ -485,7 +486,7 @@ class ASH_EXPORT TouchExplorationController
// point used when the user double-taps, holds, and drags. This can be // point used when the user double-taps, holds, and drags. This can be
// set either via touch exploration, or by a call to // set either via touch exploration, or by a call to
// SetTouchAccessibilityAnchorPoint when focus moves due to something other // SetTouchAccessibilityAnchorPoint when focus moves due to something other
// than touch exploration. // than touch exploration. Origin of this coordinate is its root window host.
gfx::PointF anchor_point_dip_; gfx::PointF anchor_point_dip_;
// The current state of the anchor point. // The current state of the anchor point.
...@@ -517,6 +518,8 @@ class ASH_EXPORT TouchExplorationController ...@@ -517,6 +518,8 @@ class ASH_EXPORT TouchExplorationController
bool VLOG_on_; bool VLOG_on_;
// LocatedEvents within this area should be left alone. // LocatedEvents within this area should be left alone.
// TODO(crbug.com/616793): Multi display support. With this implementation, we
// cannot specify display.
gfx::Rect exclude_bounds_; gfx::Rect exclude_bounds_;
// Code that detects a touch-screen gesture to enable or disable // Code that detects a touch-screen gesture to enable or disable
...@@ -528,6 +531,8 @@ class ASH_EXPORT TouchExplorationController ...@@ -528,6 +531,8 @@ class ASH_EXPORT TouchExplorationController
// Any touch exploration that both starts and ends (touch pressed, and // Any touch exploration that both starts and ends (touch pressed, and
// released) within this rectangle, triggers a simulated single finger tap at // released) within this rectangle, triggers a simulated single finger tap at
// the anchor point on release. // the anchor point on release.
// TODO(crbug.com/616793): Multi display support. With this implementation, we
// cannot specify display.
gfx::Rect lift_activation_bounds_; gfx::Rect lift_activation_bounds_;
// Whether or not we've seen a touch press event yet. // Whether or not we've seen a touch press event yet.
......
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