Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h

Issue 778503002: XKB implementation of Ozone key layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@x430194-layout
Patch Set: USE_X11 ate my brain Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
16 namespace ui {
17
18 class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyCodeConverter {
spang 2014/12/08 22:47:29 move to separate header
kpschoedel 2014/12/15 19:48:46 Done.
19 public:
20 XkbKeyCodeConverter();
21 virtual ~XkbKeyCodeConverter();
22 xkb_keycode_t InvalidXkbKeyCode() const { return invalid_xkb_keycode_; }
23 virtual xkb_keycode_t DomCodeToXkbKeyCode(DomCode dom_code) const = 0;
24
25 protected:
26 xkb_keycode_t invalid_xkb_keycode_;
27 };
28
29 class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
30 : public KeyboardLayoutEngine {
31 public:
32 XkbKeyboardLayoutEngine(const XkbKeyCodeConverter& converter);
33 virtual ~XkbKeyboardLayoutEngine();
34
35 // KeyboardLayoutEngine:
36 virtual bool CanSetCurrentLayout() const override;
37 virtual bool SetCurrentLayoutByName(const std::string& layout_name) override;
38
39 virtual bool UsesISOLevel5Shift() const override;
40 virtual bool UsesAltGr() const override;
41
42 virtual bool Lookup(DomCode dom_code,
43 int flags,
44 DomKey* dom_key,
45 base::char16* character,
46 KeyboardCode* key_code) const override;
47
48 private:
49 // Sets a new XKB keymap, updating object fields.
50 void SetKeymap(xkb_keymap* keymap);
51
52 // Returns the XKB modifiers flags corresponding to the given EventFlags.
53 xkb_mod_mask_t EventFlagsToXkbFlags(int ui_flags) const;
54
55 // Determines the XKB KeySym and character associated with a key.
56 // Returns true on success.
57 bool XkbLookup(xkb_keycode_t xkb_keycode,
58 xkb_mod_mask_t xkb_flags,
59 xkb_keysym_t* xkb_keysym,
60 base::char16* character) const;
61
62 // Maps DomCode to xkb_keycode_t.
63 const XkbKeyCodeConverter& key_code_converter_;
64
65 // libxkbcommon uses explicit reference counting for its structures,
spang 2014/12/08 22:47:29 Can you move these general-purpose typedefs to a n
kpschoedel 2014/12/15 19:48:46 OK, though I wouldn't call them general-purpose —
66 // so we need to trigger its cleanup.
67 struct XkbContextDeleter {
68 void operator()(xkb_context* context) { xkb_context_unref(context); }
69 };
70 scoped_ptr<xkb_context, XkbContextDeleter> xkb_context_;
71 struct XkbstateDeleter {
72 void operator()(xkb_state* state) { xkb_state_unref(state); }
73 };
74 scoped_ptr<xkb_state, XkbstateDeleter> xkb_state_;
75
76 // Table for EventFlagsToXkbFlags().
77 struct XkbFlagMapEntry {
78 int ui_flag;
79 xkb_mod_mask_t xkb_flag;
80 };
81 std::vector<XkbFlagMapEntry> xkb_flag_map_;
82 };
83
84 } // namespace ui
85
86 #endif // UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698