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

Side by Side Diff: ui/events/devices/x11/touch_factory_x11.cc

Issue 785753002: Don't refcount tracking id -> slot id mapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/events/devices/x11/touch_factory_x11.h" 5 #include "ui/events/devices/x11/touch_factory_x11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/XInput.h> 9 #include <X11/extensions/XInput.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (!id_generator_.HasGeneratedIDFor(tracking_id)) 243 if (!id_generator_.HasGeneratedIDFor(tracking_id))
244 return false; 244 return false;
245 *slot = static_cast<int>(id_generator_.GetGeneratedID(tracking_id)); 245 *slot = static_cast<int>(id_generator_.GetGeneratedID(tracking_id));
246 return true; 246 return true;
247 } 247 }
248 248
249 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) { 249 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) {
250 return id_generator_.GetGeneratedID(tracking_id); 250 return id_generator_.GetGeneratedID(tracking_id);
251 } 251 }
252 252
253 void TouchFactory::AcquireSlotForTrackingID(uint32 tracking_id) {
254 tracking_id_refcounts_[tracking_id]++;
255 }
256
257 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) { 253 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) {
258 tracking_id_refcounts_[tracking_id]--; 254 id_generator_.ReleaseNumber(tracking_id);
259 if (tracking_id_refcounts_[tracking_id] == 0)
260 id_generator_.ReleaseNumber(tracking_id);
261 } 255 }
262 256
263 bool TouchFactory::IsTouchDevicePresent() { 257 bool TouchFactory::IsTouchDevicePresent() {
264 return !touch_events_disabled_ && touch_device_lookup_.any(); 258 return !touch_events_disabled_ && touch_device_lookup_.any();
265 } 259 }
266 260
267 void TouchFactory::ResetForTest() { 261 void TouchFactory::ResetForTest() {
268 pointer_device_lookup_.reset(); 262 pointer_device_lookup_.reset();
269 touch_device_lookup_.reset(); 263 touch_device_lookup_.reset();
270 touch_events_disabled_ = false; 264 touch_events_disabled_ = false;
271 touch_device_list_.clear(); 265 touch_device_list_.clear();
272 touchscreen_ids_.clear(); 266 touchscreen_ids_.clear();
273 tracking_id_refcounts_.clear();
274 id_generator_.ResetForTest(); 267 id_generator_.ResetForTest();
275 } 268 }
276 269
277 void TouchFactory::SetTouchDeviceForTest( 270 void TouchFactory::SetTouchDeviceForTest(
278 const std::vector<unsigned int>& devices) { 271 const std::vector<unsigned int>& devices) {
279 touch_device_lookup_.reset(); 272 touch_device_lookup_.reset();
280 touch_device_list_.clear(); 273 touch_device_list_.clear();
281 for (std::vector<unsigned int>::const_iterator iter = devices.begin(); 274 for (std::vector<unsigned int>::const_iterator iter = devices.begin();
282 iter != devices.end(); ++iter) { 275 iter != devices.end(); ++iter) {
283 DCHECK(*iter < touch_device_lookup_.size()); 276 DCHECK(*iter < touch_device_lookup_.size());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (ptr[0] || ptr[1]) 322 if (ptr[0] || ptr[1])
330 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); 323 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
331 } 324 }
332 XFree(prop_return); 325 XFree(prop_return);
333 } 326 }
334 327
335 XCloseDevice(display, device); 328 XCloseDevice(display, device);
336 } 329 }
337 330
338 } // namespace ui 331 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/devices/x11/touch_factory_x11.h ('k') | ui/events/event.h » ('j') | ui/events/event.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698