Index: views/touchui/touch_factory.cc |
diff --git a/views/touchui/touch_factory.cc b/views/touchui/touch_factory.cc |
index 09eb704196bd382d2e4911538ba868ca272e3606..30f6c59e1324c7d6681410a1bf4c1606bd35ae8a 100644 |
--- a/views/touchui/touch_factory.cc |
+++ b/views/touchui/touch_factory.cc |
@@ -129,10 +129,11 @@ TouchFactory::TouchFactory() |
keep_mouse_cursor_(false), |
cursor_timer_(), |
pointer_device_lookup_(), |
+ touch_device_list_(), |
#if defined(USE_XI2_MT) |
- touch_device_list_() { |
+ slots_used_(), |
+ tracking_id_map_() { |
#else |
- touch_device_list_(), |
slots_used_() { |
#endif |
#if defined(TOUCH_UI) |
@@ -319,7 +320,39 @@ 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; |
+ |
+ // Finds the lowest available slot and sets up the mapping. |
+ int slot = 0; |
Daniel Kurtz
2011/09/24 01:53:36
If you store minSlotAvailable as a member variable
sadrul
2011/09/24 03:06:31
This sounds like a good proposal; although I don't
ningxin.hu
2011/09/25 16:35:39
Good idea! I will follow up the solution. Thanks.
|
+ while (slot < kMaxTouchPoints) { |
+ if (!IsSlotUsed(slot)) |
+ break; |
+ 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)); |
+ return slot; |
+} |
+ |
+void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) { |
+ TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id); |
+ if (itr != tracking_id_map_.end()) { |
+ SetSlotUsed(itr->second, false); |
+ tracking_id_map_.erase(itr); |
+ } 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]; |
@@ -329,7 +362,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) |