| 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 #ifndef UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ | 5 #ifndef UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ |
| 6 #define UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ | 6 #define UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ |
| 7 | 7 |
| 8 #include <xkbcommon/xkbcommon.h> | 8 #include <xkbcommon/xkbcommon.h> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 virtual bool UsesISOLevel5Shift() const override; | 30 virtual bool UsesISOLevel5Shift() const override; |
| 31 virtual bool UsesAltGr() const override; | 31 virtual bool UsesAltGr() const override; |
| 32 | 32 |
| 33 virtual bool Lookup(DomCode dom_code, | 33 virtual bool Lookup(DomCode dom_code, |
| 34 int flags, | 34 int flags, |
| 35 DomKey* dom_key, | 35 DomKey* dom_key, |
| 36 base::char16* character, | 36 base::char16* character, |
| 37 KeyboardCode* key_code) const override; | 37 KeyboardCode* key_code) const override; |
| 38 | 38 |
| 39 protected: |
| 40 // Table for EventFlagsToXkbFlags(). |
| 41 struct XkbFlagMapEntry { |
| 42 int ui_flag; |
| 43 xkb_mod_mask_t xkb_flag; |
| 44 }; |
| 45 std::vector<XkbFlagMapEntry> xkb_flag_map_; |
| 46 |
| 47 // Determines the Windows-based KeyboardCode (VKEY) for a character key, |
| 48 // accounting for non-US layouts. May return VKEY_UNKNOWN, in which case the |
| 49 // caller should use |DomCodeToNonLocatedKeyboardCode()| as a last resort. |
| 50 KeyboardCode DifficultKeyboardCode(DomCode dom_code, |
| 51 int ui_flags, |
| 52 xkb_keycode_t xkb_keycode, |
| 53 xkb_mod_mask_t xkb_flags, |
| 54 xkb_keysym_t xkb_keysym, |
| 55 DomKey dom_key, |
| 56 base::char16 character) const; |
| 57 |
| 58 // Maps DomCode to xkb_keycode_t. |
| 59 const XkbKeyCodeConverter& key_code_converter_; |
| 60 |
| 39 private: | 61 private: |
| 40 // Sets a new XKB keymap, updating object fields. | 62 // Sets a new XKB keymap, updating object fields. |
| 41 void SetKeymap(xkb_keymap* keymap); | 63 void SetKeymap(xkb_keymap* keymap); |
| 42 | 64 |
| 43 // Returns the XKB modifiers flags corresponding to the given EventFlags. | 65 // Returns the XKB modifiers flags corresponding to the given EventFlags. |
| 44 xkb_mod_mask_t EventFlagsToXkbFlags(int ui_flags) const; | 66 xkb_mod_mask_t EventFlagsToXkbFlags(int ui_flags) const; |
| 45 | 67 |
| 46 // Determines the XKB KeySym and character associated with a key. | 68 // Determines the XKB KeySym and character associated with a key. |
| 47 // Returns true on success. | 69 // Returns true on success. This is virtual for testing. |
| 48 bool XkbLookup(xkb_keycode_t xkb_keycode, | 70 virtual bool XkbLookup(xkb_keycode_t xkb_keycode, |
| 49 xkb_mod_mask_t xkb_flags, | 71 xkb_mod_mask_t xkb_flags, |
| 50 xkb_keysym_t* xkb_keysym, | 72 xkb_keysym_t* xkb_keysym, |
| 51 base::char16* character) const; | 73 base::char16* character) const; |
| 52 | 74 |
| 53 // Maps DomCode to xkb_keycode_t. | 75 // Helper for difficult VKEY lookup. If |ui_flags| matches |base_flags|, |
| 54 const XkbKeyCodeConverter& key_code_converter_; | 76 // returns |base_character|; otherwise returns the XKB character for |
| 77 // the keycode and mapped |ui_flags|. |
| 78 base::char16 XkbSubCharacter(xkb_keycode_t xkb_keycode, |
| 79 xkb_mod_mask_t base_flags, |
| 80 base::char16 base_character, |
| 81 int ui_flags) const; |
| 55 | 82 |
| 56 // libxkbcommon uses explicit reference counting for its structures, | 83 // libxkbcommon uses explicit reference counting for its structures, |
| 57 // so we need to trigger its cleanup. | 84 // so we need to trigger its cleanup. |
| 58 scoped_ptr<xkb_context, XkbContextDeleter> xkb_context_; | 85 scoped_ptr<xkb_context, XkbContextDeleter> xkb_context_; |
| 59 scoped_ptr<xkb_state, XkbStateDeleter> xkb_state_; | 86 scoped_ptr<xkb_state, XkbStateDeleter> xkb_state_; |
| 60 | |
| 61 // Table for EventFlagsToXkbFlags(). | |
| 62 struct XkbFlagMapEntry { | |
| 63 int ui_flag; | |
| 64 xkb_mod_mask_t xkb_flag; | |
| 65 }; | |
| 66 std::vector<XkbFlagMapEntry> xkb_flag_map_; | |
| 67 }; | 87 }; |
| 68 | 88 |
| 69 } // namespace ui | 89 } // namespace ui |
| 70 | 90 |
| 71 #endif // UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ | 91 #endif // UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ |
| OLD | NEW |