OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |