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

Side by Side Diff: views/touchui/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: Fix some typos. Created 9 years, 2 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 unified diff | Download patch
« no previous file with comments | « views/touchui/touch_factory.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/touchui/touch_factory.h" 5 #include "views/touchui/touch_factory.h"
6 6
7 #if defined(TOOLKIT_USES_GTK) 7 #if defined(TOOLKIT_USES_GTK)
8 // TODO(sad) Remove all TOOLKIT_USES_GTK uses once we move to aura only. 8 // TODO(sad) Remove all TOOLKIT_USES_GTK uses once we move to aura only.
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 #include <gdk/gdkx.h> 10 #include <gdk/gdkx.h>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // static 127 // static
128 TouchFactory* TouchFactory::GetInstance() { 128 TouchFactory* TouchFactory::GetInstance() {
129 return Singleton<TouchFactory>::get(); 129 return Singleton<TouchFactory>::get();
130 } 130 }
131 131
132 TouchFactory::TouchFactory() 132 TouchFactory::TouchFactory()
133 : is_cursor_visible_(true), 133 : is_cursor_visible_(true),
134 keep_mouse_cursor_(false), 134 keep_mouse_cursor_(false),
135 cursor_timer_(), 135 cursor_timer_(),
136 pointer_device_lookup_(), 136 pointer_device_lookup_(),
137 touch_device_list_(),
137 #if defined(USE_XI2_MT) 138 #if defined(USE_XI2_MT)
138 touch_device_list_() { 139 min_available_slot_(0),
140 slots_used_(),
141 tracking_id_map_() {
139 #else 142 #else
140 touch_device_list_(),
141 slots_used_() { 143 slots_used_() {
142 #endif 144 #endif
143 #if defined(TOUCH_UI) 145 #if defined(TOUCH_UI)
144 if (!base::MessagePumpForUI::HasXInput2()) 146 if (!base::MessagePumpForUI::HasXInput2())
145 return; 147 return;
146 #endif 148 #endif
147 149
148 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 150 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
149 XColor black; 151 XColor black;
150 black.red = black.green = black.blue = 0; 152 black.red = black.green = black.blue = 0;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 322 }
321 323
322 SetupValuator(); 324 SetupValuator();
323 } 325 }
324 326
325 bool TouchFactory::IsTouchDevice(unsigned deviceid) const { 327 bool TouchFactory::IsTouchDevice(unsigned deviceid) const {
326 return deviceid < touch_device_lookup_.size() ? 328 return deviceid < touch_device_lookup_.size() ?
327 touch_device_lookup_[deviceid] : false; 329 touch_device_lookup_[deviceid] : false;
328 } 330 }
329 331
330 #if !defined(USE_XI2_MT) 332 #if defined(USE_XI2_MT)
333 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) {
334 TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id);
335 if (itr != tracking_id_map_.end())
336 return itr->second;
337
338 int slot = min_available_slot_;
339 if (slot == kMaxTouchPoints) {
340 LOG(ERROR) << "Could not find available slot for touch point";
341 return 0;
342 }
343 SetSlotUsed(slot, true);
344 tracking_id_map_.insert(std::make_pair(tracking_id, slot));
345
346 // 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.
347 min_available_slot_++;
348 while (min_available_slot_ < kMaxTouchPoints)
349 {
350 if (!IsSlotUsed(min_available_slot_))
351 break;
352 min_available_slot_++;
353 }
354
355 return slot;
356 }
357
358 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) {
359 TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id);
360 if (itr != tracking_id_map_.end()) {
361 int slot = itr->second;
362 SetSlotUsed(slot, false);
363 tracking_id_map_.erase(itr);
364 if (slot < min_available_slot_)
365 min_available_slot_ = slot;
366 } else {
367 NOTREACHED() << "Cannot find slot mapping to tracking ID " << tracking_id;
368 }
369 }
370 #endif
371
331 bool TouchFactory::IsSlotUsed(int slot) const { 372 bool TouchFactory::IsSlotUsed(int slot) const {
332 CHECK_LT(slot, kMaxTouchPoints); 373 CHECK_LT(slot, kMaxTouchPoints);
333 return slots_used_[slot]; 374 return slots_used_[slot];
334 } 375 }
335 376
336 void TouchFactory::SetSlotUsed(int slot, bool used) { 377 void TouchFactory::SetSlotUsed(int slot, bool used) {
337 CHECK_LT(slot, kMaxTouchPoints); 378 CHECK_LT(slot, kMaxTouchPoints);
338 slots_used_[slot] = used; 379 slots_used_[slot] = used;
339 } 380 }
340 #endif
341 381
342 bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) { 382 bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) {
343 #if defined(TOUCH_UI) 383 #if defined(TOUCH_UI)
344 if (!base::MessagePumpForUI::HasXInput2() || 384 if (!base::MessagePumpForUI::HasXInput2() ||
345 touch_device_list_.empty()) 385 touch_device_list_.empty())
346 return true; 386 return true;
347 #endif 387 #endif
348 388
349 unsigned char mask[XIMaskLen(XI_LASTEVENT)]; 389 unsigned char mask[XIMaskLen(XI_LASTEVENT)];
350 bool success = true; 390 bool success = true;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 float* max) { 533 float* max) {
494 if (valuator_lookup_[deviceid][tp] >= 0) { 534 if (valuator_lookup_[deviceid][tp] >= 0) {
495 *min = touch_param_min_[deviceid][tp]; 535 *min = touch_param_min_[deviceid][tp];
496 *max = touch_param_max_[deviceid][tp]; 536 *max = touch_param_max_[deviceid][tp];
497 return true; 537 return true;
498 } 538 }
499 return false; 539 return false;
500 } 540 }
501 541
502 } // namespace views 542 } // namespace views
OLDNEW
« no previous file with comments | « views/touchui/touch_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698