Chromium Code Reviews| Index: ui/chromeos/touch_exploration_controller.cc |
| diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc |
| index 6a7543d41edf6dde30c9359f533a44743adfe51f..4c0ac866c1f94bf7326f4ee25e1baaca06901eb9 100644 |
| --- a/ui/chromeos/touch_exploration_controller.cc |
| +++ b/ui/chromeos/touch_exploration_controller.cc |
| @@ -57,6 +57,10 @@ void TouchExplorationController::SetTouchAccessibilityAnchorPoint( |
| anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET; |
| } |
| +void TouchExplorationController::SetExcludeBounds(const gfx::Rect& bounds) { |
| + exclude_bounds_ = bounds; |
| +} |
| + |
| ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| const ui::Event& event, |
| std::unique_ptr<ui::Event>* rewritten_event) { |
| @@ -72,6 +76,23 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| } |
| const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); |
| + if (!exclude_bounds_.IsEmpty()) { |
| + gfx::Point location = touch_event.location(); |
| + root_window_->GetHost()->ConvertPointFromNativeScreen(&location); |
|
oshima
2016/10/01 01:15:14
This looks wrong. Does this work when you rotate t
erosky
2016/10/03 22:38:41
No target yet here. This conversion is specificall
|
| + bool in_exclude_area = exclude_bounds_.Contains(location); |
| + if (in_exclude_area) { |
| + if (state_ == NO_FINGERS_DOWN) |
| + return ui::EVENT_REWRITE_CONTINUE; |
| + if (touch_event.type() == ui::ET_TOUCH_MOVED || |
| + touch_event.type() == ui::ET_TOUCH_PRESSED) { |
| + return ui::EVENT_REWRITE_DISCARD; |
| + } |
| + // Otherwise, continue handling events. Basically, we want to let |
| + // CANCELLED or RELEASE events through so this can get back to |
| + // the NO_FINGERS_DOWN state. |
| + } |
| + } |
| + |
| // If the tap timer should have fired by now but hasn't, run it now and |
| // stop the timer. This is important so that behavior is consistent with |
| // the timestamps of the events, and not dependent on the granularity of |
| @@ -105,7 +126,8 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| std::vector<int>::iterator it = std::find( |
| current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); |
| - // Can happen if touch exploration is enabled while fingers were down. |
| + // Can happen if touch exploration is enabled while fingers were down |
| + // or if an additional press occurred within the exclusion bounds. |
| if (it == current_touch_ids_.end()) |
| return ui::EVENT_REWRITE_CONTINUE; |