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

Side by Side Diff: ui/events/keycodes/keyboard_code_conversion_x.cc

Issue 1103263004: Set ui::KeyEvent::key_ (DOM Level 3 key) under X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments (wez@) Created 5 years, 7 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 unified diff | Download patch
OLDNEW
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>
11 #include <X11/Xlib.h> 11 #include <X11/Xlib.h>
12 #include <X11/Xutil.h> 12 #include <X11/Xutil.h>
13 #include <X11/extensions/XInput2.h> 13 #include <X11/extensions/XInput2.h>
14 #include <X11/keysym.h> 14 #include <X11/keysym.h>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/sys_string_conversions.h" 19 #include "base/strings/sys_string_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "ui/events/keycodes/dom4/keycode_converter.h" 21 #include "ui/events/keycodes/dom4/keycode_converter.h"
22 #include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
22 #include "ui/events/x/keysym_to_unicode.h" 23 #include "ui/events/x/keysym_to_unicode.h"
23 24
24 #define VKEY_UNSUPPORTED VKEY_UNKNOWN 25 #define VKEY_UNSUPPORTED VKEY_UNKNOWN
25 26
26 namespace ui { 27 namespace ui {
27 28
28 namespace { 29 namespace {
29 30
30 // MAP0 - MAP3: 31 // MAP0 - MAP3:
31 // These are the generated VKEY code maps for all possible Latin keyboard 32 // These are the generated VKEY code maps for all possible Latin keyboard
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent); 893 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent);
893 xkey = &xkeyevent.xkey; 894 xkey = &xkeyevent.xkey;
894 } else { 895 } else {
895 xkey = &xev->xkey; 896 xkey = &xev->xkey;
896 } 897 }
897 KeySym keysym = XK_VoidSymbol; 898 KeySym keysym = XK_VoidSymbol;
898 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL); 899 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL);
899 return GetUnicodeCharacterFromXKeySym(keysym); 900 return GetUnicodeCharacterFromXKeySym(keysym);
900 } 901 }
901 902
903 void GetMeaningFromXEvent(const XEvent* xev, DomKey* key, base::char16* ch) {
904 XEvent xkeyevent = {0};
905 const XKeyEvent* xkey = NULL;
906 if (xev->type == GenericEvent) {
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.
909 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent);
910 xkey = &xkeyevent.xkey;
911 } else {
912 xkey = &xev->xkey;
913 }
914 KeySym keysym = XK_VoidSymbol;
915 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL);
916 *ch = GetUnicodeCharacterFromXKeySym(keysym);
917 *key = XKeySymToDomKey(keysym, *ch);
918 }
919
902 KeyboardCode DefaultKeyboardCodeFromHardwareKeycode( 920 KeyboardCode DefaultKeyboardCodeFromHardwareKeycode(
903 unsigned int hardware_code) { 921 unsigned int hardware_code) {
904 // This function assumes that X11 is using evdev-based keycodes. 922 // This function assumes that X11 is using evdev-based keycodes.
905 static const KeyboardCode kHardwareKeycodeMap[] = { 923 static const KeyboardCode kHardwareKeycodeMap[] = {
906 // Please refer to below links for the table content: 924 // Please refer to below links for the table content:
907 // 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
908 // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode 926 // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode
909 // 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
910 VKEY_UNKNOWN, // 0x00: 928 VKEY_UNKNOWN, // 0x00:
911 VKEY_UNKNOWN, // 0x01: 929 VKEY_UNKNOWN, // 0x01:
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 // alone does not map to XK_less; XKeysymToKeycode() returns KEY_102ND 1402 // alone does not map to XK_less; XKeysymToKeycode() returns KEY_102ND
1385 // (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.
1386 // 1404 //
1387 // crbug.com/386066 and crbug.com/390263 are examples of problems 1405 // crbug.com/386066 and crbug.com/390263 are examples of problems
1388 // associated with this. 1406 // associated with this.
1389 // 1407 //
1390 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false)); 1408 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false));
1391 } 1409 }
1392 1410
1393 } // namespace ui 1411 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698