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

Unified Diff: ui/events/event.cc

Issue 336403005: Use XInput2 events for keyboard events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments (sadrul) 3 Created 6 years, 5 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
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event.cc
diff --git a/ui/events/event.cc b/ui/events/event.cc
index 7dc7fb1fe25a421227ddaa7a689d4d8a2cac1cd2..9170b0d0222ea56be7dc71543de6f0d728aa987b 100644
--- a/ui/events/event.cc
+++ b/ui/events/event.cc
@@ -147,7 +147,8 @@ Event::Event(EventType type, base::TimeDelta time_stamp, int flags)
cancelable_(true),
target_(NULL),
phase_(EP_PREDISPATCH),
- result_(ER_UNHANDLED) {
+ result_(ER_UNHANDLED),
+ source_device_id_(ED_UNKNOWN_DEVICE) {
if (type_ < ET_LAST)
name_ = EventTypeName(type_);
}
@@ -163,7 +164,8 @@ Event::Event(const base::NativeEvent& native_event,
cancelable_(true),
target_(NULL),
phase_(EP_PREDISPATCH),
- result_(ER_UNHANDLED) {
+ result_(ER_UNHANDLED),
+ source_device_id_(ED_UNKNOWN_DEVICE) {
base::TimeDelta delta = EventTimeForNow() - time_stamp_;
if (type_ < ET_LAST)
name_ = EventTypeName(type_);
@@ -179,6 +181,14 @@ Event::Event(const base::NativeEvent& native_event,
100,
base::HistogramBase::kUmaTargetedHistogramFlag);
counter_for_type->Add(delta.InMicroseconds());
+
+#if defined(USE_X11)
+ if (native_event->type == GenericEvent) {
+ XIDeviceEvent* xiev =
+ static_cast<XIDeviceEvent*>(native_event->xcookie.data);
+ source_device_id_ = xiev->deviceid;
+ }
+#endif
}
Event::Event(const Event& copy)
@@ -191,7 +201,8 @@ Event::Event(const Event& copy)
cancelable_(true),
target_(NULL),
phase_(EP_PREDISPATCH),
- result_(ER_UNHANDLED) {
+ result_(ER_UNHANDLED),
+ source_device_id_(copy.source_device_id_) {
if (type_ < ET_LAST)
name_ = EventTypeName(type_);
}
@@ -428,8 +439,7 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
radius_x_(GetTouchRadiusX(native_event)),
radius_y_(GetTouchRadiusY(native_event)),
rotation_angle_(GetTouchAngle(native_event)),
- force_(GetTouchForce(native_event)),
- source_device_id_(-1) {
+ force_(GetTouchForce(native_event)) {
latency()->AddLatencyNumberWithTimestamp(
INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
0,
@@ -437,11 +447,6 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
1);
-#if defined(USE_X11)
- XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(native_event->xcookie.data);
- source_device_id_ = xiev->deviceid;
-#endif
-
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
}
@@ -454,8 +459,7 @@ TouchEvent::TouchEvent(EventType type,
radius_x_(0.0f),
radius_y_(0.0f),
rotation_angle_(0.0f),
- force_(0.0f),
- source_device_id_(-1) {
+ force_(0.0f) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
}
@@ -473,8 +477,7 @@ TouchEvent::TouchEvent(EventType type,
radius_x_(radius_x),
radius_y_(radius_y),
rotation_angle_(angle),
- force_(force),
- source_device_id_(-1) {
+ force_(force) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
}
@@ -590,7 +593,10 @@ uint16 KeyEvent::GetCharacter() const {
return GetCharacterFromKeyCode(key_code_, flags());
DCHECK(native_event()->type == KeyPress ||
- native_event()->type == KeyRelease);
+ native_event()->type == KeyRelease ||
+ (native_event()->type == GenericEvent &&
+ (native_event()->xgeneric.evtype == XI_KeyPress ||
+ native_event()->xgeneric.evtype == XI_KeyRelease)));
// When a control key is held, prefer ASCII characters to non ASCII
// characters in order to use it for shortcut keys. GetCharacterFromKeyCode
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698