src/video/wayland/SDL_waylandvideo.c
author Sam Lantinga
Thu, 01 Sep 2016 01:26:56 -0700
changeset 10304 ee83e0b4a36f
parent 10302 729eff9ee77a
child 10492 786e10ab72d8
permissions -rw-r--r--
wayland: Add support for relative mouse mode, by Jonas Ådahl <jadahl@gmail.com>

Generate the C protocol files from the protocol XML files installed by
wayland-protocols, and use them to implement support for relative pointer
motions and pointer locking.

Note that at the time, the protocol is unstable and may change in the future.
Any future breaking changes will, however, fail gracefully and result in no
regressions compared to before this patch.
gabomdq@8062
     1
/*
gabomdq@8062
     2
  Simple DirectMedia Layer
slouken@9998
     3
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
gabomdq@8062
     4
gabomdq@8062
     5
  This software is provided 'as-is', without any express or implied
gabomdq@8062
     6
  warranty.  In no event will the authors be held liable for any damages
gabomdq@8062
     7
  arising from the use of this software.
gabomdq@8062
     8
gabomdq@8062
     9
  Permission is granted to anyone to use this software for any purpose,
gabomdq@8062
    10
  including commercial applications, and to alter it and redistribute it
gabomdq@8062
    11
  freely, subject to the following restrictions:
gabomdq@8062
    12
gabomdq@8062
    13
  1. The origin of this software must not be misrepresented; you must not
gabomdq@8062
    14
     claim that you wrote the original software. If you use this software
gabomdq@8062
    15
     in a product, an acknowledgment in the product documentation would be
gabomdq@8062
    16
     appreciated but is not required.
gabomdq@8062
    17
  2. Altered source versions must be plainly marked as such, and must not be
gabomdq@8062
    18
     misrepresented as being the original software.
gabomdq@8062
    19
  3. This notice may not be removed or altered from any source distribution.
gabomdq@8062
    20
*/
gabomdq@8062
    21
gabomdq@8104
    22
#include "../../SDL_internal.h"
gabomdq@8062
    23
icculus@8116
    24
#if SDL_VIDEO_DRIVER_WAYLAND
icculus@8116
    25
gabomdq@8062
    26
#include "SDL_video.h"
gabomdq@8062
    27
#include "SDL_mouse.h"
gabomdq@8104
    28
#include "SDL_stdinc.h"
gabomdq@8062
    29
#include "../../events/SDL_events_c.h"
gabomdq@8062
    30
gabomdq@8062
    31
#include "SDL_waylandvideo.h"
gabomdq@8062
    32
#include "SDL_waylandevents_c.h"
gabomdq@8062
    33
#include "SDL_waylandwindow.h"
gabomdq@8062
    34
#include "SDL_waylandopengles.h"
gabomdq@8062
    35
#include "SDL_waylandmouse.h"
gabomdq@8082
    36
#include "SDL_waylandtouch.h"
gabomdq@8062
    37
hadess@10302
    38
#include <sys/types.h>
hadess@10302
    39
#include <unistd.h>
gabomdq@8062
    40
#include <fcntl.h>
gabomdq@8062
    41
#include <xkbcommon/xkbcommon.h>
gabomdq@8062
    42
gabomdq@8104
    43
#include "SDL_waylanddyn.h"
gabomdq@8104
    44
#include <wayland-util.h>
gabomdq@8104
    45
gabomdq@8062
    46
#define WAYLANDVID_DRIVER_NAME "wayland"
gabomdq@8062
    47
gabomdq@8062
    48
/* Initialization/Query functions */
gabomdq@8062
    49
static int
gabomdq@8062
    50
Wayland_VideoInit(_THIS);
gabomdq@8062
    51
gabomdq@8062
    52
static void
gabomdq@8062
    53
Wayland_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display);
gabomdq@8062
    54
static int
gabomdq@8062
    55
Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
gabomdq@8062
    56
gabomdq@8062
    57
static void
gabomdq@8062
    58
Wayland_VideoQuit(_THIS);
gabomdq@8062
    59
hadess@10302
    60
/* Find out what class name we should use
hadess@10302
    61
 * Based on src/video/x11/SDL_x11video.c */
hadess@10302
    62
static char *
hadess@10302
    63
get_classname()
hadess@10302
    64
{
hadess@10302
    65
    char *spot;
hadess@10302
    66
#if defined(__LINUX__) || defined(__FREEBSD__)
hadess@10302
    67
    char procfile[1024];
hadess@10302
    68
    char linkfile[1024];
hadess@10302
    69
    int linksize;
hadess@10302
    70
#endif
hadess@10302
    71
hadess@10302
    72
    /* First allow environment variable override */
hadess@10302
    73
    spot = SDL_getenv("SDL_VIDEO_WAYLAND_WMCLASS");
hadess@10302
    74
    if (spot) {
hadess@10302
    75
        return SDL_strdup(spot);
hadess@10302
    76
    } else {
hadess@10302
    77
        /* Fallback to the "old" envvar */
hadess@10302
    78
        spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS");
hadess@10302
    79
        if (spot) {
hadess@10302
    80
            return SDL_strdup(spot);
hadess@10302
    81
        }
hadess@10302
    82
    }
hadess@10302
    83
hadess@10302
    84
    /* Next look at the application's executable name */
hadess@10302
    85
#if defined(__LINUX__) || defined(__FREEBSD__)
hadess@10302
    86
#if defined(__LINUX__)
hadess@10302
    87
    SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid());
hadess@10302
    88
#elif defined(__FREEBSD__)
hadess@10302
    89
    SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file",
hadess@10302
    90
                 getpid());
hadess@10302
    91
#else
hadess@10302
    92
#error Where can we find the executable name?
hadess@10302
    93
#endif
hadess@10302
    94
    linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
hadess@10302
    95
    if (linksize > 0) {
hadess@10302
    96
        linkfile[linksize] = '\0';
hadess@10302
    97
        spot = SDL_strrchr(linkfile, '/');
hadess@10302
    98
        if (spot) {
hadess@10302
    99
            return SDL_strdup(spot + 1);
hadess@10302
   100
        } else {
hadess@10302
   101
            return SDL_strdup(linkfile);
hadess@10302
   102
        }
hadess@10302
   103
    }
hadess@10302
   104
#endif /* __LINUX__ || __FREEBSD__ */
hadess@10302
   105
hadess@10302
   106
    /* Finally use the default we've used forever */
hadess@10302
   107
    return SDL_strdup("SDL_App");
hadess@10302
   108
}
hadess@10302
   109
gabomdq@8062
   110
/* Wayland driver bootstrap functions */
gabomdq@8062
   111
static int
gabomdq@8062
   112
Wayland_Available(void)
gabomdq@8062
   113
{
gabomdq@8062
   114
    struct wl_display *display = NULL;
gabomdq@8104
   115
    if (SDL_WAYLAND_LoadSymbols()) {
gabomdq@8104
   116
        display = WAYLAND_wl_display_connect(NULL);
gabomdq@8104
   117
        if (display != NULL) {
gabomdq@8104
   118
            WAYLAND_wl_display_disconnect(display);
gabomdq@8104
   119
        }
gabomdq@8104
   120
        SDL_WAYLAND_UnloadSymbols();
gabomdq@8062
   121
    }
gabomdq@8062
   122
gabomdq@8062
   123
    return (display != NULL);
gabomdq@8062
   124
}
gabomdq@8062
   125
gabomdq@8062
   126
static void
gabomdq@8062
   127
Wayland_DeleteDevice(SDL_VideoDevice *device)
gabomdq@8062
   128
{
gabomdq@8062
   129
    SDL_free(device);
gabomdq@8104
   130
    SDL_WAYLAND_UnloadSymbols();
gabomdq@8062
   131
}
gabomdq@8062
   132
gabomdq@8062
   133
static SDL_VideoDevice *
gabomdq@8062
   134
Wayland_CreateDevice(int devindex)
gabomdq@8062
   135
{
gabomdq@8062
   136
    SDL_VideoDevice *device;
linkmauve@9467
   137
gabomdq@8104
   138
    if (!SDL_WAYLAND_LoadSymbols()) {
gabomdq@8104
   139
        return NULL;
gabomdq@8104
   140
    }
gabomdq@8062
   141
gabomdq@8062
   142
    /* Initialize all variables that we clean on shutdown */
gabomdq@8062
   143
    device = SDL_calloc(1, sizeof(SDL_VideoDevice));
gabomdq@8062
   144
    if (!device) {
icculus@8160
   145
        SDL_WAYLAND_UnloadSymbols();
gabomdq@8062
   146
        SDL_OutOfMemory();
gabomdq@8062
   147
        return NULL;
gabomdq@8062
   148
    }
gabomdq@8062
   149
gabomdq@8062
   150
    /* Set the function pointers */
gabomdq@8062
   151
    device->VideoInit = Wayland_VideoInit;
gabomdq@8062
   152
    device->VideoQuit = Wayland_VideoQuit;
gabomdq@8062
   153
    device->SetDisplayMode = Wayland_SetDisplayMode;
gabomdq@8062
   154
    device->GetDisplayModes = Wayland_GetDisplayModes;
gabomdq@8062
   155
    device->GetWindowWMInfo = Wayland_GetWindowWMInfo;
gabomdq@8062
   156
gabomdq@8062
   157
    device->PumpEvents = Wayland_PumpEvents;
gabomdq@8062
   158
gabomdq@8062
   159
    device->GL_SwapWindow = Wayland_GLES_SwapWindow;
gabomdq@8062
   160
    device->GL_GetSwapInterval = Wayland_GLES_GetSwapInterval;
gabomdq@8062
   161
    device->GL_SetSwapInterval = Wayland_GLES_SetSwapInterval;
gabomdq@8062
   162
    device->GL_MakeCurrent = Wayland_GLES_MakeCurrent;
gabomdq@8062
   163
    device->GL_CreateContext = Wayland_GLES_CreateContext;
gabomdq@8062
   164
    device->GL_LoadLibrary = Wayland_GLES_LoadLibrary;
gabomdq@8062
   165
    device->GL_UnloadLibrary = Wayland_GLES_UnloadLibrary;
gabomdq@8062
   166
    device->GL_GetProcAddress = Wayland_GLES_GetProcAddress;
gabomdq@8062
   167
    device->GL_DeleteContext = Wayland_GLES_DeleteContext;
gabomdq@8062
   168
gabomdq@8062
   169
    device->CreateWindow = Wayland_CreateWindow;
gabomdq@8062
   170
    device->ShowWindow = Wayland_ShowWindow;
gabomdq@8062
   171
    device->SetWindowFullscreen = Wayland_SetWindowFullscreen;
gabomdq@8062
   172
    device->SetWindowSize = Wayland_SetWindowSize;
gabomdq@8062
   173
    device->DestroyWindow = Wayland_DestroyWindow;
icculus@9554
   174
    device->SetWindowHitTest = Wayland_SetWindowHitTest;
gabomdq@8062
   175
gabomdq@8062
   176
    device->free = Wayland_DeleteDevice;
gabomdq@8062
   177
gabomdq@8062
   178
    return device;
gabomdq@8062
   179
}
gabomdq@8062
   180
gabomdq@8062
   181
VideoBootStrap Wayland_bootstrap = {
gabomdq@8062
   182
    WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
gabomdq@8062
   183
    Wayland_Available, Wayland_CreateDevice
gabomdq@8062
   184
};
gabomdq@8062
   185
gabomdq@8062
   186
static void
gabomdq@8062
   187
display_handle_geometry(void *data,
gabomdq@8062
   188
                        struct wl_output *output,
gabomdq@8062
   189
                        int x, int y,
gabomdq@8062
   190
                        int physical_width,
gabomdq@8062
   191
                        int physical_height,
gabomdq@8062
   192
                        int subpixel,
gabomdq@8062
   193
                        const char *make,
gabomdq@8062
   194
                        const char *model,
gabomdq@8062
   195
                        int transform)
gabomdq@8062
   196
gabomdq@8062
   197
{
linkmauve@9467
   198
    SDL_VideoDisplay *display = data;
gabomdq@8062
   199
philipp@10187
   200
    display->name = SDL_strdup(model);
linkmauve@9467
   201
    display->driverdata = output;
gabomdq@8062
   202
}
gabomdq@8062
   203
gabomdq@8062
   204
static void
gabomdq@8062
   205
display_handle_mode(void *data,
linkmauve@9467
   206
                    struct wl_output *output,
gabomdq@8062
   207
                    uint32_t flags,
gabomdq@8062
   208
                    int width,
gabomdq@8062
   209
                    int height,
gabomdq@8062
   210
                    int refresh)
gabomdq@8062
   211
{
linkmauve@9467
   212
    SDL_VideoDisplay *display = data;
gabomdq@8062
   213
    SDL_DisplayMode mode;
gabomdq@8062
   214
gabomdq@8062
   215
    SDL_zero(mode);
gabomdq@8062
   216
    mode.w = width;
gabomdq@8062
   217
    mode.h = height;
linkmauve@9467
   218
    mode.refresh_rate = refresh / 1000; // mHz to Hz
linkmauve@9467
   219
    SDL_AddDisplayMode(display, &mode);
gabomdq@8062
   220
gabomdq@8062
   221
    if (flags & WL_OUTPUT_MODE_CURRENT) {
linkmauve@9467
   222
        display->current_mode = mode;
linkmauve@9467
   223
        display->desktop_mode = mode;
gabomdq@8062
   224
    }
gabomdq@8062
   225
}
gabomdq@8062
   226
linkmauve@9467
   227
static void
linkmauve@9467
   228
display_handle_done(void *data,
linkmauve@9467
   229
                    struct wl_output *output)
linkmauve@9467
   230
{
linkmauve@9467
   231
    SDL_VideoDisplay *display = data;
linkmauve@9467
   232
    SDL_AddVideoDisplay(display);
linkmauve@9467
   233
    SDL_free(display->name);
linkmauve@9467
   234
    SDL_free(display);
linkmauve@9467
   235
}
linkmauve@9467
   236
linkmauve@9467
   237
static void
linkmauve@9467
   238
display_handle_scale(void *data,
linkmauve@9467
   239
                     struct wl_output *output,
linkmauve@9467
   240
                     int32_t factor)
linkmauve@9467
   241
{
linkmauve@9467
   242
    // TODO: do HiDPI stuff.
linkmauve@9467
   243
}
linkmauve@9467
   244
gabomdq@8062
   245
static const struct wl_output_listener output_listener = {
gabomdq@8062
   246
    display_handle_geometry,
linkmauve@9467
   247
    display_handle_mode,
linkmauve@9467
   248
    display_handle_done,
linkmauve@9467
   249
    display_handle_scale
gabomdq@8062
   250
};
gabomdq@8062
   251
gabomdq@8062
   252
static void
linkmauve@9467
   253
Wayland_add_display(SDL_VideoData *d, uint32_t id)
gabomdq@8062
   254
{
icculus@9472
   255
    struct wl_output *output;
linkmauve@9467
   256
    SDL_VideoDisplay *display = SDL_malloc(sizeof *display);
linkmauve@9467
   257
    if (!display) {
linkmauve@9467
   258
        SDL_OutOfMemory();
linkmauve@9467
   259
        return;
linkmauve@9467
   260
    }
linkmauve@9467
   261
    SDL_zero(*display);
gabomdq@8062
   262
icculus@9472
   263
    output = wl_registry_bind(d->registry, id, &wl_output_interface, 2);
linkmauve@9467
   264
    if (!output) {
linkmauve@9467
   265
        SDL_SetError("Failed to retrieve output.");
linkmauve@9467
   266
        return;
linkmauve@9467
   267
    }
gabomdq@8062
   268
linkmauve@9467
   269
    wl_output_add_listener(output, &output_listener, display);
linkmauve@9467
   270
}
gabomdq@8062
   271
gabomdq@8082
   272
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   273
static void
gabomdq@8082
   274
windowmanager_hints(void *data, struct qt_windowmanager *qt_windowmanager,
gabomdq@8082
   275
        int32_t show_is_fullscreen)
gabomdq@8082
   276
{
gabomdq@8082
   277
}
gabomdq@8082
   278
gabomdq@8082
   279
static void
gabomdq@8082
   280
windowmanager_quit(void *data, struct qt_windowmanager *qt_windowmanager)
gabomdq@8082
   281
{
gabomdq@8082
   282
    SDL_SendQuit();
gabomdq@8082
   283
}
gabomdq@8082
   284
gabomdq@8082
   285
static const struct qt_windowmanager_listener windowmanager_listener = {
gabomdq@8082
   286
    windowmanager_hints,
gabomdq@8082
   287
    windowmanager_quit,
gabomdq@8082
   288
};
gabomdq@8082
   289
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8082
   290
gabomdq@8062
   291
static void
gabomdq@8062
   292
display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
linkmauve@9467
   293
                      const char *interface, uint32_t version)
gabomdq@8062
   294
{
gabomdq@8062
   295
    SDL_VideoData *d = data;
linkmauve@9467
   296
gabomdq@8062
   297
    if (strcmp(interface, "wl_compositor") == 0) {
gabomdq@8062
   298
        d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, 1);
gabomdq@8062
   299
    } else if (strcmp(interface, "wl_output") == 0) {
linkmauve@9467
   300
        Wayland_add_display(d, id);
gabomdq@8062
   301
    } else if (strcmp(interface, "wl_seat") == 0) {
gabomdq@8062
   302
        Wayland_display_add_input(d, id);
gabomdq@8062
   303
    } else if (strcmp(interface, "wl_shell") == 0) {
gabomdq@8062
   304
        d->shell = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
gabomdq@8062
   305
    } else if (strcmp(interface, "wl_shm") == 0) {
gabomdq@8062
   306
        d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
gabomdq@8104
   307
        d->cursor_theme = WAYLAND_wl_cursor_theme_load(NULL, 32, d->shm);
slouken@10304
   308
    } else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) {
slouken@10304
   309
        Wayland_display_add_relative_pointer_manager(d, id);
slouken@10304
   310
    } else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0) {
slouken@10304
   311
        Wayland_display_add_pointer_constraints(d, id);
gabomdq@8082
   312
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   313
    } else if (strcmp(interface, "qt_touch_extension") == 0) {
gabomdq@8082
   314
        Wayland_touch_create(d, id);
gabomdq@8082
   315
    } else if (strcmp(interface, "qt_surface_extension") == 0) {
gabomdq@8082
   316
        d->surface_extension = wl_registry_bind(registry, id,
gabomdq@8082
   317
                &qt_surface_extension_interface, 1);
gabomdq@8082
   318
    } else if (strcmp(interface, "qt_windowmanager") == 0) {
gabomdq@8082
   319
        d->windowmanager = wl_registry_bind(registry, id,
gabomdq@8082
   320
                &qt_windowmanager_interface, 1);
gabomdq@8082
   321
        qt_windowmanager_add_listener(d->windowmanager, &windowmanager_listener, d);
gabomdq@8082
   322
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8062
   323
    }
gabomdq@8062
   324
}
gabomdq@8062
   325
gabomdq@8062
   326
static const struct wl_registry_listener registry_listener = {
linkmauve@9467
   327
    display_handle_global
gabomdq@8062
   328
};
gabomdq@8062
   329
gabomdq@8062
   330
int
gabomdq@8062
   331
Wayland_VideoInit(_THIS)
gabomdq@8062
   332
{
linkmauve@9467
   333
    SDL_VideoData *data = SDL_malloc(sizeof *data);
gabomdq@8062
   334
    if (data == NULL)
philipp@9484
   335
        return SDL_OutOfMemory();
gabomdq@8062
   336
    memset(data, 0, sizeof *data);
gabomdq@8062
   337
gabomdq@8062
   338
    _this->driverdata = data;
gabomdq@8062
   339
gabomdq@8104
   340
    data->display = WAYLAND_wl_display_connect(NULL);
gabomdq@8062
   341
    if (data->display == NULL) {
philipp@9484
   342
        return SDL_SetError("Failed to connect to a Wayland display");
gabomdq@8062
   343
    }
gabomdq@8062
   344
gabomdq@8062
   345
    data->registry = wl_display_get_registry(data->display);
linkmauve@9467
   346
    if (data->registry == NULL) {
philipp@9484
   347
        return SDL_SetError("Failed to get the Wayland registry");
gabomdq@8104
   348
    }
linkmauve@9467
   349
gabomdq@8062
   350
    wl_registry_add_listener(data->registry, &registry_listener, data);
gabomdq@8062
   351
linkmauve@9467
   352
    // First roundtrip to receive all registry objects.
icculus@9476
   353
    WAYLAND_wl_display_roundtrip(data->display);
linkmauve@9467
   354
linkmauve@9467
   355
    // Second roundtrip to receive all output events.
icculus@9476
   356
    WAYLAND_wl_display_roundtrip(data->display);
gabomdq@8062
   357
gabomdq@8104
   358
    data->xkb_context = WAYLAND_xkb_context_new(0);
gabomdq@8062
   359
    if (!data->xkb_context) {
philipp@9484
   360
        return SDL_SetError("Failed to create XKB context");
gabomdq@8062
   361
    }
gabomdq@8062
   362
linkmauve@9467
   363
    Wayland_InitMouse();
gabomdq@8062
   364
hadess@10302
   365
    /* Get the surface class name, usually the name of the application */
hadess@10302
   366
    data->classname = get_classname();
hadess@10302
   367
gabomdq@8104
   368
    WAYLAND_wl_display_flush(data->display);
gabomdq@8062
   369
gabomdq@8062
   370
    return 0;
gabomdq@8062
   371
}
gabomdq@8062
   372
gabomdq@8062
   373
static void
gabomdq@8062
   374
Wayland_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
gabomdq@8062
   375
{
linkmauve@9467
   376
    // Nothing to do here, everything was already done in the wl_output
linkmauve@9467
   377
    // callbacks.
gabomdq@8062
   378
}
gabomdq@8062
   379
gabomdq@8062
   380
static int
gabomdq@8062
   381
Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
gabomdq@8062
   382
{
icculus@9469
   383
    return SDL_Unsupported();
gabomdq@8062
   384
}
gabomdq@8062
   385
gabomdq@8062
   386
void
gabomdq@8062
   387
Wayland_VideoQuit(_THIS)
gabomdq@8062
   388
{
gabomdq@8062
   389
    SDL_VideoData *data = _this->driverdata;
linkmauve@9467
   390
    int i;
gabomdq@8062
   391
gabomdq@8062
   392
    Wayland_FiniMouse ();
gabomdq@8062
   393
linkmauve@9467
   394
    for (i = 0; i < _this->num_displays; ++i) {
linkmauve@9467
   395
        SDL_VideoDisplay *display = &_this->displays[i];
linkmauve@9467
   396
        wl_output_destroy(display->driverdata);
linkmauve@9467
   397
        display->driverdata = NULL;
linkmauve@9467
   398
    }
gabomdq@8062
   399
gabomdq@8062
   400
    Wayland_display_destroy_input(data);
slouken@10304
   401
    Wayland_display_destroy_pointer_constraints(data);
slouken@10304
   402
    Wayland_display_destroy_relative_pointer_manager(data);
gabomdq@8062
   403
gabomdq@8062
   404
    if (data->xkb_context) {
gabomdq@8104
   405
        WAYLAND_xkb_context_unref(data->xkb_context);
gabomdq@8062
   406
        data->xkb_context = NULL;
gabomdq@8062
   407
    }
gabomdq@8082
   408
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   409
    if (data->windowmanager)
gabomdq@8082
   410
        qt_windowmanager_destroy(data->windowmanager);
gabomdq@8082
   411
gabomdq@8082
   412
    if (data->surface_extension)
gabomdq@8082
   413
        qt_surface_extension_destroy(data->surface_extension);
gabomdq@8082
   414
gabomdq@8082
   415
    Wayland_touch_destroy(data);
gabomdq@8082
   416
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8062
   417
gabomdq@8062
   418
    if (data->shm)
gabomdq@8062
   419
        wl_shm_destroy(data->shm);
gabomdq@8062
   420
gabomdq@8062
   421
    if (data->cursor_theme)
gabomdq@8104
   422
        WAYLAND_wl_cursor_theme_destroy(data->cursor_theme);
gabomdq@8062
   423
gabomdq@8062
   424
    if (data->shell)
gabomdq@8062
   425
        wl_shell_destroy(data->shell);
gabomdq@8062
   426
gabomdq@8062
   427
    if (data->compositor)
gabomdq@8062
   428
        wl_compositor_destroy(data->compositor);
gabomdq@8062
   429
linkmauve@9467
   430
    if (data->registry)
linkmauve@9467
   431
        wl_registry_destroy(data->registry);
linkmauve@9467
   432
gabomdq@8062
   433
    if (data->display) {
gabomdq@8104
   434
        WAYLAND_wl_display_flush(data->display);
gabomdq@8104
   435
        WAYLAND_wl_display_disconnect(data->display);
gabomdq@8062
   436
    }
gabomdq@8062
   437
hadess@10302
   438
    SDL_free(data->classname);
gabomdq@8062
   439
    free(data);
gabomdq@8062
   440
    _this->driverdata = NULL;
gabomdq@8062
   441
}
gabomdq@8062
   442
icculus@8116
   443
#endif /* SDL_VIDEO_DRIVER_WAYLAND */
icculus@8116
   444
gabomdq@8062
   445
/* vi: set ts=4 sw=4 expandtab: */