~ubuntu-branches/ubuntu/wily/mir/wily-proposed

« back to all changes in this revision

Viewing changes to include/common/mir_toolkit/event.h

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-10-10 14:01:26 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20141010140126-n1czko8na1kuz4ll
Tags: upstream-0.8.0+14.10.20141010
Import upstream version 0.8.0+14.10.20141010

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Thomas Voss <thomas.voss@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef MIR_TOOLKIT_EVENT_H_
 
20
#define MIR_TOOLKIT_EVENT_H_
 
21
 
 
22
#include <stddef.h>
 
23
#include <stdint.h>
 
24
#include "mir_toolkit/common.h"
 
25
 
 
26
#ifdef __cplusplus
 
27
/**
 
28
 * \addtogroup mir_toolkit
 
29
 * @{
 
30
 */
 
31
extern "C" {
 
32
#endif
 
33
/* TODO: To the moon. */
 
34
#define MIR_INPUT_EVENT_MAX_POINTER_COUNT 16
 
35
 
 
36
typedef int64_t nsecs_t;
 
37
 
 
38
typedef enum
 
39
{
 
40
    mir_event_type_key,
 
41
    mir_event_type_motion,
 
42
    mir_event_type_surface,
 
43
    mir_event_type_resize,
 
44
    mir_event_type_prompt_session_state_change,
 
45
    mir_event_type_orientation
 
46
} MirEventType;
 
47
 
 
48
typedef enum {
 
49
    mir_key_action_down     = 0,
 
50
    mir_key_action_up       = 1,
 
51
    mir_key_action_multiple = 2
 
52
} MirKeyAction;
 
53
 
 
54
typedef enum {
 
55
    mir_key_flag_woke_here           = 0x1,
 
56
    mir_key_flag_soft_keyboard       = 0x2,
 
57
    mir_key_flag_keep_touch_mode     = 0x4,
 
58
    mir_key_flag_from_system         = 0x8,
 
59
    mir_key_flag_editor_action       = 0x10,
 
60
    mir_key_flag_canceled            = 0x20,
 
61
    mir_key_flag_virtual_hard_key    = 0x40,
 
62
    mir_key_flag_long_press          = 0x80,
 
63
    mir_key_flag_canceled_long_press = 0x100,
 
64
    mir_key_flag_tracking            = 0x200,
 
65
    mir_key_flag_fallback            = 0x400
 
66
} MirKeyFlag;
 
67
 
 
68
typedef enum {
 
69
    mir_key_modifier_none        = 0,
 
70
    mir_key_modifier_alt         = 0x02,
 
71
    mir_key_modifier_alt_left    = 0x10,
 
72
    mir_key_modifier_alt_right   = 0x20,
 
73
    mir_key_modifier_shift       = 0x01,
 
74
    mir_key_modifier_shift_left  = 0x40,
 
75
    mir_key_modifier_shift_right = 0x80,
 
76
    mir_key_modifier_sym         = 0x04,
 
77
    mir_key_modifier_function    = 0x08,
 
78
    mir_key_modifier_ctrl        = 0x1000,
 
79
    mir_key_modifier_ctrl_left   = 0x2000,
 
80
    mir_key_modifier_ctrl_right  = 0x4000,
 
81
    mir_key_modifier_meta        = 0x10000,
 
82
    mir_key_modifier_meta_left   = 0x20000,
 
83
    mir_key_modifier_meta_right  = 0x40000,
 
84
    mir_key_modifier_caps_lock   = 0x100000,
 
85
    mir_key_modifier_num_lock    = 0x200000,
 
86
    mir_key_modifier_scroll_lock = 0x400000
 
87
} MirKeyModifier;
 
88
 
 
89
typedef enum {
 
90
    mir_motion_action_down         = 0,
 
91
    mir_motion_action_up           = 1,
 
92
    mir_motion_action_move         = 2,
 
93
    mir_motion_action_cancel       = 3,
 
94
    mir_motion_action_outside      = 4,
 
95
    mir_motion_action_pointer_down = 5,
 
96
    mir_motion_action_pointer_up   = 6,
 
97
    mir_motion_action_hover_move   = 7,
 
98
    mir_motion_action_scroll       = 8,
 
99
    mir_motion_action_hover_enter  = 9,
 
100
    mir_motion_action_hover_exit   = 10
 
101
} MirMotionAction;
 
102
 
 
103
typedef enum {
 
104
    mir_motion_flag_window_is_obscured = 0x1
 
105
} MirMotionFlag;
 
106
 
 
107
typedef enum {
 
108
    mir_motion_button_primary   = 1 << 0,
 
109
    mir_motion_button_secondary = 1 << 1,
 
110
    mir_motion_button_tertiary  = 1 << 2,
 
111
    mir_motion_button_back      = 1 << 3,
 
112
    mir_motion_button_forward   = 1 << 4
 
113
} MirMotionButton;
 
114
 
 
115
typedef enum {
 
116
   mir_motion_tool_type_unknown = 0,
 
117
   mir_motion_tool_type_finger  = 1,
 
118
   mir_motion_tool_type_stylus  = 2,
 
119
   mir_motion_tool_type_mouse   = 3,
 
120
   mir_motion_tool_type_eraser  = 4
 
121
} MirMotionToolType;
 
122
 
 
123
typedef struct
 
124
{
 
125
    MirEventType type;
 
126
 
 
127
    int32_t device_id;
 
128
    int32_t source_id;
 
129
    MirKeyAction action;
 
130
    MirKeyFlag flags;
 
131
    unsigned int modifiers;
 
132
 
 
133
    int32_t key_code;
 
134
    int32_t scan_code;
 
135
    int32_t repeat_count;
 
136
    nsecs_t down_time;
 
137
    nsecs_t event_time;
 
138
    int is_system_key;
 
139
} MirKeyEvent;
 
140
 
 
141
typedef struct
 
142
{
 
143
    int id;
 
144
    float x, raw_x;
 
145
    float y, raw_y;
 
146
    float touch_major;
 
147
    float touch_minor;
 
148
    float size;
 
149
    float pressure;
 
150
    float orientation;
 
151
    float vscroll;
 
152
    float hscroll;
 
153
    MirMotionToolType tool_type;
 
154
    int unused1;
 
155
    int unused2;
 
156
    int unused3;
 
157
} MirMotionPointer;
 
158
 
 
159
typedef struct
 
160
{
 
161
    MirEventType type;
 
162
 
 
163
    int32_t device_id;
 
164
    int32_t source_id;
 
165
    /*
 
166
     * TODO(racarr): We would like to store this as a MirMotionAction but the android input stack
 
167
     * encodes some non enumerable values in it. It's convenient to keep things
 
168
     * this way for now until we can drop SF/Hybris support in QtUbuntu.
 
169
     */
 
170
    int action;
 
171
    MirMotionFlag flags;
 
172
    unsigned int modifiers;
 
173
 
 
174
    int32_t edge_flags;
 
175
    MirMotionButton button_state;
 
176
    float x_offset;
 
177
    float y_offset;
 
178
    float x_precision;
 
179
    float y_precision;
 
180
    nsecs_t down_time;
 
181
    nsecs_t event_time;
 
182
 
 
183
    size_t pointer_count;
 
184
    MirMotionPointer pointer_coordinates[MIR_INPUT_EVENT_MAX_POINTER_COUNT];
 
185
    /* "_coordinates" is a misnomer here because there's plenty more info than
 
186
       just coordinates, but renaming it accurately would be an API break */
 
187
 
 
188
    int unused0;
 
189
    int unused1;
 
190
    int unused2;
 
191
    int unused3;
 
192
} MirMotionEvent;
 
193
 
 
194
typedef struct
 
195
{
 
196
    MirEventType type;
 
197
 
 
198
    int id;
 
199
    MirSurfaceAttrib attrib;
 
200
    int value;
 
201
} MirSurfaceEvent;
 
202
 
 
203
typedef struct
 
204
{
 
205
    MirEventType type;
 
206
 
 
207
    int surface_id;
 
208
    int width;
 
209
    int height;
 
210
} MirResizeEvent;
 
211
 
 
212
typedef struct
 
213
{
 
214
    MirEventType type;
 
215
 
 
216
    MirPromptSessionState new_state;
 
217
} MirPromptSessionEvent;
 
218
 
 
219
typedef struct MirOrientationEvent
 
220
{
 
221
    MirEventType type;
 
222
 
 
223
    int surface_id;
 
224
    MirOrientation direction;
 
225
} MirOrientationEvent;
 
226
 
 
227
typedef union
 
228
{
 
229
    MirEventType    type;
 
230
    MirKeyEvent     key;
 
231
    MirMotionEvent  motion;
 
232
    MirSurfaceEvent surface;
 
233
    MirResizeEvent  resize;
 
234
    MirPromptSessionEvent  prompt_session;
 
235
    MirOrientationEvent orientation;
 
236
} MirEvent;
 
237
 
 
238
#ifdef __cplusplus
 
239
}
 
240
/**@}*/
 
241
#endif
 
242
 
 
243
#endif /* MIR_TOOLKIT_EVENT_H_ */