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

« back to all changes in this revision

Viewing changes to include/client/mir_toolkit/events/event.h

  • Committer: Package Import Robot
  • Author(s): CI Train Bot
  • Date: 2015-05-12 13:12:55 UTC
  • mto: This revision was merged to the branch mainline in revision 96.
  • Revision ID: package-import@ubuntu.com-20150512131255-y7z12i8n4pbvo70x
Tags: upstream-0.13.0+15.10.20150512
Import upstream version 0.13.0+15.10.20150512

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2014 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: Robert Carr <robert.carr@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
 
 
34
typedef enum
 
35
{
 
36
    mir_event_type_key,
 
37
    mir_event_type_motion,
 
38
    mir_event_type_surface,
 
39
    mir_event_type_resize,
 
40
    mir_event_type_prompt_session_state_change,
 
41
    mir_event_type_orientation,
 
42
    mir_event_type_close_surface,
 
43
    /* Type for new style input event will be returned from mir_event_get_type
 
44
       when old style event type was mir_event_type_key or mir_event_type_motion */
 
45
    mir_event_type_input,
 
46
    mir_event_type_keymap
 
47
} MirEventType;
 
48
 
 
49
typedef struct MirSurfaceEvent MirSurfaceEvent;
 
50
typedef struct MirResizeEvent MirResizeEvent;
 
51
typedef struct MirPromptSessionEvent MirPromptSessionEvent;
 
52
typedef struct MirOrientationEvent MirOrientationEvent;
 
53
typedef struct MirCloseSurfaceEvent MirCloseSurfaceEvent;
 
54
typedef struct MirInputEvent MirInputEvent;
 
55
typedef struct MirKeymapEvent MirKeymapEvent;
 
56
 
 
57
typedef union MirEvent MirEvent;
 
58
 
 
59
#ifdef __cplusplus
 
60
}
 
61
/**@}*/
 
62
#endif
 
63
 
 
64
#include "mir_toolkit/events/input/input_event.h"
 
65
#include "mir_toolkit/events/resize_event.h"
 
66
#include "mir_toolkit/events/surface_event.h"
 
67
#include "mir_toolkit/events/orientation_event.h"
 
68
#include "mir_toolkit/events/prompt_session_event.h"
 
69
#include "mir_toolkit/events/keymap_event.h"
 
70
 
 
71
#ifdef __cplusplus
 
72
/**
 
73
 * \addtogroup mir_toolkit
 
74
 * @{
 
75
 */
 
76
extern "C" {
 
77
#endif
 
78
 
 
79
/*
 
80
 * Retrieves the type of a MirEvent. Now preferred over direct access to ev->type.
 
81
 * In particular ev->type will never be mir_event_type_input and mir_event_get_type
 
82
 * is the only way to ensure mir_event_get_input_event will succeed.
 
83
 *
 
84
 * \param [in] event The event
 
85
 * \return           The event type
 
86
 */
 
87
MirEventType mir_event_get_type(MirEvent const* ev);
 
88
 
 
89
/*
 
90
 * Retrieve the MirInputEvent associated with a MirEvent of 
 
91
 * type mir_event_type_input. See <mir_toolkit/events/input/input_event.h>
 
92
 * for accessors.
 
93
 *
 
94
 * \param [in] event The event
 
95
 * \return           The associated MirInputEvent
 
96
 */
 
97
MirInputEvent const* mir_event_get_input_event(MirEvent const* ev);
 
98
 
 
99
/*
 
100
 * Retrieve the MirSurfaceEvent associated with a MirEvent of
 
101
 * type mir_event_type_surface. See <mir_toolkit/events/surface_event.h>
 
102
 * for accessors.
 
103
 *
 
104
 * \param [in] event The event
 
105
 * \return           The associated MirSurfaceEvent
 
106
 */
 
107
MirSurfaceEvent const* mir_event_get_surface_event(MirEvent const* ev);
 
108
 
 
109
/*
 
110
 * Retrieve the MirResizeEvent associated with a MirEvent of
 
111
 * type mir_event_type_resize. See <mir_toolkits/events/resize_event.h>
 
112
 * for accessors.
 
113
 *
 
114
 * \param [in] event The event
 
115
 * \return           The associated MirResizeEvent
 
116
 */
 
117
MirResizeEvent const* mir_event_get_resize_event(MirEvent const* ev);
 
118
 
 
119
/*
 
120
 * Retrieve the MirPromptSessionEvent associated with a MirEvent of
 
121
 * type mir_event_type_prompt_session_state_change. See <mir_toolkits/events/prompt_session_event.h>
 
122
 * for accessors.
 
123
 *
 
124
 * \param [in] event The event
 
125
 * \return           The associated MirPromptSessionEvent
 
126
 */
 
127
MirPromptSessionEvent const* mir_event_get_prompt_session_event(MirEvent const* ev);
 
128
 
 
129
/*
 
130
 * Retrieve the MirOrientationEvent associated with a MirEvent of
 
131
 * type mir_event_type_orientation. See <mir_toolkit/events/orientation_event.h>
 
132
 * for accessors.
 
133
 *
 
134
 * \param [in] event The event
 
135
 * \return           The associated MirOrientationEvent
 
136
 */
 
137
MirOrientationEvent const* mir_event_get_orientation_event(MirEvent const* ev);
 
138
 
 
139
/*
 
140
 * Retrieve the MirCloseSurfaceEvent associated with a MirEvent of
 
141
 * type mir_event_type_close_surface. The event is a request to close
 
142
 * the surface it is delivered to and has no accessors.
 
143
 *
 
144
 * \param [in] event The event
 
145
 * \return           The associated MirCloseSurfaceEvent
 
146
 */
 
147
MirCloseSurfaceEvent const* mir_event_get_close_surface_event(MirEvent const* ev);
 
148
 
 
149
/*
 
150
 * Retrieve the MirKeymapEvent associated with a MirEvent of
 
151
 * type mir_event_type_keymap. The event signifies that the keymap
 
152
 * applied for the relevant surface has changed.
 
153
 *
 
154
 * \param [in] event The event
 
155
 * \return           The associated MirKeymapEvent
 
156
 */
 
157
MirKeymapEvent const* mir_event_get_keymap_event(MirEvent const* ev);
 
158
 
 
159
/*
 
160
 * 
 
161
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
162
 * _________________________
 
163
 *< Don't use mir_event_ref >
 
164
 *-------------------------
 
165
 *       \   ^__^
 
166
 *        \  (oo)\_______
 
167
*            (__)\       )\/\
 
168
 *                ||----w |
 
169
 *                ||     || 
 
170
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
171
 * NOTICE: mir_event_ref and mir_event_unref are implemented in terms of copy until 
 
172
 * such point whereas direct MirEvent access as deprecated. This means you must
 
173
 * use the return value as your new reference 
 
174
 *
 
175
 */
 
176
 
 
177
/*
 
178
 * Reference this MirEvent and return a pointer to the
 
179
 * newly referenced instance
 
180
 *
 
181
 * \param[in] The event to reference
 
182
 * \return    The event pointer to now use
 
183
 */
 
184
MirEvent const* mir_event_ref(MirEvent const* ev) __attribute__((warn_unused_result));
 
185
 
 
186
/*
 
187
 * Release a reference to a MirEvent.
 
188
 *
 
189
 * \param[in] The event to un-reference
 
190
 */
 
191
void mir_event_unref(MirEvent const* ev);
 
192
 
 
193
#ifdef __cplusplus
 
194
}
 
195
/**@}*/
 
196
#endif
 
197
 
 
198
#endif /* MIR_TOOLKIT_EVENT_H_ */