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

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: 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 unified diff | Download patch
« views/touchui/touch_factory.h ('K') | « 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 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <gdk/gdkx.h> 8 #include <gdk/gdkx.h>
9 #include <X11/cursorfont.h> 9 #include <X11/cursorfont.h>
10 #include <X11/extensions/XInput.h> 10 #include <X11/extensions/XInput.h>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // static 122 // static
123 TouchFactory* TouchFactory::GetInstance() { 123 TouchFactory* TouchFactory::GetInstance() {
124 return Singleton<TouchFactory>::get(); 124 return Singleton<TouchFactory>::get();
125 } 125 }
126 126
127 TouchFactory::TouchFactory() 127 TouchFactory::TouchFactory()
128 : is_cursor_visible_(true), 128 : is_cursor_visible_(true),
129 keep_mouse_cursor_(false), 129 keep_mouse_cursor_(false),
130 cursor_timer_(), 130 cursor_timer_(),
131 pointer_device_lookup_(), 131 pointer_device_lookup_(),
132 touch_device_list_(),
132 #if defined(USE_XI2_MT) 133 #if defined(USE_XI2_MT)
133 touch_device_list_() { 134 slots_used_(),
sadrul 2011/09/19 16:13:36 slots_used_ is used even when USE_XI2_MT is not se
ningxin.hu 2011/09/20 16:08:49 Yes.
135 tracking_id_map_() {
134 #else 136 #else
135 touch_device_list_(),
136 slots_used_() { 137 slots_used_() {
137 #endif 138 #endif
138 #if defined(TOUCH_UI) 139 #if defined(TOUCH_UI)
139 if (!base::MessagePumpForUI::HasXInput2()) 140 if (!base::MessagePumpForUI::HasXInput2())
140 return; 141 return;
141 #endif 142 #endif
142 143
143 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 144 char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
144 XColor black; 145 XColor black;
145 black.red = black.green = black.blue = 0; 146 black.red = black.green = black.blue = 0;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 313 }
313 314
314 SetupValuator(); 315 SetupValuator();
315 } 316 }
316 317
317 bool TouchFactory::IsTouchDevice(unsigned deviceid) const { 318 bool TouchFactory::IsTouchDevice(unsigned deviceid) const {
318 return deviceid < touch_device_lookup_.size() ? 319 return deviceid < touch_device_lookup_.size() ?
319 touch_device_lookup_[deviceid] : false; 320 touch_device_lookup_[deviceid] : false;
320 } 321 }
321 322
322 #if !defined(USE_XI2_MT) 323 #if defined(USE_XI2_MT)
324 int TouchFactory::AllocateSlotIdForTrackingId(uint32 tracking_id) {
325 TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id);
326 if (itr != tracking_id_map_.end())
327 return itr->second;
328
329 // Find the lowest available slot, assume kMaxTouchPoints is less than 32
330 int slot = ffs(~(slots_used_.to_ulong())) - 1;
sadrul 2011/09/19 16:13:36 I think we can spare a few cycles here and do a lo
ningxin.hu 2011/09/20 16:08:49 OK. Will implement it.
331 if (slot == -1) {
332 LOG(ERROR) << "Could not find available slot for touch point";
333 return 0;
334 }
335 SetSlotUsed(slot, true);
336 tracking_id_map_.insert(std::make_pair(tracking_id, slot));
337 return slot;
338 }
339
340 void TouchFactory::ReleaseSlotIdForTrackingId(uint32 tracking_id) {
341 TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id);
342 if (itr != tracking_id_map_.end()) {
343 SetSlotUsed(itr->second, false);
344 tracking_id_map_.erase(itr);
345 }
sadrul 2011/09/19 16:13:36 Add a NOTREACHED or DCHECK on else
ningxin.hu 2011/09/20 16:08:49 Will add. Thanks for comment.
346 }
347 #endif
348
323 bool TouchFactory::IsSlotUsed(int slot) const { 349 bool TouchFactory::IsSlotUsed(int slot) const {
324 CHECK_LT(slot, kMaxTouchPoints); 350 CHECK_LT(slot, kMaxTouchPoints);
325 return slots_used_[slot]; 351 return slots_used_[slot];
326 } 352 }
327 353
328 void TouchFactory::SetSlotUsed(int slot, bool used) { 354 void TouchFactory::SetSlotUsed(int slot, bool used) {
329 CHECK_LT(slot, kMaxTouchPoints); 355 CHECK_LT(slot, kMaxTouchPoints);
330 slots_used_[slot] = used; 356 slots_used_[slot] = used;
331 } 357 }
332 #endif
333 358
334 bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) { 359 bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) {
335 #if defined(TOUCH_UI) 360 #if defined(TOUCH_UI)
336 if (!base::MessagePumpForUI::HasXInput2() || 361 if (!base::MessagePumpForUI::HasXInput2() ||
337 touch_device_list_.empty()) 362 touch_device_list_.empty())
338 return true; 363 return true;
339 #endif 364 #endif
340 365
341 unsigned char mask[XIMaskLen(XI_LASTEVENT)]; 366 unsigned char mask[XIMaskLen(XI_LASTEVENT)];
342 bool success = true; 367 bool success = true;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 float* max) { 508 float* max) {
484 if (valuator_lookup_[deviceid][tp] >= 0) { 509 if (valuator_lookup_[deviceid][tp] >= 0) {
485 *min = touch_param_min_[deviceid][tp]; 510 *min = touch_param_min_[deviceid][tp];
486 *max = touch_param_max_[deviceid][tp]; 511 *max = touch_param_max_[deviceid][tp];
487 return true; 512 return true;
488 } 513 }
489 return false; 514 return false;
490 } 515 }
491 516
492 } // namespace views 517 } // namespace views
OLDNEW
« views/touchui/touch_factory.h ('K') | « views/touchui/touch_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698