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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "base/threading/worker_pool.h" | 15 #include "base/threading/worker_pool.h" |
16 #include "ui/events/event_constants.h" | 16 #include "ui/events/event_constants.h" |
17 #include "ui/events/keycodes/dom3/dom_code.h" | 17 #include "ui/events/keycodes/dom3/dom_code.h" |
18 #include "ui/events/keycodes/dom3/dom_key.h" | 18 #include "ui/events/keycodes/dom3/dom_key.h" |
19 #include "ui/events/keycodes/dom4/keycode_converter.h" | 19 #include "ui/events/keycodes/dom4/keycode_converter.h" |
20 #include "ui/events/keycodes/keyboard_code_conversion.h" | 20 #include "ui/events/keycodes/keyboard_code_conversion.h" |
21 #include "ui/events/keycodes/keyboard_code_conversion.h" | |
21 #include "ui/events/ozone/layout/layout_util.h" | 22 #include "ui/events/ozone/layout/layout_util.h" |
22 #include "ui/events/ozone/layout/xkb/xkb_keyboard_code_conversion.h" | 23 #include "ui/events/ozone/layout/xkb/xkb_keyboard_code_conversion.h" |
23 | 24 |
24 namespace ui { | 25 namespace ui { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 typedef base::Callback<void(const std::string&, | 29 typedef base::Callback<void(const std::string&, |
29 scoped_ptr<char, base::FreeDeleter>)> | 30 scoped_ptr<char, base::FreeDeleter>)> |
30 LoadKeymapCallback; | 31 LoadKeymapCallback; |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 *platform_keycode = xkb_keysym; | 767 *platform_keycode = xkb_keysym; |
767 // Classify the keysym and convert to DOM and VKEY representations. | 768 // Classify the keysym and convert to DOM and VKEY representations. |
768 *dom_key = NonPrintableXkbKeySymToDomKey(xkb_keysym); | 769 *dom_key = NonPrintableXkbKeySymToDomKey(xkb_keysym); |
769 if (*dom_key == DomKey::NONE) { | 770 if (*dom_key == DomKey::NONE) { |
770 *dom_key = CharacterToDomKey(*character); | 771 *dom_key = CharacterToDomKey(*character); |
771 *key_code = AlphanumericKeyboardCode(*character); | 772 *key_code = AlphanumericKeyboardCode(*character); |
772 if (*key_code == VKEY_UNKNOWN) { | 773 if (*key_code == VKEY_UNKNOWN) { |
773 *key_code = DifficultKeyboardCode(dom_code, flags, xkb_keycode, xkb_flags, | 774 *key_code = DifficultKeyboardCode(dom_code, flags, xkb_keycode, xkb_flags, |
774 xkb_keysym, *dom_key, *character); | 775 xkb_keysym, *dom_key, *character); |
775 if (*key_code == VKEY_UNKNOWN) | 776 if (*key_code == VKEY_UNKNOWN) |
776 *key_code = DomCodeToNonLocatedKeyboardCode(dom_code); | 777 *key_code = |
778 LocatedToNonLocatedKeyboardCode(DomCodeToKeyboardCode(dom_code)); | |
777 } | 779 } |
778 | 780 |
779 if ((flags & EF_CONTROL_DOWN) == EF_CONTROL_DOWN) { | 781 if ((flags & EF_CONTROL_DOWN) == EF_CONTROL_DOWN) { |
780 // Use GetCharacterFromKeyCode() to set |character| to 0x0 for key codes | 782 // Use GetCharacterFromKeyCode() to set |character| to 0x0 for key codes |
781 // that we do not care about. | 783 // that we do not care about. |
Wez
2015/02/19 23:16:09
This comment's a little confusing; you mean that i
kpschoedel
2015/04/10 18:32:34
Yes, it made sense while I reviewed it.... Regardl
| |
782 *character = GetCharacterFromKeyCode(*key_code, flags); | 784 *character = GetCharacterFromKeyCode(*key_code, flags); |
783 } | 785 } |
784 } else if (*dom_key == DomKey::DEAD) { | 786 } else if (*dom_key == DomKey::DEAD) { |
785 *character = DeadXkbKeySymToCombiningCharacter(xkb_keysym); | 787 *character = DeadXkbKeySymToCombiningCharacter(xkb_keysym); |
786 *key_code = DomCodeToNonLocatedKeyboardCode(dom_code); | 788 *key_code = |
789 LocatedToNonLocatedKeyboardCode(DomCodeToKeyboardCode(dom_code)); | |
787 } else { | 790 } else { |
788 *key_code = NonPrintableDomKeyToKeyboardCode(*dom_key); | 791 *key_code = NonPrintableDomKeyToKeyboardCode(*dom_key); |
789 if (*key_code == VKEY_UNKNOWN) | 792 if (*key_code == VKEY_UNKNOWN) |
790 *key_code = DomCodeToNonLocatedKeyboardCode(dom_code); | 793 *key_code = |
794 LocatedToNonLocatedKeyboardCode(DomCodeToKeyboardCode(dom_code)); | |
791 } | 795 } |
792 return true; | 796 return true; |
793 } | 797 } |
794 | 798 |
795 void XkbKeyboardLayoutEngine::SetKeymap(xkb_keymap* keymap) { | 799 void XkbKeyboardLayoutEngine::SetKeymap(xkb_keymap* keymap) { |
796 xkb_state_.reset(xkb_state_new(keymap)); | 800 xkb_state_.reset(xkb_state_new(keymap)); |
797 // Update flag map. | 801 // Update flag map. |
798 static const struct { | 802 static const struct { |
799 int ui_flag; | 803 int ui_flag; |
800 const char* xkb_name; | 804 const char* xkb_name; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 if (close_index == std::string::npos) | 960 if (close_index == std::string::npos) |
957 close_index = layout_name.size(); | 961 close_index = layout_name.size(); |
958 *layout_variant = layout_name.substr(parentheses_index + 1, | 962 *layout_variant = layout_name.substr(parentheses_index + 1, |
959 close_index - parentheses_index - 1); | 963 close_index - parentheses_index - 1); |
960 } else if (dash_index != std::string::npos) { | 964 } else if (dash_index != std::string::npos) { |
961 *layout_id = layout_name.substr(0, dash_index); | 965 *layout_id = layout_name.substr(0, dash_index); |
962 *layout_variant = layout_name.substr(dash_index + 1); | 966 *layout_variant = layout_name.substr(dash_index + 1); |
963 } | 967 } |
964 } | 968 } |
965 } // namespace ui | 969 } // namespace ui |
OLD | NEW |