Index: ui/events/gesture_detection/gesture_detector.cc |
diff --git a/ui/events/gesture_detection/gesture_detector.cc b/ui/events/gesture_detection/gesture_detector.cc |
index 5dc61938b1ae4fff85ff6d8f30a836dd74075f96..dc8847d2a76c87a9cf109d6d49567d67f01ebdbe 100644 |
--- a/ui/events/gesture_detection/gesture_detector.cc |
+++ b/ui/events/gesture_detection/gesture_detector.cc |
@@ -61,11 +61,14 @@ bool GestureDetector::SimpleGestureListener::OnDown(const MotionEvent& e) { |
return false; |
} |
-void GestureDetector::SimpleGestureListener::OnShowPress(const MotionEvent& e) { |
+void GestureDetector::SimpleGestureListener::OnShowPress(const MotionEvent& e, |
+ float max_radius) { |
} |
-bool GestureDetector::SimpleGestureListener::OnSingleTapUp( |
- const MotionEvent& e) { |
+bool GestureDetector::SimpleGestureListener::OnSingleTapUp(const MotionEvent& e, |
+ float x, |
+ float y, |
+ float max_radius) { |
return false; |
} |
@@ -100,7 +103,10 @@ bool GestureDetector::SimpleGestureListener::OnTwoFingerTap( |
} |
bool GestureDetector::SimpleGestureListener::OnSingleTapConfirmed( |
- const MotionEvent& e) { |
+ const MotionEvent& e, |
+ float x, |
+ float y, |
+ float max_touch_diameter_) { |
return false; |
} |
@@ -197,7 +203,6 @@ GestureDetector::~GestureDetector() {} |
bool GestureDetector::OnTouchEvent(const MotionEvent& ev) { |
const MotionEvent::Action action = ev.GetAction(); |
- |
velocity_tracker_.AddMovement(ev); |
const bool pointer_up = action == MotionEvent::ACTION_POINTER_UP; |
@@ -313,6 +318,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) { |
defer_confirm_single_tap_ = false; |
two_finger_tap_allowed_for_gesture_ = two_finger_tap_enabled_; |
+ max_touch_diameter_ = ev.GetTouchMajor(); |
// Always start the SHOW_PRESS timer before the LONG_PRESS timer to ensure |
// proper timeout ordering. |
timeout_handler_->StartTimeout(SHOW_PRESS); |
@@ -351,6 +357,11 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) { |
last_focus_y_ = focus_y; |
} |
+ if (timeout_handler_->HasTimeout(SHOW_PRESS)) { |
+ max_touch_diameter_ = |
+ std::max(max_touch_diameter_, ev.GetTouchMajor()); |
+ } |
+ |
if (!two_finger_tap_allowed_for_gesture_) |
break; |
@@ -375,6 +386,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) { |
if (dx * dx + dy * dy > touch_slop_square_) |
two_finger_tap_allowed_for_gesture_ = false; |
} |
+ |
} |
break; |
@@ -386,9 +398,16 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) { |
DCHECK(double_tap_listener_); |
handled |= double_tap_listener_->OnDoubleTapEvent(ev); |
} else if (always_in_tap_region_) { |
- handled = listener_->OnSingleTapUp(ev); |
+ handled = listener_->OnSingleTapUp(ev, |
+ current_down_event_->GetX(), |
+ current_down_event_->GetY(), |
+ max_touch_diameter_); |
if (defer_confirm_single_tap_ && double_tap_listener_ != NULL) { |
- double_tap_listener_->OnSingleTapConfirmed(ev); |
+ double_tap_listener_->OnSingleTapConfirmed( |
+ ev, |
+ current_down_event_->GetX(), |
+ current_down_event_->GetY(), |
+ max_touch_diameter_); |
} |
} else { |
@@ -474,7 +493,7 @@ void GestureDetector::Init(const Config& config) { |
} |
void GestureDetector::OnShowPressTimeout() { |
- listener_->OnShowPress(*current_down_event_); |
+ listener_->OnShowPress(*current_down_event_, max_touch_diameter_); |
} |
void GestureDetector::OnLongPressTimeout() { |
@@ -487,7 +506,10 @@ void GestureDetector::OnTapTimeout() { |
if (!double_tap_listener_) |
return; |
if (!still_down_) |
- double_tap_listener_->OnSingleTapConfirmed(*current_down_event_); |
+ double_tap_listener_->OnSingleTapConfirmed(*current_down_event_, |
+ current_down_event_->GetX(), |
+ current_down_event_->GetY(), |
+ max_touch_diameter_); |
else |
defer_confirm_single_tap_ = true; |
} |