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

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: Update the patch set according to comment #2. 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/events/event_x.cc ('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_(),
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::GetSlotForTrackingID(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 // Finds the lowest available slot and sets up the mapping.
330 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.
331 while (slot < kMaxTouchPoints) {
332 if (!IsSlotUsed(slot))
333 break;
334 slot++;
335 }
336 if (slot == kMaxTouchPoints) {
337 LOG(ERROR) << "Could not find available slot for touch point";
338 return 0;
339 }
340 SetSlotUsed(slot, true);
341 tracking_id_map_.insert(std::make_pair(tracking_id, slot));
342 return slot;
343 }
344
345 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) {
346 TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id);
347 if (itr != tracking_id_map_.end()) {
348 SetSlotUsed(itr->second, false);
349 tracking_id_map_.erase(itr);
350 } else {
351 NOTREACHED() << "Cannot find slot mapping to tracking ID " << tracking_id;
352 }
353 }
354 #endif
355
323 bool TouchFactory::IsSlotUsed(int slot) const { 356 bool TouchFactory::IsSlotUsed(int slot) const {
324 CHECK_LT(slot, kMaxTouchPoints); 357 CHECK_LT(slot, kMaxTouchPoints);
325 return slots_used_[slot]; 358 return slots_used_[slot];
326 } 359 }
327 360
328 void TouchFactory::SetSlotUsed(int slot, bool used) { 361 void TouchFactory::SetSlotUsed(int slot, bool used) {
329 CHECK_LT(slot, kMaxTouchPoints); 362 CHECK_LT(slot, kMaxTouchPoints);
330 slots_used_[slot] = used; 363 slots_used_[slot] = used;
331 } 364 }
332 #endif
333 365
334 bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) { 366 bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) {
335 #if defined(TOUCH_UI) 367 #if defined(TOUCH_UI)
336 if (!base::MessagePumpForUI::HasXInput2() || 368 if (!base::MessagePumpForUI::HasXInput2() ||
337 touch_device_list_.empty()) 369 touch_device_list_.empty())
338 return true; 370 return true;
339 #endif 371 #endif
340 372
341 unsigned char mask[XIMaskLen(XI_LASTEVENT)]; 373 unsigned char mask[XIMaskLen(XI_LASTEVENT)];
342 bool success = true; 374 bool success = true;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 float* max) { 517 float* max) {
486 if (valuator_lookup_[deviceid][tp] >= 0) { 518 if (valuator_lookup_[deviceid][tp] >= 0) {
487 *min = touch_param_min_[deviceid][tp]; 519 *min = touch_param_min_[deviceid][tp];
488 *max = touch_param_max_[deviceid][tp]; 520 *max = touch_param_max_[deviceid][tp];
489 return true; 521 return true;
490 } 522 }
491 return false; 523 return false;
492 } 524 }
493 525
494 } // namespace views 526 } // namespace views
OLDNEW
« views/events/event_x.cc ('K') | « views/touchui/touch_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698