Chromium Code Reviews| 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 3b91724f4f6a6e8ab31489fe58d92aec9648d434..7d74e54f540e020bf1c3623faa0cb7ac3d7fcc55 100644 |
| --- a/ui/events/devices/x11/touch_factory_x11.cc |
| +++ b/ui/events/devices/x11/touch_factory_x11.cc |
| @@ -74,7 +74,6 @@ void TouchFactory::SetTouchDeviceListFromCommandLine() { |
| void TouchFactory::UpdateDeviceList(XDisplay* display) { |
| // Detect touch devices. |
| - touch_device_lookup_.reset(); |
| touch_device_list_.clear(); |
| touchscreen_ids_.clear(); |
| @@ -105,10 +104,8 @@ void TouchFactory::UpdateDeviceList(XDisplay* display) { |
| XITouchClassInfo* tci = |
| reinterpret_cast<XITouchClassInfo*>(xiclassinfo); |
| // Only care direct touch device (such as touch screen) right now |
| - if (tci->mode == XIDirectTouch) { |
| - touch_device_lookup_[devinfo.deviceid] = true; |
| + if (tci->mode == XIDirectTouch) |
| touch_device_list_[devinfo.deviceid] = true; |
| - } |
| } |
| } |
| pointer_device_lookup_[devinfo.deviceid] = true; |
| @@ -129,7 +126,6 @@ void TouchFactory::UpdateDeviceList(XDisplay* display) { |
| device_master_id_list_[devinfo.deviceid] = devinfo.attachment; |
| // If the slave device is direct touch device, we also set its |
| // master device to be touch device. |
| - touch_device_lookup_[devinfo.attachment] = true; |
| touch_device_list_[devinfo.attachment] = true; |
| } |
| } |
| @@ -232,32 +228,28 @@ void TouchFactory::SetupXI2ForXWindow(Window window) { |
| } |
| void TouchFactory::SetTouchDeviceList(const std::vector<int>& devices) { |
| - touch_device_lookup_.reset(); |
| touch_device_list_.clear(); |
| for (int deviceid : devices) { |
| DCHECK(IsValidDevice(deviceid)); |
| - touch_device_lookup_[deviceid] = true; |
| touch_device_list_[deviceid] = false; |
| if (device_master_id_list_.find(deviceid) != device_master_id_list_.end()) { |
| // When we set the device through the "--touch-devices" flag to slave |
| // touch device, we also set its master device to be touch device. |
| - touch_device_lookup_[device_master_id_list_[deviceid]] = true; |
| touch_device_list_[device_master_id_list_[deviceid]] = false; |
| } |
| } |
| } |
| bool TouchFactory::IsValidDevice(int deviceid) const { |
| - return (deviceid >= 0) && |
| - (static_cast<size_t>(deviceid) < touch_device_lookup_.size()); |
| + return deviceid >= 0; |
|
sadrul
2016/12/08 17:53:16
Should we check size of |touch_device_list_| inste
|
| } |
| bool TouchFactory::IsTouchDevice(int deviceid) const { |
| - return IsValidDevice(deviceid) ? touch_device_lookup_[deviceid] : false; |
| + return IsValidDevice(deviceid) && (touch_device_list_.count(deviceid) > 0); |
| } |
| bool TouchFactory::IsMultiTouchDevice(int deviceid) const { |
| - return (IsValidDevice(deviceid) && touch_device_lookup_[deviceid]) |
| + return IsTouchDevice(deviceid) |
| ? touch_device_list_.find(deviceid)->second |
| : false; |
| } |
| @@ -278,13 +270,11 @@ void TouchFactory::ReleaseSlotForTrackingID(uint32_t tracking_id) { |
| } |
| bool TouchFactory::IsTouchDevicePresent() { |
| - return touch_screens_enabled_ && |
| - touch_device_lookup_.any(); |
| + return touch_screens_enabled_ && !touch_device_list_.empty(); |
| } |
| void TouchFactory::ResetForTest() { |
| pointer_device_lookup_.reset(); |
| - touch_device_lookup_.reset(); |
| touch_device_list_.clear(); |
| touchscreen_ids_.clear(); |
| id_generator_.ResetForTest(); |
| @@ -293,12 +283,10 @@ void TouchFactory::ResetForTest() { |
| void TouchFactory::SetTouchDeviceForTest( |
| const std::vector<int>& devices) { |
| - touch_device_lookup_.reset(); |
| touch_device_list_.clear(); |
| for (std::vector<int>::const_iterator iter = devices.begin(); |
| iter != devices.end(); ++iter) { |
| DCHECK(IsValidDevice(*iter)); |
| - touch_device_lookup_[*iter] = true; |
| touch_device_list_[*iter] = true; |
| } |
| SetTouchscreensEnabled(true); |