change SDL 1.2 to SDL 2.0
[platform/upstream/SDL.git] / src / video / wayland / SDL_waylandtouch.h
1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4
5   This software is provided 'as-is', without any express or implied
6   warranty.  In no event will the authors be held liable for any damages
7   arising from the use of this software.
8
9   Permission is granted to anyone to use this software for any purpose,
10   including commercial applications, and to alter it and redistribute it
11   freely, subject to the following restrictions:
12
13   1. The origin of this software must not be misrepresented; you must not
14      claim that you wrote the original software. If you use this software
15      in a product, an acknowledgment in the product documentation would be
16      appreciated but is not required.
17   2. Altered source versions must be plainly marked as such, and must not be
18      misrepresented as being the original software.
19   3. This notice may not be removed or altered from any source distribution.
20 */
21
22 #include "../../SDL_internal.h"
23
24 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
25
26 #ifndef _SDL_waylandtouch_h
27 #define _SDL_waylandtouch_h
28
29 #include "SDL_waylandvideo.h"
30 #include <stdint.h>
31 #include <stddef.h>
32 #include "wayland-util.h"
33 #include "SDL_waylanddyn.h"
34
35
36 void Wayland_touch_create(SDL_VideoData *data, uint32_t id);
37 void Wayland_touch_destroy(SDL_VideoData *data);
38
39 struct qt_touch_extension;
40
41 /* Autogenerated QT headers */
42
43 /*
44  Support for Wayland with QmlCompositor as Server
45 ================================================
46
47 The Wayland video driver has support for some additional features when
48 using QtWayland's "qmlcompositor" as Wayland server. This is needed for touch
49 input when running SDL applications under a qmlcompositor Wayland server.
50
51 The files following headers have been
52 generated from the Wayland XML Protocol Definition in QtWayland as follows:
53
54 Clone QtWayland from Git:
55     http://qt.gitorious.org/qt/qtwayland/
56
57 Generate headers and glue code:
58     for extension in touch-extension surface-extension windowmanager; do
59         wayland-scanner client-header < src/extensions/$extension.xml > wayland-qt-$extension.h
60         wayland-scanner code < src/extensions/$extension.xml > wayland-qt-$extension.c
61     done
62
63 */
64
65 /* wayland-qt-surface-extension.h */
66
67 struct wl_client;
68 struct wl_resource;
69
70 struct qt_surface_extension;
71 struct qt_extended_surface;
72
73 extern const struct wl_interface qt_surface_extension_interface;
74 extern const struct wl_interface qt_extended_surface_interface;
75
76 #define QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE   0
77
78 static inline void
79 qt_surface_extension_set_user_data(struct qt_surface_extension *qt_surface_extension, void *user_data)
80 {
81     wl_proxy_set_user_data((struct wl_proxy *) qt_surface_extension, user_data);
82 }
83
84 static inline void *
85 qt_surface_extension_get_user_data(struct qt_surface_extension *qt_surface_extension)
86 {
87     return wl_proxy_get_user_data((struct wl_proxy *) qt_surface_extension);
88 }
89
90 static inline void
91 qt_surface_extension_destroy(struct qt_surface_extension *qt_surface_extension)
92 {
93     WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_surface_extension);
94 }
95
96 static inline struct qt_extended_surface *
97 qt_surface_extension_get_extended_surface(struct qt_surface_extension *qt_surface_extension, struct wl_surface *surface)
98 {
99     struct wl_proxy *id;
100
101     id = wl_proxy_create((struct wl_proxy *) qt_surface_extension,
102                  &qt_extended_surface_interface);
103     if (!id)
104         return NULL;
105
106     WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_surface_extension,
107              QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE, id, surface);
108
109     return (struct qt_extended_surface *) id;
110 }
111
112 #ifndef QT_EXTENDED_SURFACE_ORIENTATION_ENUM
113 #define QT_EXTENDED_SURFACE_ORIENTATION_ENUM
114 enum qt_extended_surface_orientation {
115     QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION = 0,
116     QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION = 1,
117     QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION = 2,
118     QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION = 4,
119     QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION = 8,
120 };
121 #endif /* QT_EXTENDED_SURFACE_ORIENTATION_ENUM */
122
123 #ifndef QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM
124 #define QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM
125 enum qt_extended_surface_windowflag {
126     QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES = 1,
127     QT_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP = 2,
128 };
129 #endif /* QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM */
130
131 struct qt_extended_surface_listener {
132     /**
133      * onscreen_visibility - (none)
134      * @visible: (none)
135      */
136     void (*onscreen_visibility)(void *data,
137                     struct qt_extended_surface *qt_extended_surface,
138                     int32_t visible);
139     /**
140      * set_generic_property - (none)
141      * @name: (none)
142      * @value: (none)
143      */
144     void (*set_generic_property)(void *data,
145                      struct qt_extended_surface *qt_extended_surface,
146                      const char *name,
147                      struct wl_array *value);
148     /**
149      * close - (none)
150      */
151     void (*close)(void *data,
152               struct qt_extended_surface *qt_extended_surface);
153 };
154
155 static inline int
156 qt_extended_surface_add_listener(struct qt_extended_surface *qt_extended_surface,
157                  const struct qt_extended_surface_listener *listener, void *data)
158 {
159     return wl_proxy_add_listener((struct wl_proxy *) qt_extended_surface,
160                      (void (**)(void)) listener, data);
161 }
162
163 #define QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY 0
164 #define QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION 1
165 #define QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS    2
166
167 static inline void
168 qt_extended_surface_set_user_data(struct qt_extended_surface *qt_extended_surface, void *user_data)
169 {
170     WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_extended_surface, user_data);
171 }
172
173 static inline void *
174 qt_extended_surface_get_user_data(struct qt_extended_surface *qt_extended_surface)
175 {
176     return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_extended_surface);
177 }
178
179 static inline void
180 qt_extended_surface_destroy(struct qt_extended_surface *qt_extended_surface)
181 {
182     WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_extended_surface);
183 }
184
185 static inline void
186 qt_extended_surface_update_generic_property(struct qt_extended_surface *qt_extended_surface, const char *name, struct wl_array *value)
187 {
188     WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
189              QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY, name, value);
190 }
191
192 static inline void
193 qt_extended_surface_set_content_orientation(struct qt_extended_surface *qt_extended_surface, int32_t orientation)
194 {
195     WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
196              QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION, orientation);
197 }
198
199 static inline void
200 qt_extended_surface_set_window_flags(struct qt_extended_surface *qt_extended_surface, int32_t flags)
201 {
202     WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
203              QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS, flags);
204 }
205
206 /* wayland-qt-touch-extension.h */
207
208 extern const struct wl_interface qt_touch_extension_interface;
209
210 #ifndef QT_TOUCH_EXTENSION_FLAGS_ENUM
211 #define QT_TOUCH_EXTENSION_FLAGS_ENUM
212 enum qt_touch_extension_flags {
213     QT_TOUCH_EXTENSION_FLAGS_MOUSE_FROM_TOUCH = 0x1,
214 };
215 #endif /* QT_TOUCH_EXTENSION_FLAGS_ENUM */
216
217 struct qt_touch_extension_listener {
218     /**
219      * touch - (none)
220      * @time: (none)
221      * @id: (none)
222      * @state: (none)
223      * @x: (none)
224      * @y: (none)
225      * @normalized_x: (none)
226      * @normalized_y: (none)
227      * @width: (none)
228      * @height: (none)
229      * @pressure: (none)
230      * @velocity_x: (none)
231      * @velocity_y: (none)
232      * @flags: (none)
233      * @rawdata: (none)
234      */
235     void (*touch)(void *data,
236               struct qt_touch_extension *qt_touch_extension,
237               uint32_t time,
238               uint32_t id,
239               uint32_t state,
240               int32_t x,
241               int32_t y,
242               int32_t normalized_x,
243               int32_t normalized_y,
244               int32_t width,
245               int32_t height,
246               uint32_t pressure,
247               int32_t velocity_x,
248               int32_t velocity_y,
249               uint32_t flags,
250               struct wl_array *rawdata);
251     /**
252      * configure - (none)
253      * @flags: (none)
254      */
255     void (*configure)(void *data,
256               struct qt_touch_extension *qt_touch_extension,
257               uint32_t flags);
258 };
259
260 static inline int
261 qt_touch_extension_add_listener(struct qt_touch_extension *qt_touch_extension,
262                 const struct qt_touch_extension_listener *listener, void *data)
263 {
264     return wl_proxy_add_listener((struct wl_proxy *) qt_touch_extension,
265                      (void (**)(void)) listener, data);
266 }
267
268 #define QT_TOUCH_EXTENSION_DUMMY    0
269
270 static inline void
271 qt_touch_extension_set_user_data(struct qt_touch_extension *qt_touch_extension, void *user_data)
272 {
273     WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_touch_extension, user_data);
274 }
275
276 static inline void *
277 qt_touch_extension_get_user_data(struct qt_touch_extension *qt_touch_extension)
278 {
279     return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_touch_extension);
280 }
281
282 static inline void
283 qt_touch_extension_destroy(struct qt_touch_extension *qt_touch_extension)
284 {
285     WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_touch_extension);
286 }
287
288 static inline void
289 qt_touch_extension_dummy(struct qt_touch_extension *qt_touch_extension)
290 {
291     WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_touch_extension,
292              QT_TOUCH_EXTENSION_DUMMY);
293 }
294
295
296 /* wayland-qt-windowmanager.h */
297
298 extern const struct wl_interface qt_windowmanager_interface;
299
300 struct qt_windowmanager_listener {
301     /**
302      * hints - (none)
303      * @show_is_fullscreen: (none)
304      */
305     void (*hints)(void *data,
306               struct qt_windowmanager *qt_windowmanager,
307               int32_t show_is_fullscreen);
308     /**
309      * quit - (none)
310      */
311     void (*quit)(void *data,
312              struct qt_windowmanager *qt_windowmanager);
313 };
314
315 static inline int
316 qt_windowmanager_add_listener(struct qt_windowmanager *qt_windowmanager,
317                   const struct qt_windowmanager_listener *listener, void *data)
318 {
319     return wl_proxy_add_listener((struct wl_proxy *) qt_windowmanager,
320                      (void (**)(void)) listener, data);
321 }
322
323 #define QT_WINDOWMANAGER_OPEN_URL   0
324
325 static inline void
326 qt_windowmanager_set_user_data(struct qt_windowmanager *qt_windowmanager, void *user_data)
327 {
328     WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_windowmanager, user_data);
329 }
330
331 static inline void *
332 qt_windowmanager_get_user_data(struct qt_windowmanager *qt_windowmanager)
333 {
334     return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_windowmanager);
335 }
336
337 static inline void
338 qt_windowmanager_destroy(struct qt_windowmanager *qt_windowmanager)
339 {
340     WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_windowmanager);
341 }
342
343 static inline void
344 qt_windowmanager_open_url(struct qt_windowmanager *qt_windowmanager, uint32_t remaining, const char *url)
345 {
346     WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_windowmanager,
347              QT_WINDOWMANAGER_OPEN_URL, remaining, url);
348 }
349
350 #endif /* _SDL_waylandtouch_h */
351
352 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */