[M67 Dev][Tizen] Integrate GN and set up build environment
[platform/framework/web/chromium-efl.git] / ui / events / event_modifiers.h
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_EVENT_MODIFIERS_H_
6 #define UI_EVENTS_EVENT_MODIFIERS_H_
7
8 #include "base/macros.h"
9 #include "ui/events/events_export.h"
10
11 namespace ui {
12
13 enum {
14   MODIFIER_NONE,
15   MODIFIER_SHIFT,
16   MODIFIER_CONTROL,
17   MODIFIER_ALT,
18   MODIFIER_COMMAND,
19   MODIFIER_ALTGR,
20   MODIFIER_MOD3,
21   MODIFIER_CAPS_LOCK,
22   MODIFIER_LEFT_MOUSE_BUTTON,
23   MODIFIER_MIDDLE_MOUSE_BUTTON,
24   MODIFIER_RIGHT_MOUSE_BUTTON,
25   MODIFIER_BACK_MOUSE_BUTTON,
26   MODIFIER_FORWARD_MOUSE_BUTTON,
27   MODIFIER_NUM_MODIFIERS
28 };
29
30 // Modifier key state for Evdev.
31 //
32 // Chrome relies on the underlying OS to interpret modifier keys such as Shift,
33 // Ctrl, and Alt. The Linux input subsystem does not assign any special meaning
34 // to these keys, so this work must happen at a higher layer (normally X11 or
35 // the console driver). When using evdev directly, we must do it ourselves.
36 //
37 // The modifier state is shared between all input devices connected to the
38 // system. This is to support actions such as Shift-Clicking that use multiple
39 // devices.
40 //
41 // Normally a modifier is set if any of the keys or buttons assigned to it are
42 // currently pressed. However some keys toggle a persistent "lock" for the
43 // modifier instead, such as CapsLock. If a modifier is "locked" then its state
44 // is inverted until it is unlocked.
45 class EVENTS_EXPORT EventModifiers {
46  public:
47   EventModifiers();
48   ~EventModifiers();
49
50   // Record key press or release for regular modifier key (shift, alt, etc).
51   void UpdateModifier(unsigned int modifier, bool down);
52
53   // Record key press or release for locking modifier key (caps lock).
54   void UpdateModifierLock(unsigned int modifier, bool down);
55
56   // Directly set the state of a locking modifier key (caps lock).
57   void SetModifierLock(unsigned int modifier, bool locked);
58
59   // Return current flags to use for incoming events.
60   int GetModifierFlags();
61
62   // Release modifier keys.
63   void ResetKeyboardModifiers();
64
65   // Return the mask for the specified modifier.
66   static int GetEventFlagFromModifier(unsigned int modifier);
67
68   // Return the modifier for the specified mask.
69   static int GetModifierFromEventFlag(int flag);
70
71  private:
72   // Count of keys pressed for each modifier.
73   int modifiers_down_[MODIFIER_NUM_MODIFIERS];
74
75   // Mask of modifier flags currently "locked".
76   int modifier_flags_locked_ = 0;
77
78   // Mask of modifier flags currently active (nonzero keys pressed xor locked).
79   int modifier_flags_ = 0;
80
81   // Update modifier_flags_ from modifiers_down_ and modifier_flags_locked_.
82   void UpdateFlags(unsigned int modifier);
83
84   DISALLOW_COPY_AND_ASSIGN(EventModifiers);
85 };
86
87 }  // namespace ui
88
89 #endif  // UI_EVENTS_EVENT_MODIFIERS_H_