Chromium Code Reviews| Index: ui/events/device_data_manager.cc |
| diff --git a/ui/events/device_data_manager.cc b/ui/events/device_data_manager.cc |
| index d255b871abc80b10082d7408e92e25deafc7cb9a..4a375af325a201f341379b67d38c73104cdcf721 100644 |
| --- a/ui/events/device_data_manager.cc |
| +++ b/ui/events/device_data_manager.cc |
| @@ -13,6 +13,20 @@ |
| namespace ui { |
| +namespace { |
| + |
| +bool TouchscreenEquals(const ui::TouchscreenDevice& a, |
| + const ui::TouchscreenDevice& b) { |
| + return a.id == b.id; |
| +} |
| + |
| +bool KeyboardEquals(const ui::KeyboardDevice& a, |
| + const ui::KeyboardDevice& b) { |
| + return a.id == b.id; |
| +} |
| + |
| +} // namespace |
| + |
| // static |
| DeviceDataManager* DeviceDataManager::instance_ = NULL; |
| @@ -111,11 +125,26 @@ int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const { |
| void DeviceDataManager::OnTouchscreenDevicesUpdated( |
| const std::vector<TouchscreenDevice>& devices) { |
| - touchscreen_devices_ = devices; |
| + if (devices.size() != touchscreen_devices_.size() || |
| + std::equal(devices.begin(), devices.end(), |
|
flackr
2014/10/04 00:35:12
Did you mean !std::equal(...?
rsadam
2014/10/04 18:46:27
Done.
|
| + touchscreen_devices_.begin(), TouchscreenEquals)) { |
|
flackr
2014/10/04 00:35:12
nit: indent 4 more (to show it's wrapped from std:
rsadam
2014/10/04 18:46:27
Done.
|
| + touchscreen_devices_ = devices; |
|
flackr
2014/10/04 00:35:12
Better yet, early return if the device list looks
rsadam
2014/10/04 18:46:27
Done.
|
| + FOR_EACH_OBSERVER(InputDeviceEventObserver, |
| + observers_, |
| + OnTouchscreenDeviceConfigurationChanged()); |
| + } |
| +} |
| - FOR_EACH_OBSERVER(InputDeviceEventObserver, |
| +void DeviceDataManager::OnKeyboardDevicesUpdated( |
| + const std::vector<KeyboardDevice>& devices) { |
| + if (devices.size() != keyboard_devices_.size() || |
| + std::equal(devices.begin(), devices.end(), |
|
flackr
2014/10/04 00:35:12
ditto, !std::equal?
rsadam
2014/10/04 18:46:27
Done.
|
| + keyboard_devices_.begin(), KeyboardEquals)) { |
|
flackr
2014/10/04 00:35:12
ditto, indent 4 more or to just past '(' above.
rsadam
2014/10/04 18:46:27
Done.
|
| + keyboard_devices_ = devices; |
| + FOR_EACH_OBSERVER(InputDeviceEventObserver, |
| observers_, |
| - OnInputDeviceConfigurationChanged()); |
| + OnKeyboardDeviceConfigurationChanged()); |
| + } |
| } |
| void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { |