OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 BASE_WAYLAND_WAYLAND_EVENT_H_ | |
6 #define BASE_WAYLAND_WAYLAND_EVENT_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 // Wayland event information is being passed in as arguments to the callbacks. | |
11 // (See wayland_input_device.{h,cc} for information on the callbacks and how | |
12 // events are processed.) | |
13 // In order to provide a more generic look for events we wrap these arguments | |
14 // in specific event structs. Then define a WaylandEvent as a union of all | |
15 // types of events that Wayland will send. | |
16 // | |
17 // The following fields are common for most event types and their use is | |
18 // similar: | |
19 // - time: | |
20 // The time of the event. This should be monotonically increasing. | |
21 // - state: | |
22 // The value of the button event as given by evdev. This is 0 if button | |
23 // isn't pressed. | |
24 // - modifiers: | |
25 // Stores all the keyboard modifiers (Ctrl, Alt, Shift, ...) currently | |
26 // active. The modifiers are values as defined by xkbcommon. | |
27 | |
28 namespace base { | |
29 namespace wayland { | |
30 | |
31 // Types of events Wayland will send | |
32 enum WaylandEventType { | |
33 WAYLAND_BUTTON, | |
34 WAYLAND_KEY, | |
35 WAYLAND_MOTION, | |
36 WAYLAND_POINTER_FOCUS, | |
37 WAYLAND_KEYBOARD_FOCUS, | |
38 WAYLAND_GEOMETRY_CHANGE, | |
39 }; | |
40 | |
41 struct WaylandEventButton { | |
42 WaylandEventType type; | |
43 uint32_t time; | |
44 // WaylandEventButtonType defines some of the values button can take | |
45 uint32_t button; | |
46 uint32_t state; | |
47 uint32_t modifiers; | |
48 int32_t x; | |
49 int32_t y; | |
50 }; | |
51 | |
52 struct WaylandEventKey { | |
53 WaylandEventType type; | |
54 uint32_t time; | |
55 // The raw key value that evdev returns. | |
56 uint32_t key; | |
57 // The key symbol returned by processing the raw key using the xkbcommon | |
58 // library. | |
59 uint32_t sym; | |
60 uint32_t state; | |
61 uint32_t modifiers; | |
62 }; | |
63 | |
64 // Triggered when there is a motion event. The motion event is triggered | |
65 // only if there is a window under focus. | |
66 struct WaylandEventMotion { | |
67 WaylandEventType type; | |
68 uint32_t time; | |
69 uint32_t modifiers; | |
70 int32_t x; | |
71 int32_t y; | |
72 }; | |
73 | |
74 // Triggered when a window enters/exits pointer focus. The state tells us | |
75 // if the window lost focus (state == 0) or gained focus (state != 0). | |
76 struct WaylandEventPointerFocus { | |
77 WaylandEventType type; | |
78 uint32_t time; | |
79 uint32_t state; | |
80 int32_t x; | |
81 int32_t y; | |
82 }; | |
83 | |
84 // Triggered when a window enters/exits keyboard focus. The state tells us | |
85 // if the window lost focus (state == 0) or gained focus (state != 0). | |
86 struct WaylandEventKeyboardFocus { | |
87 WaylandEventType type; | |
88 uint32_t time; | |
89 uint32_t state; | |
90 uint32_t modifiers; | |
91 }; | |
92 | |
93 // Event triggered when a window's geometry changes. The event contains the | |
94 // position and dimensions of the window. | |
95 struct WaylandEventGeometryChange { | |
96 WaylandEventType type; | |
97 uint32_t time; | |
98 int32_t x; | |
99 int32_t y; | |
100 int32_t width; | |
101 int32_t height; | |
102 }; | |
103 | |
104 union WaylandEvent { | |
105 WaylandEventType type; | |
106 WaylandEventButton button; | |
107 WaylandEventKey key; | |
108 WaylandEventMotion motion; | |
109 WaylandEventPointerFocus pointer_focus; | |
110 WaylandEventKeyboardFocus keyboard_focus; | |
111 WaylandEventGeometryChange geometry_change; | |
112 }; | |
113 | |
114 } // namespace wayland | |
115 } // namespace base | |
116 | |
117 #endif // BASE_WAYLAND_WAYLAND_EVENT_H_ | |
OLD | NEW |