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

Unified Diff: ui/events/x/events_x.cc

Issue 397803007: Support XI2 in PlatformKeycodeFromNative() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments (sadrul) 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/x/events_x.cc
diff --git a/ui/events/x/events_x.cc b/ui/events/x/events_x.cc
index 03b7e28d8de9704453e90d7dde5a6e126667863b..b9e969150fe49d14d541916236b2a651493e65e7 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -579,8 +579,35 @@ const char* CodeFromNative(const base::NativeEvent& native_event) {
}
uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) {
- KeySym keysym;
- XLookupString(&native_event->xkey, NULL, 0, &keysym, NULL);
+ XKeyEvent* xkey = NULL;
+ XEvent xkey_from_xi2;
+ switch (native_event->type) {
+ case KeyPress:
+ case KeyRelease:
+ xkey = &native_event->xkey;
+ break;
+ case GenericEvent: {
+ XIDeviceEvent* xievent =
+ static_cast<XIDeviceEvent*>(native_event->xcookie.data);
+ switch (xievent->evtype) {
+ case XI_KeyPress:
+ case XI_KeyRelease:
+ // Build an XKeyEvent corresponding to the XI2 event,
+ // so that we can call XLookupString on it.
+ InitXKeyEventFromXIDeviceEvent(*native_event, &xkey_from_xi2);
+ xkey = &xkey_from_xi2.xkey;
sadrul 2014/07/17 17:09:14 You are missing a break; here.
kpschoedel 2014/07/17 17:12:30 Thanks for catching that.
+ default:
+ NOTREACHED();
+ break;
+ }
+ }
+ default:
+ NOTREACHED();
+ break;
+ }
+ KeySym keysym = XK_VoidSymbol;
+ if (xkey)
+ XLookupString(xkey, NULL, 0, &keysym, NULL);
return keysym;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698