Index: ui/events/devices/x11/touch_factory_x11.cc |
diff --git a/ui/events/devices/x11/touch_factory_x11.cc b/ui/events/devices/x11/touch_factory_x11.cc |
index 3d0423569ee11abbda85db1c368ef4f8ca324006..40c56240d9a189ee1518e38a05fc4a54a75ada1a 100644 |
--- a/ui/events/devices/x11/touch_factory_x11.cc |
+++ b/ui/events/devices/x11/touch_factory_x11.cc |
@@ -63,8 +63,8 @@ void TouchFactory::SetTouchDeviceListFromCommandLine() { |
if (!touch_devices.empty()) { |
std::vector<std::string> devs; |
- std::vector<unsigned int> device_ids; |
- unsigned int devid; |
+ std::vector<int> device_ids; |
+ int devid; |
base::SplitString(touch_devices, ',', &devs); |
for (std::vector<std::string>::iterator iter = devs.begin(); |
iter != devs.end(); ++iter) { |
@@ -216,28 +216,30 @@ void TouchFactory::SetupXI2ForXWindow(Window window) { |
XFlush(display); |
} |
-void TouchFactory::SetTouchDeviceList( |
- const std::vector<unsigned int>& devices) { |
+void TouchFactory::SetTouchDeviceList(const std::vector<int>& devices) { |
touch_device_lookup_.reset(); |
touch_device_list_.clear(); |
- for (std::vector<unsigned int>::const_iterator iter = devices.begin(); |
+ for (std::vector<int>::const_iterator iter = devices.begin(); |
iter != devices.end(); ++iter) { |
- DCHECK(*iter < touch_device_lookup_.size()); |
+ DCHECK(IsValidDevice(*iter)); |
touch_device_lookup_[*iter] = true; |
touch_device_list_[*iter] = false; |
} |
} |
-bool TouchFactory::IsTouchDevice(unsigned deviceid) const { |
- return deviceid < touch_device_lookup_.size() ? |
- touch_device_lookup_[deviceid] : false; |
+bool TouchFactory::IsValidDevice(int deviceid) const { |
+ return (deviceid >= 0) && |
+ (static_cast<size_t>(deviceid) < touch_device_lookup_.size()); |
} |
-bool TouchFactory::IsMultiTouchDevice(unsigned int deviceid) const { |
- return (deviceid < touch_device_lookup_.size() && |
- touch_device_lookup_[deviceid]) ? |
- touch_device_list_.find(deviceid)->second : |
- false; |
+bool TouchFactory::IsTouchDevice(int deviceid) const { |
+ return IsValidDevice(deviceid) ? touch_device_lookup_[deviceid] : false; |
+} |
+ |
+bool TouchFactory::IsMultiTouchDevice(int deviceid) const { |
+ return (IsValidDevice(deviceid) && touch_device_lookup_[deviceid]) |
+ ? touch_device_list_.find(deviceid)->second |
+ : false; |
} |
bool TouchFactory::QuerySlotForTrackingID(uint32 tracking_id, int* slot) { |
@@ -269,12 +271,12 @@ void TouchFactory::ResetForTest() { |
} |
void TouchFactory::SetTouchDeviceForTest( |
- const std::vector<unsigned int>& devices) { |
+ const std::vector<int>& devices) { |
touch_device_lookup_.reset(); |
touch_device_list_.clear(); |
- for (std::vector<unsigned int>::const_iterator iter = devices.begin(); |
+ for (std::vector<int>::const_iterator iter = devices.begin(); |
iter != devices.end(); ++iter) { |
- DCHECK(*iter < touch_device_lookup_.size()); |
+ DCHECK(IsValidDevice(*iter)); |
touch_device_lookup_[*iter] = true; |
touch_device_list_[*iter] = true; |
} |
@@ -282,9 +284,9 @@ void TouchFactory::SetTouchDeviceForTest( |
} |
void TouchFactory::SetPointerDeviceForTest( |
- const std::vector<unsigned int>& devices) { |
+ const std::vector<int>& devices) { |
pointer_device_lookup_.reset(); |
- for (std::vector<unsigned int>::const_iterator iter = devices.begin(); |
+ for (std::vector<int>::const_iterator iter = devices.begin(); |
iter != devices.end(); ++iter) { |
pointer_device_lookup_[*iter] = true; |
} |