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

Unified Diff: ui/events/keycodes/keyboard_code_conversion_x.cc

Issue 2474083002: [DomKey X11] Produce correct DomKey when Control is down (Closed)
Patch Set: dtapuska's review: Move #if block Created 4 years, 1 month 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/keycodes/keyboard_code_conversion_x.cc
diff --git a/ui/events/keycodes/keyboard_code_conversion_x.cc b/ui/events/keycodes/keyboard_code_conversion_x.cc
index dfac6ed4e44ca917e68bd39fb1d3a2fa0b4f1e9d..c6f2bfeb40fac90165fcb5bcb36698b478da9a1b 100644
--- a/ui/events/keycodes/keyboard_code_conversion_x.cc
+++ b/ui/events/keycodes/keyboard_code_conversion_x.cc
@@ -904,17 +904,27 @@ uint16_t GetCharacterFromXEvent(const XEvent* xev) {
DomKey GetDomKeyFromXEvent(const XEvent* xev) {
XEvent xkeyevent = {0};
- const XKeyEvent* xkey = NULL;
+ XKeyEvent xkey;
if (xev->type == GenericEvent) {
// Convert the XI2 key event into a core key event so that we can
// continue to use XLookupString() until crbug.com/367732 is complete.
InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent);
- xkey = &xkeyevent.xkey;
+ xkey = xkeyevent.xkey;
} else {
- xkey = &xev->xkey;
+ xkey = xev->xkey;
}
+ // There is no good way to check whether a key combination will print a
+ // character on screen.
+ // e.g. On Linux US keyboard with French layout, |XLookupString()|
+ // * Returns '?' for ctrl-shift-/
+ // * Returns '§' for shift-/
+ // According to spec the DomKey for ctrl-shift-/ should also be '§'.
+ // The solution is to take out ctrl modifier directly, as according to XKB map
+ // no keyboard combinations with ctrl key are mapped to printable character.
+ // https://crbug.com/633838
+ xkey.state &= ~ControlMask;
KeySym keysym = XK_VoidSymbol;
- XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL);
+ XLookupString(&xkey, NULL, 0, &keysym, NULL);
base::char16 ch = GetUnicodeCharacterFromXKeySym(keysym);
return XKeySymToDomKey(keysym, ch);
}
« third_party/WebKit/Source/core/editing/EditingBehavior.cpp ('K') | « ui/events/event.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698