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

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

Issue 313913004: Block internal PlatformEvents before they are dispatched in touchview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Block events from disabled devices through DeviceDataManager. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/x/device_data_manager.cc
diff --git a/ui/events/x/device_data_manager.cc b/ui/events/x/device_data_manager.cc
index 4cc0957b4a8379140c3dda73ceee093d4b0d52aa..eaef11ff179793377f190a240c7dac0228e8600c 100644
--- a/ui/events/x/device_data_manager.cc
+++ b/ui/events/x/device_data_manager.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/event_utils.h"
#include "ui/events/x/device_list_cache_x.h"
#include "ui/events/x/touch_factory_x11.h"
#include "ui/gfx/display.h"
@@ -115,6 +116,7 @@ DeviceDataManager* DeviceDataManager::GetInstance() {
DeviceDataManager::DeviceDataManager()
: xi_opcode_(-1),
+ blocked_keyboard_(false),
atom_cache_(gfx::GetXDisplay(), kCachedAtoms),
button_map_count_(0) {
CHECK(gfx::GetXDisplay());
@@ -651,6 +653,45 @@ bool DeviceDataManager::TouchEventNeedsCalibrate(int touch_device_id) const {
return false;
}
+void DeviceDataManager::DisableKeyboard(
+ scoped_ptr<std::set<KeyboardCode> > excepted_keys) {
+ DCHECK(!blocked_keyboard_);
+ DCHECK(!blocked_keyboard_allowed_keys_.get());
+ DCHECK(excepted_keys);
sadrul 2014/06/12 21:02:27 This is probably not necessary? It should be possi
flackr 2014/06/18 05:28:32 Done.
+ blocked_keyboard_ = true;
+ blocked_keyboard_allowed_keys_ = excepted_keys.Pass();
+}
+
+void DeviceDataManager::EnableKeyboard() {
+ DCHECK(blocked_keyboard_);
+ blocked_keyboard_ = false;
+ blocked_keyboard_allowed_keys_.reset();
+}
+
+void DeviceDataManager::DisableDevice(unsigned int deviceid) {
+ blocked_devices_.set(deviceid, true);
+}
+
+void DeviceDataManager::EnableDevice(unsigned int deviceid) {
+ blocked_devices_.set(deviceid, false);
+}
+
+bool DeviceDataManager::EventBlocked(const base::NativeEvent& native_event) {
+ switch (native_event->type) {
+ case KeyPress:
+ case KeyRelease:
+ return blocked_keyboard_ && blocked_keyboard_allowed_keys_->find(
+ KeyboardCodeFromNative(native_event)) ==
+ blocked_keyboard_allowed_keys_->end();
+ case GenericEvent:
+ return blocked_devices_.test(
+ static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid);
+ default:
+ break;
+ }
+ return false;
+}
+
void DeviceDataManager::ClearTouchTransformerRecord() {
for (int i = 0; i < kMaxDeviceNum; i++) {
touch_device_transformer_map_[i] = gfx::Transform();

Powered by Google App Engine
This is Rietveld 408576698