Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: ui/events/gesture_detection/gesture_provider.cc

Issue 212663010: Store the id of a contributing motion event in GestureEventData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Store motion_event_id, not touch_id. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/gesture_detection/gesture_provider.cc
diff --git a/ui/events/gesture_detection/gesture_provider.cc b/ui/events/gesture_detection/gesture_provider.cc
index 4deeba2580f3a7a72928cd3cec30f4a401aa2f18..56232582ad9bf0f32547f1ca00f7b3632793171c 100644
--- a/ui/events/gesture_detection/gesture_provider.cc
+++ b/ui/events/gesture_detection/gesture_provider.cc
@@ -31,30 +31,40 @@ const char* GetMotionEventActionName(MotionEvent::Action action) {
}
GestureEventData CreateGesture(EventType type,
+ int motion_event_id,
base::TimeTicks time,
float x,
float y,
const GestureEventDetails& details) {
- return GestureEventData(type, time, x, y, details);
+ return GestureEventData(type, motion_event_id, time, x, y, details);
}
GestureEventData CreateGesture(EventType type,
+ int motion_event_id,
base::TimeTicks time,
float x,
float y) {
- return GestureEventData(type, time, x, y);
- }
+ return GestureEventData(type, motion_event_id, time, x, y);
+}
GestureEventData CreateGesture(EventType type,
const MotionEvent& event,
const GestureEventDetails& details) {
- return CreateGesture(
- type, event.GetEventTime(), event.GetX(), event.GetY(), details);
+ return GestureEventData(type,
+ event.GetId(),
+ event.GetEventTime(),
+ event.GetX(),
+ event.GetY(),
+ details);
}
GestureEventData CreateGesture(EventType type,
const MotionEvent& event) {
- return CreateGesture(type, event.GetEventTime(), event.GetX(), event.GetY());
+ return CreateGesture(type,
+ event.GetId(),
+ event.GetEventTime(),
+ event.GetX(),
+ event.GetY());
}
float Round(float f) {
@@ -105,27 +115,34 @@ class GestureProvider::ScaleGestureListenerImpl
}
// ScaleGestureDetector::ScaleGestureListener implementation.
- virtual bool OnScaleBegin(const ScaleGestureDetector& detector) OVERRIDE {
+ virtual bool OnScaleBegin(const ScaleGestureDetector& detector,
+ const MotionEvent& e) OVERRIDE {
if (ignore_detector_events_)
return false;
pinch_event_sent_ = false;
return true;
}
- virtual void OnScaleEnd(const ScaleGestureDetector& detector) OVERRIDE {
+ virtual void OnScaleEnd(const ScaleGestureDetector& detector,
+ const MotionEvent& e) OVERRIDE {
if (!pinch_event_sent_)
return;
- provider_->Send(
- CreateGesture(ET_GESTURE_PINCH_END, detector.GetEventTime(), 0, 0));
+ provider_->Send(CreateGesture(ET_GESTURE_PINCH_END,
+ e.GetId(),
+ detector.GetEventTime(),
+ 0,
+ 0));
pinch_event_sent_ = false;
}
- virtual bool OnScale(const ScaleGestureDetector& detector) OVERRIDE {
+ virtual bool OnScale(const ScaleGestureDetector& detector,
+ const MotionEvent& e) OVERRIDE {
if (ignore_detector_events_)
return false;
if (!pinch_event_sent_) {
pinch_event_sent_ = true;
provider_->Send(CreateGesture(ET_GESTURE_PINCH_BEGIN,
+ e.GetId(),
detector.GetEventTime(),
detector.GetFocusX(),
detector.GetFocusY()));
@@ -133,6 +150,7 @@ class GestureProvider::ScaleGestureListenerImpl
GestureEventDetails pinch_details(
ET_GESTURE_PINCH_UPDATE, detector.GetScaleFactor(), 0);
provider_->Send(CreateGesture(ET_GESTURE_PINCH_UPDATE,
+ e.GetId(),
detector.GetEventTime(),
detector.GetFocusX(),
detector.GetFocusY(),
@@ -275,6 +293,7 @@ class GestureProvider::GestureListenerImpl
GestureEventDetails scroll_details(
ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y);
provider_->Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN,
+ e1.GetId(),
jdduke (slow) 2014/04/02 18:33:12 Hmm... e1 is the ACTION_DOWN, don't we want the id
tdresser 2014/04/03 14:01:23 There were a couple other similar issues - my init
e2.GetEventTime(),
e1.GetX(),
e1.GetY(),
@@ -314,8 +333,12 @@ class GestureProvider::GestureListenerImpl
}
}
- provider_->Fling(
- e2.GetEventTime(), e1.GetX(), e1.GetY(), velocity_x, velocity_y);
+ provider_->Fling(e2.GetEventTime(),
+ e1.GetId(),
jdduke (slow) 2014/04/02 18:33:12 Hmm, I think we want e2.getId() on the fling (the
tdresser 2014/04/03 14:01:23 Done.
+ e1.GetX(),
+ e1.GetY(),
+ velocity_x,
+ velocity_y);
return true;
}
@@ -403,10 +426,11 @@ class GestureProvider::GestureListenerImpl
if (IsDistanceGreaterThanTouchSlop(distance_x, distance_y)) {
GestureEventDetails scroll_details(
ET_GESTURE_SCROLL_BEGIN, -distance_x, -distance_y);
- provider_->Send(
- CreateGesture(ET_GESTURE_SCROLL_BEGIN, e, scroll_details));
+ provider_->Send(CreateGesture(
+ ET_GESTURE_SCROLL_BEGIN, e, scroll_details));
provider_->Send(
CreateGesture(ET_GESTURE_PINCH_BEGIN,
+ e.GetId(),
e.GetEventTime(),
Round(double_tap_drag_zoom_anchor_x_),
Round(double_tap_drag_zoom_anchor_y_)));
@@ -421,6 +445,7 @@ class GestureProvider::GestureListenerImpl
std::abs(dy * px_to_dp_));
GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE, scale, 0);
provider_->Send(CreateGesture(ET_GESTURE_PINCH_UPDATE,
+ e.GetId(),
e.GetEventTime(),
Round(double_tap_drag_zoom_anchor_x_),
Round(double_tap_drag_zoom_anchor_y_),
@@ -637,7 +662,7 @@ bool GestureProvider::OnTouchEvent(const MotionEvent& event) {
// "Last finger raised" could be an end to movement, but it should
// only terminate scrolling if the event did not cause a fling.
if (was_touch_scrolling_ && !handled)
- EndTouchScrollIfNecessary(event.GetEventTime(), true);
+ EndTouchScrollIfNecessary(event.GetEventTime(), event.GetId(), true);
// We shouldn't necessarily cancel a tap on ACTION_UP, as the double-tap
// timeout may yet trigger a SINGLE_TAP.
@@ -703,12 +728,13 @@ bool GestureProvider::CanHandle(const MotionEvent& event) const {
}
void GestureProvider::Fling(base::TimeTicks time,
+ int motion_event_id,
float x,
float y,
float velocity_x,
float velocity_y) {
if (!velocity_x && !velocity_y) {
- EndTouchScrollIfNecessary(time, true);
+ EndTouchScrollIfNecessary(time, motion_event_id, true);
return;
}
@@ -719,13 +745,15 @@ void GestureProvider::Fling(base::TimeTicks time,
// start hint.
GestureEventDetails scroll_details(
ET_GESTURE_SCROLL_BEGIN, velocity_x, velocity_y);
- Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN, time, x, y, scroll_details));
+ Send(CreateGesture(
+ ET_GESTURE_SCROLL_BEGIN, motion_event_id, time, x, y, scroll_details));
}
- EndTouchScrollIfNecessary(time, false);
+ EndTouchScrollIfNecessary(time, motion_event_id, false);
GestureEventDetails fling_details(
ET_SCROLL_FLING_START, velocity_x, velocity_y);
- Send(CreateGesture(ET_SCROLL_FLING_START, time, x, y, fling_details));
+ Send(CreateGesture(
+ ET_SCROLL_FLING_START, motion_event_id, time, x, y, fling_details));
}
void GestureProvider::Send(const GestureEventData& gesture) {
@@ -745,8 +773,11 @@ void GestureProvider::Send(const GestureEventData& gesture) {
break;
case ET_GESTURE_TAP:
if (needs_show_press_event_)
- Send(CreateGesture(
- ET_GESTURE_SHOW_PRESS, gesture.time, gesture.x, gesture.y));
+ Send(CreateGesture(ET_GESTURE_SHOW_PRESS,
+ gesture.motion_event_id,
+ gesture.time,
+ gesture.x,
+ gesture.y));
needs_tap_ending_event_ = false;
break;
case ET_GESTURE_DOUBLE_TAP:
@@ -810,12 +841,13 @@ bool GestureProvider::SendLongTapIfNecessary(const MotionEvent& event) {
}
void GestureProvider::EndTouchScrollIfNecessary(base::TimeTicks time,
+ int motion_event_id,
bool send_scroll_end_event) {
if (!touch_scroll_in_progress_)
return;
touch_scroll_in_progress_ = false;
if (send_scroll_end_event)
- Send(CreateGesture(ET_GESTURE_SCROLL_END, time, 0, 0));
+ Send(CreateGesture(ET_GESTURE_SCROLL_END, motion_event_id, time, 0, 0));
}
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698