Upstream version 11.39.252.0
[platform/framework/web/crosswalk.git] / src / ozone / ui / events / keyboard_engine_xkb.h
1 // Copyright 2013 Intel Corporation. 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 OZONE_UI_EVENTS_INPUT_KEYBOARD_ENGINE_XKB_H_
6 #define OZONE_UI_EVENTS_INPUT_KEYBOARD_ENGINE_XKB_H_
7
8 #include <xkbcommon/xkbcommon.h>
9
10 #include "base/basictypes.h"
11
12 namespace ui {
13
14 class KeyboardEngineXKB {
15  public:
16   KeyboardEngineXKB();
17   ~KeyboardEngineXKB();
18
19   void OnKeyboardKeymap(int fd, uint32_t size);
20   void OnKeyModifiers(uint32_t mods_depressed,
21                       uint32_t mods_latched,
22                       uint32_t mods_locked,
23                       uint32_t group);
24   unsigned ConvertKeyCodeFromEvdev(unsigned hardwarecode);
25
26   uint32_t GetKeyBoardModifiers() const { return keyboard_modifiers_; }
27
28  private:
29   void InitXKB();
30   void FiniXKB();
31   bool IsOnlyCapsLocked() const;
32   void NormalizeKey();
33
34   // Keeps track of the currently active keyboard modifiers. We keep this
35   // since we want to advertise keyboard modifiers with mouse events.
36   uint32_t keyboard_modifiers_;
37   uint32_t mods_depressed_;
38   uint32_t mods_latched_;
39   uint32_t mods_locked_;
40   uint32_t group_;
41   int last_key_;
42   uint32_t last_modifiers_;
43   xkb_keysym_t cached_sym_;
44
45   // keymap used to transform keyboard events.
46   struct xkb_keymap *keymap_;
47   struct xkb_state *state_;
48   struct xkb_context *context_;
49
50   DISALLOW_COPY_AND_ASSIGN(KeyboardEngineXKB);
51 };
52
53 }  // namespace ui
54
55 #endif  // OZONE_UI_EVENTS_INPUT_KEYBOARD_ENGINE_XKB_H_