src/video/wayland/SDL_waylandtouch.h
author Michał Janiszewski <janisozaur+sdl2image@gmail.com>
Sun, 28 Oct 2018 21:36:48 +0100
changeset 12366 c46e72bd9950
parent 11811 5d94cb6b24d3
child 12503 806492103856
permissions -rw-r--r--
Add and update include guards

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