Index: views/events/event_x.cc |
diff --git a/views/events/event_x.cc b/views/events/event_x.cc |
index 9957d5f00941bea07e04e6147881e9bd13df8625..86995fe7bf03462fee134e194f031fd5e0903e79 100644 |
--- a/views/events/event_x.cc |
+++ b/views/events/event_x.cc |
@@ -20,17 +20,21 @@ namespace views { |
namespace { |
int GetTouchIDFromXEvent(XEvent* xev) { |
- float id = 0; |
+ float slot = 0; |
+ ui::TouchFactory* factory = ui::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. |
- ui::TouchFactory::TouchParam tp = ui::TouchFactory::TP_TRACKING_ID; |
+ float tracking_id; |
+ if (!factory->ExtractTouchParam( |
+ *xev, ui::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 |
- ui::TouchFactory::TouchParam tp = ui::TouchFactory::TP_SLOT_ID; |
+ if (!factory->ExtractTouchParam( |
+ *xev, ui::TouchFactory::TP_SLOT_ID, &slot)) |
+ LOG(ERROR) << "Could not get the slot ID for the event. Using 0."; |
#endif |
- if (!ui::TouchFactory::GetInstance()->ExtractTouchParam(*xev, tp, &id)) |
- LOG(ERROR) << "Could not get the touch ID for the event. Using 0."; |
- return id; |
+ return slot; |
} |
uint16 GetCharacterFromXKeyEvent(XKeyEvent* key) { |
@@ -171,7 +175,20 @@ TouchEvent::TouchEvent(const ui::NativeEvent& native_event) |
ui::TouchFactory::TP_ORIENTATION, |
0.0)), |
force_(GetTouchForceFromXEvent(native_event)) { |
-#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. |
+ ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
+ float tracking_id; |
+ if (factory->ExtractTouchParam(*native_event, |
+ ui::TouchFactory::TP_TRACKING_ID, |
+ &tracking_id)) { |
+ factory->ReleaseSlotForTrackingID(tracking_id); |
+ } |
+ } |
+#else |
if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) { |
ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
float slot; |