Chromium Code Reviews| Index: ui/events/x/device_data_manager_x11.cc |
| diff --git a/ui/events/x/device_data_manager_x11.cc b/ui/events/x/device_data_manager_x11.cc |
| index 795cc44be7b4af79def8f0bbfce52cdd02ea6664..61ec4ec510d02c14e3267add3c43b8e497e63cb0 100644 |
| --- a/ui/events/x/device_data_manager_x11.cc |
| +++ b/ui/events/x/device_data_manager_x11.cc |
| @@ -13,6 +13,7 @@ |
| #include "base/sys_info.h" |
| #include "ui/events/event_constants.h" |
| #include "ui/events/event_switches.h" |
| +#include "ui/events/keyboard_device.h" |
| #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| #include "ui/events/x/device_list_cache_x.h" |
| #include "ui/events/x/touch_factory_x11.h" |
| @@ -106,6 +107,16 @@ const int kTouchDataTypeEnd = ui::DeviceDataManagerX11::DT_TOUCH_RAW_TIMESTAMP; |
| namespace ui { |
| +namespace { |
| + |
| +bool ShouldIgnoreKeyboard( |
| + ui::KeyboardDevice keyboard, |
| + const std::bitset<DeviceDataManagerX11::kMaxDeviceNum>& blocked_devices) { |
| + return blocked_devices.test(keyboard.id); |
| +} |
| + |
| +} // namespace |
| + |
| bool DeviceDataManagerX11::IsCMTDataType(const int type) { |
| return (type >= kCMTDataTypeStart) && (type <= kCMTDataTypeEnd); |
| } |
| @@ -681,10 +692,14 @@ void DeviceDataManagerX11::SetDisabledKeyboardAllowedKeys( |
| void DeviceDataManagerX11::DisableDevice(unsigned int deviceid) { |
| blocked_devices_.set(deviceid, true); |
| + OnTouchscreenDevicesUpdated(touchscreen_devices()); |
| + OnKeyboardDevicesUpdated(keyboard_devices()); |
| } |
| void DeviceDataManagerX11::EnableDevice(unsigned int deviceid) { |
| blocked_devices_.set(deviceid, false); |
| + OnTouchscreenDevicesUpdated(touchscreen_devices()); |
| + OnKeyboardDevicesUpdated(keyboard_devices()); |
|
flackr
2014/10/07 13:30:15
Can you add a test to ensure enable/disable correc
rsadam
2014/10/07 22:00:36
Done.
|
| } |
| bool DeviceDataManagerX11::IsEventBlocked( |
| @@ -707,4 +722,15 @@ bool DeviceDataManagerX11::IsEventBlocked( |
| return blocked_devices_.test(xievent->sourceid); |
| } |
| +void DeviceDataManagerX11::OnKeyboardDevicesUpdated( |
| + const std::vector<KeyboardDevice>& devices) { |
| + std::vector<KeyboardDevice> keyboards(devices); |
| + keyboards.erase( |
| + std::remove_if(keyboards.begin(), keyboards.end(), |
| + std::bind2nd( |
| + std::ptr_fun(&ShouldIgnoreKeyboard), blocked_devices_)), |
| + keyboards.end()); |
| + DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); |
| +} |
| + |
| } // namespace ui |