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