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

Side by Side Diff: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc

Issue 2481413006: Checks the DomKey in the non-printable map to determine whether a key event is non-character. (Closed)
Patch Set: Checks the DomKey in the non-printable map to determine whether a key event is non-character. Created 4 years 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
« no previous file with comments | « no previous file | ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ozone/layout/xkb/xkb_keyboard_layout_engine.h" 5 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <xkbcommon/xkbcommon-names.h> 8 #include <xkbcommon/xkbcommon-names.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 return false; 745 return false;
746 } 746 }
747 xkb_mod_mask_t xkb_flags = EventFlagsToXkbFlags(flags); 747 xkb_mod_mask_t xkb_flags = EventFlagsToXkbFlags(flags);
748 // Obtain keysym and character. 748 // Obtain keysym and character.
749 xkb_keysym_t xkb_keysym; 749 xkb_keysym_t xkb_keysym;
750 uint32_t character = 0; 750 uint32_t character = 0;
751 if (!XkbLookup(xkb_keycode, xkb_flags, &xkb_keysym, &character)) 751 if (!XkbLookup(xkb_keycode, xkb_flags, &xkb_keysym, &character))
752 return false; 752 return false;
753 753
754 // Classify the keysym and convert to DOM and VKEY representations. 754 // Classify the keysym and convert to DOM and VKEY representations.
755 if ((character == 0) && 755 if (xkb_keysym != XKB_KEY_at || (flags & EF_CONTROL_DOWN) == 0) {
756 ((xkb_keysym != XKB_KEY_at) || (flags & EF_CONTROL_DOWN) == 0)) {
757 // Non-character key. (We only support NUL as ^@.) 756 // Non-character key. (We only support NUL as ^@.)
758 *dom_key = NonPrintableXKeySymToDomKey(xkb_keysym); 757 *dom_key = NonPrintableXKeySymToDomKey(xkb_keysym);
759 if (*dom_key == DomKey::NONE) { 758 if (*dom_key != DomKey::NONE) {
759 *key_code = NonPrintableDomKeyToKeyboardCode(*dom_key);
760 if (*key_code == VKEY_UNKNOWN)
761 *key_code = DomCodeToUsLayoutNonLocatedKeyboardCode(dom_code);
762 return true;
763 }
764 if (character == 0) {
760 *dom_key = DomKey::UNIDENTIFIED; 765 *dom_key = DomKey::UNIDENTIFIED;
761 *key_code = VKEY_UNKNOWN; 766 *key_code = DomCodeToUsLayoutNonLocatedKeyboardCode(dom_code);
762 } else { 767 return true;
763 *key_code = NonPrintableDomKeyToKeyboardCode(*dom_key);
764 } 768 }
765 if (*key_code == VKEY_UNKNOWN)
766 *key_code = DomCodeToUsLayoutNonLocatedKeyboardCode(dom_code);
767 return true;
768 } 769 }
769 770
770 // Per UI Events rules for determining |key|, if the character is 771 // Per UI Events rules for determining |key|, if the character is
771 // non-printable and a non-shiftlike modifier is down, we preferentially 772 // non-printable and a non-shiftlike modifier is down, we preferentially
772 // return a printable key as if the modifier were not down. 773 // return a printable key as if the modifier were not down.
773 // https://w3c.github.io/uievents/#keys-guidelines 774 // https://w3c.github.io/uievents/#keys-guidelines
774 const int kNonShiftlikeModifiers = 775 const int kNonShiftlikeModifiers =
775 EF_CONTROL_DOWN | EF_ALT_DOWN | EF_COMMAND_DOWN; 776 EF_CONTROL_DOWN | EF_ALT_DOWN | EF_COMMAND_DOWN;
776 if ((flags & kNonShiftlikeModifiers) && IsControlCharacter(character)) { 777 if ((flags & kNonShiftlikeModifiers) && IsControlCharacter(character)) {
777 int normal_ui_flags = flags & ~kNonShiftlikeModifiers; 778 int normal_ui_flags = flags & ~kNonShiftlikeModifiers;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 close_index = layout_name.size(); 971 close_index = layout_name.size();
971 *layout_variant = layout_name.substr(parentheses_index + 1, 972 *layout_variant = layout_name.substr(parentheses_index + 1,
972 close_index - parentheses_index - 1); 973 close_index - parentheses_index - 1);
973 } else if (dash_index != std::string::npos) { 974 } else if (dash_index != std::string::npos) {
974 *layout_id = layout_name.substr(0, dash_index); 975 *layout_id = layout_name.substr(0, dash_index);
975 *layout_variant = layout_name.substr(dash_index + 1); 976 *layout_variant = layout_name.substr(dash_index + 1);
976 } 977 }
977 } 978 }
978 979
979 } // namespace ui 980 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698