| Index: views/events/event_x.cc
|
| diff --git a/views/events/event_x.cc b/views/events/event_x.cc
|
| index fda4affb3038f172432e0f45dd3c2641d69a66f7..e74d475111215d2db654a8e6f52d234ff0947571 100644
|
| --- a/views/events/event_x.cc
|
| +++ b/views/events/event_x.cc
|
| @@ -122,18 +122,21 @@ ui::EventType GetTouchEventType(XEvent* xev) {
|
| }
|
|
|
| int GetTouchIDFromXEvent(XEvent* xev) {
|
| - float id = 0;
|
| + float slot = 0;
|
| + TouchFactory* factory = TouchFactory::GetInstance();
|
| #if defined(USE_XI2_MT)
|
| - // TODO(ningxin.hu@gmail.com): Make the id always start from 0 for a new
|
| - // touch-sequence when TRACKING_ID is used to extract the touch id.
|
| - TouchFactory::TouchParam tp = TouchFactory::TP_TRACKING_ID;
|
| + float tracking_id;
|
| + if (!factory->ExtractTouchParam(
|
| + *xev, TouchFactory::TP_TRACKING_ID, &tracking_id))
|
| + LOG(ERROR) << "Could not get the slot ID for the event. Using 0.";
|
| + else
|
| + slot = factory->GetSlotForTrackingID(tracking_id);
|
| #else
|
| - TouchFactory::TouchParam tp = TouchFactory::TP_SLOT_ID;
|
| + if (!factory->ExtractTouchParam(
|
| + *xev, TouchFactory::TP_SLOT_ID, &slot))
|
| + LOG(ERROR) << "Could not get the slot ID for the event. Using 0.";
|
| #endif
|
| - if (!TouchFactory::GetInstance()->ExtractTouchParam(
|
| - *xev, tp, &id))
|
| - LOG(ERROR) << "Could not get the touch ID for the event. Using 0.";
|
| - return id;
|
| + return slot;
|
| }
|
|
|
| ui::EventType EventTypeFromNative(NativeEvent2 native_event) {
|
| @@ -424,7 +427,20 @@ TouchEvent::TouchEvent(NativeEvent2 native_event_2,
|
| TouchFactory::TP_ORIENTATION,
|
| 0.0)),
|
| force_(GetTouchForceFromXEvent(native_event_2)) {
|
| -#if !defined(USE_XI2_MT)
|
| +#if defined(USE_XI2_MT)
|
| + if (type() == ui::ET_TOUCH_RELEASED) {
|
| + // NOTE: The slot is allocated by TouchFactory for each XI_TouchBegin
|
| + // event, which carries a new tracking ID to identify a new touch
|
| + // sequence.
|
| + TouchFactory* factory = TouchFactory::GetInstance();
|
| + float tracking_id;
|
| + if (factory->ExtractTouchParam(*native_event_2,
|
| + TouchFactory::TP_TRACKING_ID,
|
| + &tracking_id)) {
|
| + factory->ReleaseSlotForTrackingID(tracking_id);
|
| + }
|
| + }
|
| +#else
|
| if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) {
|
| TouchFactory* factory = TouchFactory::GetInstance();
|
| float slot;
|
|
|