| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |