Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: ui/events/devices/x11/device_data_manager_x11.cc

Issue 2028593004: Add new InputDeviceManager interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_keyboard
Patch Set: Fix windows compile error. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <X11/extensions/XInput.h> 8 #include <X11/extensions/XInput.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 void DeviceDataManagerX11::SetDisabledKeyboardAllowedKeys( 810 void DeviceDataManagerX11::SetDisabledKeyboardAllowedKeys(
811 std::unique_ptr<std::set<KeyboardCode>> excepted_keys) { 811 std::unique_ptr<std::set<KeyboardCode>> excepted_keys) {
812 DCHECK(!excepted_keys.get() || 812 DCHECK(!excepted_keys.get() ||
813 !blocked_keyboard_allowed_keys_.get()); 813 !blocked_keyboard_allowed_keys_.get());
814 blocked_keyboard_allowed_keys_ = std::move(excepted_keys); 814 blocked_keyboard_allowed_keys_ = std::move(excepted_keys);
815 } 815 }
816 816
817 void DeviceDataManagerX11::DisableDevice(int deviceid) { 817 void DeviceDataManagerX11::DisableDevice(int deviceid) {
818 blocked_devices_.set(deviceid, true); 818 blocked_devices_.set(deviceid, true);
819 // TODO(rsadam@): Support blocking touchscreen devices. 819 // TODO(rsadam@): Support blocking touchscreen devices.
820 std::vector<InputDevice> keyboards = keyboard_devices(); 820 std::vector<InputDevice> keyboards = GetKeyboardDevices();
821 std::vector<InputDevice>::iterator it = 821 std::vector<InputDevice>::iterator it =
822 FindDeviceWithId(keyboards.begin(), keyboards.end(), deviceid); 822 FindDeviceWithId(keyboards.begin(), keyboards.end(), deviceid);
823 if (it != std::end(keyboards)) { 823 if (it != std::end(keyboards)) {
824 blocked_keyboard_devices_.insert( 824 blocked_keyboard_devices_.insert(
825 std::pair<int, InputDevice>(deviceid, *it)); 825 std::pair<int, InputDevice>(deviceid, *it));
826 keyboards.erase(it); 826 keyboards.erase(it);
827 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); 827 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards);
828 } 828 }
829 } 829 }
830 830
831 void DeviceDataManagerX11::EnableDevice(int deviceid) { 831 void DeviceDataManagerX11::EnableDevice(int deviceid) {
832 blocked_devices_.set(deviceid, false); 832 blocked_devices_.set(deviceid, false);
833 std::map<int, InputDevice>::iterator it = 833 std::map<int, InputDevice>::iterator it =
834 blocked_keyboard_devices_.find(deviceid); 834 blocked_keyboard_devices_.find(deviceid);
835 if (it != blocked_keyboard_devices_.end()) { 835 if (it != blocked_keyboard_devices_.end()) {
836 std::vector<InputDevice> devices = keyboard_devices(); 836 std::vector<InputDevice> devices = GetKeyboardDevices();
837 // Add device to current list of active devices. 837 // Add device to current list of active devices.
838 devices.push_back((*it).second); 838 devices.push_back((*it).second);
839 blocked_keyboard_devices_.erase(it); 839 blocked_keyboard_devices_.erase(it);
840 DeviceDataManager::OnKeyboardDevicesUpdated(devices); 840 DeviceDataManager::OnKeyboardDevicesUpdated(devices);
841 } 841 }
842 } 842 }
843 843
844 bool DeviceDataManagerX11::IsDeviceEnabled(int device_id) const { 844 bool DeviceDataManagerX11::IsDeviceEnabled(int device_id) const {
845 return blocked_devices_.test(device_id); 845 return blocked_devices_.test(device_id);
846 } 846 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } else { 880 } else {
881 keyboards.erase(it); 881 keyboards.erase(it);
882 ++blocked_iter; 882 ++blocked_iter;
883 } 883 }
884 } 884 }
885 // Notify base class of updated list. 885 // Notify base class of updated list.
886 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); 886 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards);
887 } 887 }
888 888
889 } // namespace ui 889 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/devices/input_device_manager.cc ('k') | ui/events/devices/x11/device_data_manager_x11_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698