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

Side by Side 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 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } else { 897 } else {
898 xkey = &xev->xkey; 898 xkey = &xev->xkey;
899 } 899 }
900 KeySym keysym = XK_VoidSymbol; 900 KeySym keysym = XK_VoidSymbol;
901 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL); 901 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL);
902 return GetUnicodeCharacterFromXKeySym(keysym); 902 return GetUnicodeCharacterFromXKeySym(keysym);
903 } 903 }
904 904
905 DomKey GetDomKeyFromXEvent(const XEvent* xev) { 905 DomKey GetDomKeyFromXEvent(const XEvent* xev) {
906 XEvent xkeyevent = {0}; 906 XEvent xkeyevent = {0};
907 const XKeyEvent* xkey = NULL; 907 XKeyEvent xkey;
908 if (xev->type == GenericEvent) { 908 if (xev->type == GenericEvent) {
909 // Convert the XI2 key event into a core key event so that we can 909 // Convert the XI2 key event into a core key event so that we can
910 // continue to use XLookupString() until crbug.com/367732 is complete. 910 // continue to use XLookupString() until crbug.com/367732 is complete.
911 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent); 911 InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent);
912 xkey = &xkeyevent.xkey; 912 xkey = xkeyevent.xkey;
913 } else { 913 } else {
914 xkey = &xev->xkey; 914 xkey = xev->xkey;
915 } 915 }
916 // There is no good way to check whether a key combination will print a
917 // character on screen.
918 // e.g. On Linux US keyboard with French layout, |XLookupString()|
919 // * Returns '?' for ctrl-shift-/
920 // * Returns '§' for shift-/
921 // According to spec the DomKey for ctrl-shift-/ should also be '§'.
922 // The solution is to take out ctrl modifier directly, as according to XKB map
923 // no keyboard combinations with ctrl key are mapped to printable character.
924 // https://crbug.com/633838
925 xkey.state &= ~ControlMask;
916 KeySym keysym = XK_VoidSymbol; 926 KeySym keysym = XK_VoidSymbol;
917 XLookupString(const_cast<XKeyEvent*>(xkey), NULL, 0, &keysym, NULL); 927 XLookupString(&xkey, NULL, 0, &keysym, NULL);
918 base::char16 ch = GetUnicodeCharacterFromXKeySym(keysym); 928 base::char16 ch = GetUnicodeCharacterFromXKeySym(keysym);
919 return XKeySymToDomKey(keysym, ch); 929 return XKeySymToDomKey(keysym, ch);
920 } 930 }
921 931
922 KeyboardCode DefaultKeyboardCodeFromHardwareKeycode( 932 KeyboardCode DefaultKeyboardCodeFromHardwareKeycode(
923 unsigned int hardware_code) { 933 unsigned int hardware_code) {
924 // This function assumes that X11 is using evdev-based keycodes. 934 // This function assumes that X11 is using evdev-based keycodes.
925 static const KeyboardCode kHardwareKeycodeMap[] = { 935 static const KeyboardCode kHardwareKeycodeMap[] = {
926 // Please refer to below links for the table content: 936 // Please refer to below links for the table content:
927 // http://www.w3.org/TR/DOM-Level-3-Events-code/#keyboard-101 937 // http://www.w3.org/TR/DOM-Level-3-Events-code/#keyboard-101
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 // alone does not map to XK_less; XKeysymToKeycode() returns KEY_102ND 1414 // alone does not map to XK_less; XKeysymToKeycode() returns KEY_102ND
1405 // (the '<>' key between Shift and Z on 105-key keyboards) which does. 1415 // (the '<>' key between Shift and Z on 105-key keyboards) which does.
1406 // 1416 //
1407 // crbug.com/386066 and crbug.com/390263 are examples of problems 1417 // crbug.com/386066 and crbug.com/390263 are examples of problems
1408 // associated with this. 1418 // associated with this.
1409 // 1419 //
1410 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false)); 1420 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false));
1411 } 1421 }
1412 1422
1413 } // namespace ui 1423 } // namespace ui
OLDNEW
« 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