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(); |
} |