OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/device_data_manager_x11.h" | 5 #include "ui/events/devices/x11/device_data_manager_x11.h" |
6 | 6 |
7 #include <X11/extensions/XInput.h> | 7 #include <X11/extensions/XInput.h> |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 | 10 |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 blocked_keyboards_.find(deviceid); | 733 blocked_keyboards_.find(deviceid); |
734 if (it != blocked_keyboards_.end()) { | 734 if (it != blocked_keyboards_.end()) { |
735 std::vector<KeyboardDevice> devices = keyboard_devices(); | 735 std::vector<KeyboardDevice> devices = keyboard_devices(); |
736 // Add device to current list of active devices. | 736 // Add device to current list of active devices. |
737 devices.push_back((*it).second); | 737 devices.push_back((*it).second); |
738 blocked_keyboards_.erase(it); | 738 blocked_keyboards_.erase(it); |
739 DeviceDataManager::OnKeyboardDevicesUpdated(devices); | 739 DeviceDataManager::OnKeyboardDevicesUpdated(devices); |
740 } | 740 } |
741 } | 741 } |
742 | 742 |
| 743 bool DeviceDataManagerX11::IsDeviceEnabled(int device_id) const { |
| 744 return blocked_devices_.test(device_id); |
| 745 } |
| 746 |
743 bool DeviceDataManagerX11::IsEventBlocked( | 747 bool DeviceDataManagerX11::IsEventBlocked( |
744 const base::NativeEvent& native_event) { | 748 const base::NativeEvent& native_event) { |
745 // Only check XI2 events which have a source device id. | 749 // Only check XI2 events which have a source device id. |
746 if (native_event->type != GenericEvent) | 750 if (native_event->type != GenericEvent) |
747 return false; | 751 return false; |
748 | 752 |
749 XIDeviceEvent* xievent = | 753 XIDeviceEvent* xievent = |
750 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 754 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
751 // Allow any key events from blocked_keyboard_allowed_keys_. | 755 // Allow any key events from blocked_keyboard_allowed_keys_. |
752 if (blocked_keyboard_allowed_keys_ && | 756 if (blocked_keyboard_allowed_keys_ && |
(...skipping 25 matching lines...) Expand all Loading... |
778 } else { | 782 } else { |
779 keyboards.erase(it); | 783 keyboards.erase(it); |
780 ++blocked_iter; | 784 ++blocked_iter; |
781 } | 785 } |
782 } | 786 } |
783 // Notify base class of updated list. | 787 // Notify base class of updated list. |
784 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); | 788 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); |
785 } | 789 } |
786 | 790 |
787 } // namespace ui | 791 } // namespace ui |
OLD | NEW |