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 <map> |
8 #include <xkbcommon/xkbcommon.h> | 9 #include <xkbcommon/xkbcommon.h> |
9 | 10 |
10 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
13 #include "ui/events/ozone/layout/events_ozone_layout_export.h" | 15 #include "ui/events/ozone/layout/events_ozone_layout_export.h" |
14 #include "ui/events/ozone/layout/keyboard_layout_engine.h" | 16 #include "ui/events/ozone/layout/keyboard_layout_engine.h" |
15 #include "ui/events/ozone/layout/xkb/scoped_xkb.h" | 17 #include "ui/events/ozone/layout/xkb/scoped_xkb.h" |
16 #include "ui/events/ozone/layout/xkb/xkb_key_code_converter.h" | 18 #include "ui/events/ozone/layout/xkb/xkb_key_code_converter.h" |
17 | 19 |
18 namespace ui { | 20 namespace ui { |
19 | 21 |
20 class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine | 22 class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // the keycode and mapped |ui_flags|. | 81 // the keycode and mapped |ui_flags|. |
80 base::char16 XkbSubCharacter(xkb_keycode_t xkb_keycode, | 82 base::char16 XkbSubCharacter(xkb_keycode_t xkb_keycode, |
81 xkb_mod_mask_t base_flags, | 83 xkb_mod_mask_t base_flags, |
82 base::char16 base_character, | 84 base::char16 base_character, |
83 int ui_flags) const; | 85 int ui_flags) const; |
84 | 86 |
85 // libxkbcommon uses explicit reference counting for its structures, | 87 // libxkbcommon uses explicit reference counting for its structures, |
86 // so we need to trigger its cleanup. | 88 // so we need to trigger its cleanup. |
87 scoped_ptr<xkb_context, XkbContextDeleter> xkb_context_; | 89 scoped_ptr<xkb_context, XkbContextDeleter> xkb_context_; |
88 scoped_ptr<xkb_state, XkbStateDeleter> xkb_state_; | 90 scoped_ptr<xkb_state, XkbStateDeleter> xkb_state_; |
| 91 std::map<std::string, xkb_keymap*> xkb_keymaps_; |
| 92 |
| 93 // The class is used to load keymap files. |
| 94 class XkbKeymapLoader : public base::RefCountedThreadSafe<XkbKeymapLoader> { |
| 95 public: |
| 96 explicit XkbKeymapLoader(XkbKeyboardLayoutEngine* layout_engine); |
| 97 void loadKeymap(const std::string& layout_name); |
| 98 |
| 99 private: |
| 100 friend class base::RefCountedThreadSafe<XkbKeymapLoader>; |
| 101 ~XkbKeymapLoader() {} |
| 102 XkbKeyboardLayoutEngine* layout_engine_; |
| 103 struct xkb_rule_names* names; |
| 104 // Uses xkb_keymap_new_from_names from libxkbcommon to load keymap file, |
| 105 // And pushes this keymap file load into FILE thread. |
| 106 void startLoadKeymap(const std::string& layout_name, |
| 107 xkb_rule_names* names); |
| 108 }; |
89 }; | 109 }; |
90 | 110 |
91 } // namespace ui | 111 } // namespace ui |
92 | 112 |
93 #endif // UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ | 113 #endif // UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ |
OLD | NEW |