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 <xkbcommon/xkbcommon-names.h> | 7 #include <xkbcommon/xkbcommon-names.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 *dom_key = NonPrintableXkbKeySymToDomKey(xkb_keysym); | 768 *dom_key = NonPrintableXkbKeySymToDomKey(xkb_keysym); |
769 if (*dom_key == DomKey::NONE) { | 769 if (*dom_key == DomKey::NONE) { |
770 *dom_key = CharacterToDomKey(*character); | 770 *dom_key = CharacterToDomKey(*character); |
771 *key_code = AlphanumericKeyboardCode(*character); | 771 *key_code = AlphanumericKeyboardCode(*character); |
772 if (*key_code == VKEY_UNKNOWN) { | 772 if (*key_code == VKEY_UNKNOWN) { |
773 *key_code = DifficultKeyboardCode(dom_code, flags, xkb_keycode, xkb_flags, | 773 *key_code = DifficultKeyboardCode(dom_code, flags, xkb_keycode, xkb_flags, |
774 xkb_keysym, *dom_key, *character); | 774 xkb_keysym, *dom_key, *character); |
775 if (*key_code == VKEY_UNKNOWN) | 775 if (*key_code == VKEY_UNKNOWN) |
776 *key_code = DomCodeToUsLayoutKeyboardCode(dom_code); | 776 *key_code = DomCodeToUsLayoutKeyboardCode(dom_code); |
777 } | 777 } |
778 | 778 // If the Control key is down, only allow ASCII control characters to be |
779 if ((flags & EF_CONTROL_DOWN) == EF_CONTROL_DOWN) { | 779 // returned, regardless of the key layout. crbug.com/450849 |
780 // Use GetCharacterFromKeyCode() to set |character| to 0x0 for keys that | 780 if ((flags & EF_CONTROL_DOWN) && (*character >= 0x20)) |
781 // are not part of the accepted set of Control+Key combinations. | 781 *character = 0; |
782 *character = GetCharacterFromKeyCode(*key_code, flags); | |
783 } | |
784 } else if (*dom_key == DomKey::DEAD) { | 782 } else if (*dom_key == DomKey::DEAD) { |
785 *character = DeadXkbKeySymToCombiningCharacter(xkb_keysym); | 783 *character = DeadXkbKeySymToCombiningCharacter(xkb_keysym); |
786 *key_code = DomCodeToUsLayoutKeyboardCode(dom_code); | 784 *key_code = DomCodeToUsLayoutKeyboardCode(dom_code); |
787 } else { | 785 } else { |
788 *key_code = NonPrintableDomKeyToKeyboardCode(*dom_key); | 786 *key_code = NonPrintableDomKeyToKeyboardCode(*dom_key); |
789 if (*key_code == VKEY_UNKNOWN) | 787 if (*key_code == VKEY_UNKNOWN) |
790 *key_code = DomCodeToUsLayoutKeyboardCode(dom_code); | 788 *key_code = DomCodeToUsLayoutKeyboardCode(dom_code); |
791 } | 789 } |
792 return true; | 790 return true; |
793 } | 791 } |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 close_index = layout_name.size(); | 955 close_index = layout_name.size(); |
958 *layout_variant = layout_name.substr(parentheses_index + 1, | 956 *layout_variant = layout_name.substr(parentheses_index + 1, |
959 close_index - parentheses_index - 1); | 957 close_index - parentheses_index - 1); |
960 } else if (dash_index != std::string::npos) { | 958 } else if (dash_index != std::string::npos) { |
961 *layout_id = layout_name.substr(0, dash_index); | 959 *layout_id = layout_name.substr(0, dash_index); |
962 *layout_variant = layout_name.substr(dash_index + 1); | 960 *layout_variant = layout_name.substr(dash_index + 1); |
963 } | 961 } |
964 } | 962 } |
965 | 963 |
966 } // namespace ui | 964 } // namespace ui |
OLD | NEW |