Chromium Code Reviews| 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 efbf1d427e47edd5b6e9071e8a3d9aff1f1d85c7..238e0ff3a682637f686a1b0c8cff05a8b60a0590 100644 |
| --- a/ui/events/keycodes/keyboard_code_conversion_x.cc |
| +++ b/ui/events/keycodes/keyboard_code_conversion_x.cc |
| @@ -19,6 +19,7 @@ |
| #include "base/strings/sys_string_conversions.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "ui/events/keycodes/dom4/keycode_converter.h" |
| +#include "ui/events/x/keysym_to_unicode.h" |
| #define VKEY_UNSUPPORTED VKEY_UNKNOWN |
| @@ -842,8 +843,7 @@ const char* CodeFromXEvent(const XEvent* xev) { |
| uint16 GetCharacterFromXEvent(const XEvent* xev) { |
| XEvent xkeyevent; |
| - const XKeyEvent* xkey = NULL; |
| - char buf[6]; |
| + const XKeyEvent* xkey; |
|
Wez
2014/08/08 22:56:25
nit: Style guide requires local variables be initi
Yuki
2014/08/11 05:58:52
Done.
|
| 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. |
| @@ -852,15 +852,9 @@ uint16 GetCharacterFromXEvent(const XEvent* xev) { |
| } else { |
| xkey = &xev->xkey; |
| } |
| - int bytes_written = |
| - XLookupString(const_cast<XKeyEvent*>(xkey), buf, 6, NULL, NULL); |
| - DCHECK_LE(bytes_written, 6); |
| - |
| - if (bytes_written <= 0) |
| - return 0; |
| - const base::string16& result = base::WideToUTF16( |
| - base::SysNativeMBToWide(base::StringPiece(buf, bytes_written))); |
| - return result.length() == 1 ? result[0] : 0; |
| + KeySym keysym = XK_VoidSymbol; |
| + XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL); |
| + return GetUnicodeCharacterFromXKeySym(keysym); |
| } |
| KeyboardCode DefaultKeyboardCodeFromHardwareKeycode( |