Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Unified Diff: ui/base/touch/touch_factory.cc

Issue 7927001: touchui: Convert XI2 MT tracking id to slot id for gesture recognizer (Closed) Base URL: nhu@powerbuilder.sh.intel.com:/home/www-data/git-repos/chromium/chromium.git@trunk
Patch Set: rebase to trunk Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/touch/touch_factory.h ('k') | views/events/event_x.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « ui/base/touch/touch_factory.h ('k') | views/events/event_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698