| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 5 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #define XK_3270 // for XK_3270_BackTab | 9 #define XK_3270 // for XK_3270_BackTab |
| 10 #include <X11/XF86keysym.h> | 10 #include <X11/XF86keysym.h> |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent); | 893 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent); |
| 894 xkey = &xkeyevent.xkey; | 894 xkey = &xkeyevent.xkey; |
| 895 } else { | 895 } else { |
| 896 xkey = &xev->xkey; | 896 xkey = &xev->xkey; |
| 897 } | 897 } |
| 898 KeySym keysym = XK_VoidSymbol; | 898 KeySym keysym = XK_VoidSymbol; |
| 899 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL); | 899 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL); |
| 900 return GetUnicodeCharacterFromXKeySym(keysym); | 900 return GetUnicodeCharacterFromXKeySym(keysym); |
| 901 } | 901 } |
| 902 | 902 |
| 903 void GetMeaningFromXEvent(const XEvent* xev, DomKey* key, base::char16* ch) { | 903 DomKey GetDomKeyFromXEvent(const XEvent* xev) { |
| 904 XEvent xkeyevent = {0}; | 904 XEvent xkeyevent = {0}; |
| 905 const XKeyEvent* xkey = NULL; | 905 const XKeyEvent* xkey = NULL; |
| 906 if (xev->type == GenericEvent) { | 906 if (xev->type == GenericEvent) { |
| 907 // Convert the XI2 key event into a core key event so that we can | 907 // Convert the XI2 key event into a core key event so that we can |
| 908 // continue to use XLookupString() until crbug.com/367732 is complete. | 908 // continue to use XLookupString() until crbug.com/367732 is complete. |
| 909 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent); | 909 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent); |
| 910 xkey = &xkeyevent.xkey; | 910 xkey = &xkeyevent.xkey; |
| 911 } else { | 911 } else { |
| 912 xkey = &xev->xkey; | 912 xkey = &xev->xkey; |
| 913 } | 913 } |
| 914 KeySym keysym = XK_VoidSymbol; | 914 KeySym keysym = XK_VoidSymbol; |
| 915 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL); | 915 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL); |
| 916 *ch = GetUnicodeCharacterFromXKeySym(keysym); | 916 base::char16 ch = GetUnicodeCharacterFromXKeySym(keysym); |
| 917 *key = XKeySymToDomKey(keysym, *ch); | 917 return XKeySymToDomKey(keysym, ch); |
| 918 } | 918 } |
| 919 | 919 |
| 920 KeyboardCode DefaultKeyboardCodeFromHardwareKeycode( | 920 KeyboardCode DefaultKeyboardCodeFromHardwareKeycode( |
| 921 unsigned int hardware_code) { | 921 unsigned int hardware_code) { |
| 922 // This function assumes that X11 is using evdev-based keycodes. | 922 // This function assumes that X11 is using evdev-based keycodes. |
| 923 static const KeyboardCode kHardwareKeycodeMap[] = { | 923 static const KeyboardCode kHardwareKeycodeMap[] = { |
| 924 // Please refer to below links for the table content: | 924 // Please refer to below links for the table content: |
| 925 // http://www.w3.org/TR/DOM-Level-3-Events-code/#keyboard-101 | 925 // http://www.w3.org/TR/DOM-Level-3-Events-code/#keyboard-101 |
| 926 // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode | 926 // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode |
| 927 // http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-92
3143f3456c/translate.pdf | 927 // http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-92
3143f3456c/translate.pdf |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 // alone does not map to XK_less; XKeysymToKeycode() returns KEY_102ND | 1402 // alone does not map to XK_less; XKeysymToKeycode() returns KEY_102ND |
| 1403 // (the '<>' key between Shift and Z on 105-key keyboards) which does. | 1403 // (the '<>' key between Shift and Z on 105-key keyboards) which does. |
| 1404 // | 1404 // |
| 1405 // crbug.com/386066 and crbug.com/390263 are examples of problems | 1405 // crbug.com/386066 and crbug.com/390263 are examples of problems |
| 1406 // associated with this. | 1406 // associated with this. |
| 1407 // | 1407 // |
| 1408 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false)); | 1408 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false)); |
| 1409 } | 1409 } |
| 1410 | 1410 |
| 1411 } // namespace ui | 1411 } // namespace ui |
| OLD | NEW |