Index: ui/base/touch/touch_factory.cc |
diff --git a/ui/base/touch/touch_factory.cc b/ui/base/touch/touch_factory.cc |
index c4f72b1fbcc3310a9e02977cfec6e6b773195621..d71b3f9101c7a5ce61f5d245b9566ef2620121b2 100644 |
--- a/ui/base/touch/touch_factory.cc |
+++ b/ui/base/touch/touch_factory.cc |
@@ -134,10 +134,12 @@ TouchFactory::TouchFactory() |
keep_mouse_cursor_(false), |
cursor_timer_(), |
pointer_device_lookup_(), |
+ touch_device_list_(), |
#if defined(USE_XI2_MT) |
- touch_device_list_() { |
+ min_available_slot_(0), |
+ slots_used_(), |
+ tracking_id_map_() { |
#else |
- touch_device_list_(), |
slots_used_() { |
#endif |
#if defined(TOUCH_UI) |
@@ -327,7 +329,42 @@ bool TouchFactory::IsTouchDevice(unsigned deviceid) const { |
touch_device_lookup_[deviceid] : false; |
} |
-#if !defined(USE_XI2_MT) |
+#if defined(USE_XI2_MT) |
+int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) { |
+ TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id); |
+ if (itr != tracking_id_map_.end()) |
+ return itr->second; |
+ |
+ int slot = min_available_slot_; |
+ if (slot == kMaxTouchPoints) { |
+ LOG(ERROR) << "Could not find available slot for touch point"; |
+ return 0; |
+ } |
+ SetSlotUsed(slot, true); |
+ tracking_id_map_.insert(std::make_pair(tracking_id, slot)); |
+ |
+ // Updates the minium available slot ID |
+ while (++min_available_slot_ < kMaxTouchPoints && |
+ IsSlotUsed(min_available_slot_)) |
+ continue; |
+ |
+ return slot; |
+} |
+ |
+void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) { |
+ TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id); |
+ if (itr != tracking_id_map_.end()) { |
+ int slot = itr->second; |
+ SetSlotUsed(slot, false); |
+ tracking_id_map_.erase(itr); |
+ if (slot < min_available_slot_) |
+ min_available_slot_ = slot; |
+ } else { |
+ NOTREACHED() << "Cannot find slot mapping to tracking ID " << tracking_id; |
+ } |
+} |
+#endif |
+ |
bool TouchFactory::IsSlotUsed(int slot) const { |
CHECK_LT(slot, kMaxTouchPoints); |
return slots_used_[slot]; |
@@ -337,7 +374,6 @@ void TouchFactory::SetSlotUsed(int slot, bool used) { |
CHECK_LT(slot, kMaxTouchPoints); |
slots_used_[slot] = used; |
} |
-#endif |
bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) { |
#if defined(TOUCH_UI) |