Chromium Code Reviews| Index: views/touchui/touch_factory.cc |
| diff --git a/views/touchui/touch_factory.cc b/views/touchui/touch_factory.cc |
| index e644bca965c1e70b998614086f0bb8525d6ff955..d16eeaadba80c1966812b6a6f80281bf1f4d59e8 100644 |
| --- a/views/touchui/touch_factory.cc |
| +++ b/views/touchui/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,46 @@ 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 |
|
Daniel Kurtz
2011/09/26 08:29:17
while (++min_available_slot_ < kMaxTouchPoints &&
ningxin.hu
2011/09/26 15:44:06
Good! I will merge the code. Thanks.
|
| + min_available_slot_++; |
| + while (min_available_slot_ < kMaxTouchPoints) |
| + { |
| + if (!IsSlotUsed(min_available_slot_)) |
| + break; |
| + min_available_slot_++; |
| + } |
| + |
| + 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 +378,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) |