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