2 Simple DirectMedia Layer
3 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
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.
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:
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.
22 #include "../../SDL_internal.h"
24 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
26 #ifndef _SDL_waylandtouch_h
27 #define _SDL_waylandtouch_h
29 #include "SDL_waylandvideo.h"
32 #include "wayland-util.h"
33 #include "SDL_waylanddyn.h"
36 void Wayland_touch_create(SDL_VideoData *data, uint32_t id);
37 void Wayland_touch_destroy(SDL_VideoData *data);
39 struct qt_touch_extension;
41 /* Autogenerated QT headers */
44 Support for Wayland with QmlCompositor as Server
45 ================================================
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.
51 The files following headers have been
52 generated from the Wayland XML Protocol Definition in QtWayland as follows:
54 Clone QtWayland from Git:
55 http://qt.gitorious.org/qt/qtwayland/
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
65 /* wayland-qt-surface-extension.h */
70 struct qt_surface_extension;
71 struct qt_extended_surface;
73 extern const struct wl_interface qt_surface_extension_interface;
74 extern const struct wl_interface qt_extended_surface_interface;
76 #define QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE 0
79 qt_surface_extension_set_user_data(struct qt_surface_extension *qt_surface_extension, void *user_data)
81 wl_proxy_set_user_data((struct wl_proxy *) qt_surface_extension, user_data);
85 qt_surface_extension_get_user_data(struct qt_surface_extension *qt_surface_extension)
87 return wl_proxy_get_user_data((struct wl_proxy *) qt_surface_extension);
91 qt_surface_extension_destroy(struct qt_surface_extension *qt_surface_extension)
93 WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_surface_extension);
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)
101 id = wl_proxy_create((struct wl_proxy *) qt_surface_extension,
102 &qt_extended_surface_interface);
106 WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_surface_extension,
107 QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE, id, surface);
109 return (struct qt_extended_surface *) id;
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,
121 #endif /* QT_EXTENDED_SURFACE_ORIENTATION_ENUM */
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,
129 #endif /* QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM */
131 struct qt_extended_surface_listener {
133 * onscreen_visibility - (none)
136 void (*onscreen_visibility)(void *data,
137 struct qt_extended_surface *qt_extended_surface,
140 * set_generic_property - (none)
144 void (*set_generic_property)(void *data,
145 struct qt_extended_surface *qt_extended_surface,
147 struct wl_array *value);
151 void (*close)(void *data,
152 struct qt_extended_surface *qt_extended_surface);
156 qt_extended_surface_add_listener(struct qt_extended_surface *qt_extended_surface,
157 const struct qt_extended_surface_listener *listener, void *data)
159 return wl_proxy_add_listener((struct wl_proxy *) qt_extended_surface,
160 (void (**)(void)) listener, data);
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
168 qt_extended_surface_set_user_data(struct qt_extended_surface *qt_extended_surface, void *user_data)
170 WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_extended_surface, user_data);
174 qt_extended_surface_get_user_data(struct qt_extended_surface *qt_extended_surface)
176 return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_extended_surface);
180 qt_extended_surface_destroy(struct qt_extended_surface *qt_extended_surface)
182 WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_extended_surface);
186 qt_extended_surface_update_generic_property(struct qt_extended_surface *qt_extended_surface, const char *name, struct wl_array *value)
188 WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
189 QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY, name, value);
193 qt_extended_surface_set_content_orientation(struct qt_extended_surface *qt_extended_surface, int32_t orientation)
195 WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
196 QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION, orientation);
200 qt_extended_surface_set_window_flags(struct qt_extended_surface *qt_extended_surface, int32_t flags)
202 WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
203 QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS, flags);
206 /* wayland-qt-touch-extension.h */
208 extern const struct wl_interface qt_touch_extension_interface;
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,
215 #endif /* QT_TOUCH_EXTENSION_FLAGS_ENUM */
217 struct qt_touch_extension_listener {
225 * @normalized_x: (none)
226 * @normalized_y: (none)
230 * @velocity_x: (none)
231 * @velocity_y: (none)
235 void (*touch)(void *data,
236 struct qt_touch_extension *qt_touch_extension,
242 int32_t normalized_x,
243 int32_t normalized_y,
250 struct wl_array *rawdata);
255 void (*configure)(void *data,
256 struct qt_touch_extension *qt_touch_extension,
261 qt_touch_extension_add_listener(struct qt_touch_extension *qt_touch_extension,
262 const struct qt_touch_extension_listener *listener, void *data)
264 return wl_proxy_add_listener((struct wl_proxy *) qt_touch_extension,
265 (void (**)(void)) listener, data);
268 #define QT_TOUCH_EXTENSION_DUMMY 0
271 qt_touch_extension_set_user_data(struct qt_touch_extension *qt_touch_extension, void *user_data)
273 WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_touch_extension, user_data);
277 qt_touch_extension_get_user_data(struct qt_touch_extension *qt_touch_extension)
279 return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_touch_extension);
283 qt_touch_extension_destroy(struct qt_touch_extension *qt_touch_extension)
285 WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_touch_extension);
289 qt_touch_extension_dummy(struct qt_touch_extension *qt_touch_extension)
291 WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_touch_extension,
292 QT_TOUCH_EXTENSION_DUMMY);
296 /* wayland-qt-windowmanager.h */
298 extern const struct wl_interface qt_windowmanager_interface;
300 struct qt_windowmanager_listener {
303 * @show_is_fullscreen: (none)
305 void (*hints)(void *data,
306 struct qt_windowmanager *qt_windowmanager,
307 int32_t show_is_fullscreen);
311 void (*quit)(void *data,
312 struct qt_windowmanager *qt_windowmanager);
316 qt_windowmanager_add_listener(struct qt_windowmanager *qt_windowmanager,
317 const struct qt_windowmanager_listener *listener, void *data)
319 return wl_proxy_add_listener((struct wl_proxy *) qt_windowmanager,
320 (void (**)(void)) listener, data);
323 #define QT_WINDOWMANAGER_OPEN_URL 0
326 qt_windowmanager_set_user_data(struct qt_windowmanager *qt_windowmanager, void *user_data)
328 WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_windowmanager, user_data);
332 qt_windowmanager_get_user_data(struct qt_windowmanager *qt_windowmanager)
334 return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_windowmanager);
338 qt_windowmanager_destroy(struct qt_windowmanager *qt_windowmanager)
340 WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_windowmanager);
344 qt_windowmanager_open_url(struct qt_windowmanager *qt_windowmanager, uint32_t remaining, const char *url)
346 WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_windowmanager,
347 QT_WINDOWMANAGER_OPEN_URL, remaining, url);
350 #endif /* _SDL_waylandtouch_h */
352 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */