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

Unified Diff: chrome/browser/chromeos/events/event_rewriter.cc

Issue 192123002: chromeos: A little more cleanup for EventRewriter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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: chrome/browser/chromeos/events/event_rewriter.cc
diff --git a/chrome/browser/chromeos/events/event_rewriter.cc b/chrome/browser/chromeos/events/event_rewriter.cc
index bebcf47fda94e5047ffa8c5da7abe5072827edd7..3c0548a90e750b763dd02e7e576e3a33a1ac958b 100644
--- a/chrome/browser/chromeos/events/event_rewriter.cc
+++ b/chrome/browser/chromeos/events/event_rewriter.cc
@@ -185,13 +185,31 @@ void EventRewriter::RewriteForTesting(XEvent* event) {
Rewrite(event);
}
+void EventRewriter::DeviceKeyPressedOrReleased(int device_id) {
+ std::map<int, DeviceType>::const_iterator iter =
+ device_id_to_type_.find(device_id);
+ if (iter == device_id_to_type_.end()) {
+ // |device_id| is unknown. This means the device was connected before
+ // booting the OS. Query the name of the device and add it to the map.
+ DeviceAdded(device_id);
+ }
+
+ last_device_id_ = device_id;
+}
+
base::EventStatus EventRewriter::WillProcessEvent(
const base::NativeEvent& event) {
XEvent* xevent = event;
if (xevent->type == KeyPress || xevent->type == KeyRelease) {
Rewrite(xevent);
} else if (xevent->type == GenericEvent) {
- RewriteLocatedEvent(xevent);
+ XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data);
+ if (xievent->evtype == XI_KeyPress || xievent->evtype == XI_KeyRelease) {
+ if (xievent->deviceid == xievent->sourceid)
+ DeviceKeyPressedOrReleased(xievent->deviceid);
+ } else {
+ RewriteLocatedEvent(xevent);
+ }
} else if (xevent->type == MappingNotify) {
if (xevent->xmapping.request == MappingModifier ||
xevent->xmapping.request == MappingKeyboard) {
@@ -204,6 +222,8 @@ base::EventStatus EventRewriter::WillProcessEvent(
void EventRewriter::DidProcessEvent(const base::NativeEvent& event) {
}
+void EventRewriter::DeviceHierarchyChanged() {}
+
void EventRewriter::DeviceAdded(int device_id) {
DCHECK_NE(XIAllDevices, device_id);
DCHECK_NE(XIAllMasterDevices, device_id);
@@ -238,18 +258,6 @@ void EventRewriter::DeviceRemoved(int device_id) {
device_id_to_type_.erase(device_id);
}
-void EventRewriter::DeviceKeyPressedOrReleased(int device_id) {
- std::map<int, DeviceType>::const_iterator iter =
- device_id_to_type_.find(device_id);
- if (iter == device_id_to_type_.end()) {
- // |device_id| is unknown. This means the device was connected before
- // booting the OS. Query the name of the device and add it to the map.
- DeviceAdded(device_id);
- }
-
- last_device_id_ = device_id;
-}
-
void EventRewriter::RefreshKeycodes() {
keysym_to_keycode_map_.clear();
}

Powered by Google App Engine
This is Rietveld 408576698