| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (!id_generator_.HasGeneratedIDFor(tracking_id)) | 247 if (!id_generator_.HasGeneratedIDFor(tracking_id)) |
| 248 return false; | 248 return false; |
| 249 *slot = static_cast<int>(id_generator_.GetGeneratedID(tracking_id)); | 249 *slot = static_cast<int>(id_generator_.GetGeneratedID(tracking_id)); |
| 250 return true; | 250 return true; |
| 251 } | 251 } |
| 252 | 252 |
| 253 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) { | 253 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) { |
| 254 return id_generator_.GetGeneratedID(tracking_id); | 254 return id_generator_.GetGeneratedID(tracking_id); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void TouchFactory::AcquireSlotForTrackingID(uint32 tracking_id) { | |
| 258 tracking_id_refcounts_[tracking_id]++; | |
| 259 } | |
| 260 | |
| 261 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) { | 257 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) { |
| 262 tracking_id_refcounts_[tracking_id]--; | 258 id_generator_.ReleaseNumber(tracking_id); |
| 263 if (tracking_id_refcounts_[tracking_id] == 0) | |
| 264 id_generator_.ReleaseNumber(tracking_id); | |
| 265 } | 259 } |
| 266 | 260 |
| 267 bool TouchFactory::IsTouchDevicePresent() { | 261 bool TouchFactory::IsTouchDevicePresent() { |
| 268 return !touch_events_disabled_ && touch_device_lookup_.any(); | 262 return !touch_events_disabled_ && touch_device_lookup_.any(); |
| 269 } | 263 } |
| 270 | 264 |
| 271 int TouchFactory::GetMaxTouchPoints() const { | 265 int TouchFactory::GetMaxTouchPoints() const { |
| 272 return max_touch_points_; | 266 return max_touch_points_; |
| 273 } | 267 } |
| 274 | 268 |
| 275 void TouchFactory::ResetForTest() { | 269 void TouchFactory::ResetForTest() { |
| 276 pointer_device_lookup_.reset(); | 270 pointer_device_lookup_.reset(); |
| 277 touch_device_lookup_.reset(); | 271 touch_device_lookup_.reset(); |
| 278 touch_events_disabled_ = false; | 272 touch_events_disabled_ = false; |
| 279 touch_device_list_.clear(); | 273 touch_device_list_.clear(); |
| 280 touchscreen_ids_.clear(); | 274 touchscreen_ids_.clear(); |
| 281 tracking_id_refcounts_.clear(); | |
| 282 max_touch_points_ = -1; | 275 max_touch_points_ = -1; |
| 283 id_generator_.ResetForTest(); | 276 id_generator_.ResetForTest(); |
| 284 } | 277 } |
| 285 | 278 |
| 286 void TouchFactory::SetTouchDeviceForTest( | 279 void TouchFactory::SetTouchDeviceForTest( |
| 287 const std::vector<unsigned int>& devices) { | 280 const std::vector<unsigned int>& devices) { |
| 288 touch_device_lookup_.reset(); | 281 touch_device_lookup_.reset(); |
| 289 touch_device_list_.clear(); | 282 touch_device_list_.clear(); |
| 290 for (std::vector<unsigned int>::const_iterator iter = devices.begin(); | 283 for (std::vector<unsigned int>::const_iterator iter = devices.begin(); |
| 291 iter != devices.end(); ++iter) { | 284 iter != devices.end(); ++iter) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 if (ptr[0] || ptr[1]) | 331 if (ptr[0] || ptr[1]) |
| 339 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); | 332 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); |
| 340 } | 333 } |
| 341 XFree(prop_return); | 334 XFree(prop_return); |
| 342 } | 335 } |
| 343 | 336 |
| 344 XCloseDevice(display, device); | 337 XCloseDevice(display, device); |
| 345 } | 338 } |
| 346 | 339 |
| 347 } // namespace ui | 340 } // namespace ui |
| OLD | NEW |