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