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

Unified Diff: ui/events/test/events_test_utils_x11.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 (derat), the sequel. 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/test/events_test_utils_x11.cc
diff --git a/ui/events/test/events_test_utils_x11.cc b/ui/events/test/events_test_utils_x11.cc
index 40d5d4a0dbb0274349f328c4309b811ec2a06af7..6e644c90f5d24b28328dca0d27c54dc1a452363b 100644
--- a/ui/events/test/events_test_utils_x11.cc
+++ b/ui/events/test/events_test_utils_x11.cc
@@ -45,6 +45,18 @@ int XKeyEventType(ui::EventType type) {
}
}
+// Converts EventType to XI2 event type.
+int XIKeyEventType(ui::EventType type) {
+ switch (type) {
+ case ui::ET_KEY_PRESSED:
+ return XI_KeyPress;
+ case ui::ET_KEY_RELEASED:
+ return XI_KeyRelease;
+ default:
+ return 0;
+ }
+}
+
int XIButtonEventType(ui::EventType type) {
switch (type) {
case ui::ET_MOUSEWHEEL:
@@ -170,6 +182,21 @@ void ScopedXI2Event::InitKeyEvent(EventType type,
event_->xkey.same_screen = 1;
}
+void ScopedXI2Event::InitGenericKeyEvent(int deviceid,
+ EventType type,
+ KeyboardCode key_code,
+ int flags) {
+ event_.reset(
+ CreateXInput2Event(deviceid, XIKeyEventType(type), 0, gfx::Point()));
+ XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event_->xcookie.data);
+ CHECK_NE(0, xievent->evtype);
+ XDisplay* display = gfx::GetXDisplay();
+ event_->xgeneric.display = display;
+ xievent->display = display;
+ xievent->mods.effective = XEventState(flags);
+ xievent->detail = XKeyEventKeyCode(key_code, flags, display);
+}
+
void ScopedXI2Event::InitGenericButtonEvent(int deviceid,
EventType type,
const gfx::Point& location,

Powered by Google App Engine
This is Rietveld 408576698