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