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

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 (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/test/events_test_utils_x11.h ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 622684de93659fb66ce43839710710d1ccacb721..40755c71385488ed2581719ede8d4c045d2f01dd 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:
@@ -169,6 +181,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,
« no previous file with comments | « ui/events/test/events_test_utils_x11.h ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698