OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ |
| 6 #define UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ |
| 7 |
| 8 #include <xkbcommon/xkbcommon.h> |
| 9 |
| 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/strings/string16.h" |
| 13 #include "ui/events/ozone/layout/events_ozone_layout_export.h" |
| 14 #include "ui/events/ozone/layout/keyboard_layout_engine.h" |
| 15 #include "ui/events/ozone/layout/xkb/scoped_xkb.h" |
| 16 #include "ui/events/ozone/layout/xkb/xkb_key_code_converter.h" |
| 17 |
| 18 namespace ui { |
| 19 |
| 20 class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine |
| 21 : public KeyboardLayoutEngine { |
| 22 public: |
| 23 XkbKeyboardLayoutEngine(const XkbKeyCodeConverter& converter); |
| 24 virtual ~XkbKeyboardLayoutEngine(); |
| 25 |
| 26 // KeyboardLayoutEngine: |
| 27 virtual bool CanSetCurrentLayout() const override; |
| 28 virtual bool SetCurrentLayoutByName(const std::string& layout_name) override; |
| 29 |
| 30 virtual bool UsesISOLevel5Shift() const override; |
| 31 virtual bool UsesAltGr() const override; |
| 32 |
| 33 virtual bool Lookup(DomCode dom_code, |
| 34 int flags, |
| 35 DomKey* dom_key, |
| 36 base::char16* character, |
| 37 KeyboardCode* key_code) const override; |
| 38 |
| 39 private: |
| 40 // Sets a new XKB keymap, updating object fields. |
| 41 void SetKeymap(xkb_keymap* keymap); |
| 42 |
| 43 // Returns the XKB modifiers flags corresponding to the given EventFlags. |
| 44 xkb_mod_mask_t EventFlagsToXkbFlags(int ui_flags) const; |
| 45 |
| 46 // Determines the XKB KeySym and character associated with a key. |
| 47 // Returns true on success. |
| 48 bool XkbLookup(xkb_keycode_t xkb_keycode, |
| 49 xkb_mod_mask_t xkb_flags, |
| 50 xkb_keysym_t* xkb_keysym, |
| 51 base::char16* character) const; |
| 52 |
| 53 // Maps DomCode to xkb_keycode_t. |
| 54 const XkbKeyCodeConverter& key_code_converter_; |
| 55 |
| 56 // libxkbcommon uses explicit reference counting for its structures, |
| 57 // so we need to trigger its cleanup. |
| 58 scoped_ptr<xkb_context, XkbContextDeleter> xkb_context_; |
| 59 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 }; |
| 68 |
| 69 } // namespace ui |
| 70 |
| 71 #endif // UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_ |
OLD | NEW |