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

Unified Diff: ui/events/x/device_data_manager_x11.cc

Issue 618283003: Adds special support to the device manager for keyboards devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made comparator anonymous. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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..52a49a9a14f4402b090b60079afe3084103c1723 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());
}
bool DeviceDataManagerX11::IsEventBlocked(
@@ -707,4 +722,16 @@ 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_)),
flackr 2014/10/06 21:14:53 nit: Looks like this can be pushed up to the previ
rsadam 2014/10/07 05:25:05 Done.
+ keyboards.end());
+ DeviceDataManager::OnKeyboardDevicesUpdated(keyboards);
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698