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

Side by Side Diff: ui/events/ozone/evdev/event_modifiers_evdev.h

Issue 1287103004: Sync ui/events to chromium @ https://codereview.chromium.org/1210203002 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 months 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_EVDEV_EVENT_MODIFIERS_EVDEV_H_
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_MODIFIERS_EVDEV_H_
7
8 #include "base/basictypes.h"
9 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
10
11 namespace ui {
12
13 enum {
14 EVDEV_MODIFIER_NONE,
15 EVDEV_MODIFIER_CAPS_LOCK,
16 EVDEV_MODIFIER_SHIFT,
17 EVDEV_MODIFIER_CONTROL,
18 EVDEV_MODIFIER_ALT,
19 EVDEV_MODIFIER_LEFT_MOUSE_BUTTON,
20 EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON,
21 EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON,
22 EVDEV_MODIFIER_BACK_MOUSE_BUTTON,
23 EVDEV_MODIFIER_FORWARD_MOUSE_BUTTON,
24 EVDEV_MODIFIER_COMMAND,
25 EVDEV_MODIFIER_ALTGR,
26 EVDEV_MODIFIER_MOD3,
27 EVDEV_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_OZONE_EVDEV_EXPORT EventModifiersEvdev {
46 public:
47 EventModifiersEvdev();
48 ~EventModifiersEvdev();
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 // Return the mask for the specified modifier.
63 static int GetEventFlagFromModifier(unsigned int modifier);
64
65 private:
66 // Count of keys pressed for each modifier.
67 int modifiers_down_[EVDEV_NUM_MODIFIERS];
68
69 // Mask of modifier flags currently "locked".
70 int modifier_flags_locked_ = 0;
71
72 // Mask of modifier flags currently active (nonzero keys pressed xor locked).
73 int modifier_flags_ = 0;
74
75 // Update modifier_flags_ from modifiers_down_ and modifier_flags_locked_.
76 void UpdateFlags(unsigned int modifier);
77
78 DISALLOW_COPY_AND_ASSIGN(EventModifiersEvdev);
79 };
80
81 } // namspace ui
82
83 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_MODIFIERS_EVDEV_H_
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_factory_evdev.cc ('k') | ui/events/ozone/evdev/event_modifiers_evdev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698