src/video/wayland/SDL_waylandvideo.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 30 Oct 2016 21:01:33 +0100
changeset 10563 e3d84016cb79
parent 10530 2a3f8bc23daa
child 10583 974f8ebcb819
permissions -rw-r--r--
Fixed outdated info in README.
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;
slouken@10492
   172
    device->MaximizeWindow = Wayland_MaximizeWindow;
slouken@10492
   173
    device->RestoreWindow = Wayland_RestoreWindow;
gabomdq@8062
   174
    device->SetWindowSize = Wayland_SetWindowSize;
slouken@10492
   175
    device->SetWindowTitle = Wayland_SetWindowTitle;
gabomdq@8062
   176
    device->DestroyWindow = Wayland_DestroyWindow;
icculus@9554
   177
    device->SetWindowHitTest = Wayland_SetWindowHitTest;
gabomdq@8062
   178
gabomdq@8062
   179
    device->free = Wayland_DeleteDevice;
gabomdq@8062
   180
gabomdq@8062
   181
    return device;
gabomdq@8062
   182
}
gabomdq@8062
   183
gabomdq@8062
   184
VideoBootStrap Wayland_bootstrap = {
gabomdq@8062
   185
    WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
gabomdq@8062
   186
    Wayland_Available, Wayland_CreateDevice
gabomdq@8062
   187
};
gabomdq@8062
   188
gabomdq@8062
   189
static void
gabomdq@8062
   190
display_handle_geometry(void *data,
gabomdq@8062
   191
                        struct wl_output *output,
gabomdq@8062
   192
                        int x, int y,
gabomdq@8062
   193
                        int physical_width,
gabomdq@8062
   194
                        int physical_height,
gabomdq@8062
   195
                        int subpixel,
gabomdq@8062
   196
                        const char *make,
gabomdq@8062
   197
                        const char *model,
gabomdq@8062
   198
                        int transform)
gabomdq@8062
   199
gabomdq@8062
   200
{
linkmauve@9467
   201
    SDL_VideoDisplay *display = data;
gabomdq@8062
   202
philipp@10187
   203
    display->name = SDL_strdup(model);
linkmauve@9467
   204
    display->driverdata = output;
gabomdq@8062
   205
}
gabomdq@8062
   206
gabomdq@8062
   207
static void
gabomdq@8062
   208
display_handle_mode(void *data,
linkmauve@9467
   209
                    struct wl_output *output,
gabomdq@8062
   210
                    uint32_t flags,
gabomdq@8062
   211
                    int width,
gabomdq@8062
   212
                    int height,
gabomdq@8062
   213
                    int refresh)
gabomdq@8062
   214
{
linkmauve@9467
   215
    SDL_VideoDisplay *display = data;
gabomdq@8062
   216
    SDL_DisplayMode mode;
gabomdq@8062
   217
gabomdq@8062
   218
    SDL_zero(mode);
gabomdq@8062
   219
    mode.w = width;
gabomdq@8062
   220
    mode.h = height;
linkmauve@9467
   221
    mode.refresh_rate = refresh / 1000; // mHz to Hz
linkmauve@9467
   222
    SDL_AddDisplayMode(display, &mode);
gabomdq@8062
   223
gabomdq@8062
   224
    if (flags & WL_OUTPUT_MODE_CURRENT) {
linkmauve@9467
   225
        display->current_mode = mode;
linkmauve@9467
   226
        display->desktop_mode = mode;
gabomdq@8062
   227
    }
gabomdq@8062
   228
}
gabomdq@8062
   229
linkmauve@9467
   230
static void
linkmauve@9467
   231
display_handle_done(void *data,
linkmauve@9467
   232
                    struct wl_output *output)
linkmauve@9467
   233
{
linkmauve@9467
   234
    SDL_VideoDisplay *display = data;
linkmauve@9467
   235
    SDL_AddVideoDisplay(display);
linkmauve@9467
   236
    SDL_free(display->name);
linkmauve@9467
   237
    SDL_free(display);
linkmauve@9467
   238
}
linkmauve@9467
   239
linkmauve@9467
   240
static void
linkmauve@9467
   241
display_handle_scale(void *data,
linkmauve@9467
   242
                     struct wl_output *output,
linkmauve@9467
   243
                     int32_t factor)
linkmauve@9467
   244
{
linkmauve@9467
   245
    // TODO: do HiDPI stuff.
linkmauve@9467
   246
}
linkmauve@9467
   247
gabomdq@8062
   248
static const struct wl_output_listener output_listener = {
gabomdq@8062
   249
    display_handle_geometry,
linkmauve@9467
   250
    display_handle_mode,
linkmauve@9467
   251
    display_handle_done,
linkmauve@9467
   252
    display_handle_scale
gabomdq@8062
   253
};
gabomdq@8062
   254
gabomdq@8062
   255
static void
linkmauve@9467
   256
Wayland_add_display(SDL_VideoData *d, uint32_t id)
gabomdq@8062
   257
{
icculus@9472
   258
    struct wl_output *output;
linkmauve@9467
   259
    SDL_VideoDisplay *display = SDL_malloc(sizeof *display);
linkmauve@9467
   260
    if (!display) {
linkmauve@9467
   261
        SDL_OutOfMemory();
linkmauve@9467
   262
        return;
linkmauve@9467
   263
    }
linkmauve@9467
   264
    SDL_zero(*display);
gabomdq@8062
   265
icculus@9472
   266
    output = wl_registry_bind(d->registry, id, &wl_output_interface, 2);
linkmauve@9467
   267
    if (!output) {
linkmauve@9467
   268
        SDL_SetError("Failed to retrieve output.");
linkmauve@9467
   269
        return;
linkmauve@9467
   270
    }
gabomdq@8062
   271
linkmauve@9467
   272
    wl_output_add_listener(output, &output_listener, display);
linkmauve@9467
   273
}
gabomdq@8062
   274
gabomdq@8082
   275
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   276
static void
gabomdq@8082
   277
windowmanager_hints(void *data, struct qt_windowmanager *qt_windowmanager,
gabomdq@8082
   278
        int32_t show_is_fullscreen)
gabomdq@8082
   279
{
gabomdq@8082
   280
}
gabomdq@8082
   281
gabomdq@8082
   282
static void
gabomdq@8082
   283
windowmanager_quit(void *data, struct qt_windowmanager *qt_windowmanager)
gabomdq@8082
   284
{
gabomdq@8082
   285
    SDL_SendQuit();
gabomdq@8082
   286
}
gabomdq@8082
   287
gabomdq@8082
   288
static const struct qt_windowmanager_listener windowmanager_listener = {
gabomdq@8082
   289
    windowmanager_hints,
gabomdq@8082
   290
    windowmanager_quit,
gabomdq@8082
   291
};
gabomdq@8082
   292
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8082
   293
gabomdq@8062
   294
static void
gabomdq@8062
   295
display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
linkmauve@9467
   296
                      const char *interface, uint32_t version)
gabomdq@8062
   297
{
gabomdq@8062
   298
    SDL_VideoData *d = data;
linkmauve@9467
   299
gabomdq@8062
   300
    if (strcmp(interface, "wl_compositor") == 0) {
gabomdq@8062
   301
        d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, 1);
gabomdq@8062
   302
    } else if (strcmp(interface, "wl_output") == 0) {
linkmauve@9467
   303
        Wayland_add_display(d, id);
gabomdq@8062
   304
    } else if (strcmp(interface, "wl_seat") == 0) {
gabomdq@8062
   305
        Wayland_display_add_input(d, id);
gabomdq@8062
   306
    } else if (strcmp(interface, "wl_shell") == 0) {
gabomdq@8062
   307
        d->shell = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
gabomdq@8062
   308
    } else if (strcmp(interface, "wl_shm") == 0) {
gabomdq@8062
   309
        d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
gabomdq@8104
   310
        d->cursor_theme = WAYLAND_wl_cursor_theme_load(NULL, 32, d->shm);
slouken@10304
   311
    } else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) {
slouken@10304
   312
        Wayland_display_add_relative_pointer_manager(d, id);
slouken@10304
   313
    } else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0) {
slouken@10304
   314
        Wayland_display_add_pointer_constraints(d, id);
gabomdq@8082
   315
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   316
    } else if (strcmp(interface, "qt_touch_extension") == 0) {
gabomdq@8082
   317
        Wayland_touch_create(d, id);
gabomdq@8082
   318
    } else if (strcmp(interface, "qt_surface_extension") == 0) {
gabomdq@8082
   319
        d->surface_extension = wl_registry_bind(registry, id,
gabomdq@8082
   320
                &qt_surface_extension_interface, 1);
gabomdq@8082
   321
    } else if (strcmp(interface, "qt_windowmanager") == 0) {
gabomdq@8082
   322
        d->windowmanager = wl_registry_bind(registry, id,
gabomdq@8082
   323
                &qt_windowmanager_interface, 1);
gabomdq@8082
   324
        qt_windowmanager_add_listener(d->windowmanager, &windowmanager_listener, d);
gabomdq@8082
   325
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8062
   326
    }
gabomdq@8062
   327
}
gabomdq@8062
   328
gabomdq@8062
   329
static const struct wl_registry_listener registry_listener = {
linkmauve@9467
   330
    display_handle_global
gabomdq@8062
   331
};
gabomdq@8062
   332
gabomdq@8062
   333
int
gabomdq@8062
   334
Wayland_VideoInit(_THIS)
gabomdq@8062
   335
{
linkmauve@9467
   336
    SDL_VideoData *data = SDL_malloc(sizeof *data);
gabomdq@8062
   337
    if (data == NULL)
philipp@9484
   338
        return SDL_OutOfMemory();
gabomdq@8062
   339
    memset(data, 0, sizeof *data);
gabomdq@8062
   340
gabomdq@8062
   341
    _this->driverdata = data;
gabomdq@8062
   342
slouken@10530
   343
    data->xkb_context = WAYLAND_xkb_context_new(0);
slouken@10530
   344
    if (!data->xkb_context) {
slouken@10530
   345
        return SDL_SetError("Failed to create XKB context");
slouken@10530
   346
    }
slouken@10530
   347
gabomdq@8104
   348
    data->display = WAYLAND_wl_display_connect(NULL);
gabomdq@8062
   349
    if (data->display == NULL) {
philipp@9484
   350
        return SDL_SetError("Failed to connect to a Wayland display");
gabomdq@8062
   351
    }
gabomdq@8062
   352
gabomdq@8062
   353
    data->registry = wl_display_get_registry(data->display);
linkmauve@9467
   354
    if (data->registry == NULL) {
philipp@9484
   355
        return SDL_SetError("Failed to get the Wayland registry");
gabomdq@8104
   356
    }
linkmauve@9467
   357
gabomdq@8062
   358
    wl_registry_add_listener(data->registry, &registry_listener, data);
gabomdq@8062
   359
linkmauve@9467
   360
    // First roundtrip to receive all registry objects.
icculus@9476
   361
    WAYLAND_wl_display_roundtrip(data->display);
linkmauve@9467
   362
linkmauve@9467
   363
    // Second roundtrip to receive all output events.
icculus@9476
   364
    WAYLAND_wl_display_roundtrip(data->display);
gabomdq@8062
   365
linkmauve@9467
   366
    Wayland_InitMouse();
gabomdq@8062
   367
hadess@10302
   368
    /* Get the surface class name, usually the name of the application */
hadess@10302
   369
    data->classname = get_classname();
hadess@10302
   370
gabomdq@8104
   371
    WAYLAND_wl_display_flush(data->display);
gabomdq@8062
   372
gabomdq@8062
   373
    return 0;
gabomdq@8062
   374
}
gabomdq@8062
   375
gabomdq@8062
   376
static void
gabomdq@8062
   377
Wayland_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
gabomdq@8062
   378
{
linkmauve@9467
   379
    // Nothing to do here, everything was already done in the wl_output
linkmauve@9467
   380
    // callbacks.
gabomdq@8062
   381
}
gabomdq@8062
   382
gabomdq@8062
   383
static int
gabomdq@8062
   384
Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
gabomdq@8062
   385
{
icculus@9469
   386
    return SDL_Unsupported();
gabomdq@8062
   387
}
gabomdq@8062
   388
gabomdq@8062
   389
void
gabomdq@8062
   390
Wayland_VideoQuit(_THIS)
gabomdq@8062
   391
{
gabomdq@8062
   392
    SDL_VideoData *data = _this->driverdata;
linkmauve@9467
   393
    int i;
gabomdq@8062
   394
gabomdq@8062
   395
    Wayland_FiniMouse ();
gabomdq@8062
   396
linkmauve@9467
   397
    for (i = 0; i < _this->num_displays; ++i) {
linkmauve@9467
   398
        SDL_VideoDisplay *display = &_this->displays[i];
linkmauve@9467
   399
        wl_output_destroy(display->driverdata);
linkmauve@9467
   400
        display->driverdata = NULL;
linkmauve@9467
   401
    }
gabomdq@8062
   402
gabomdq@8062
   403
    Wayland_display_destroy_input(data);
slouken@10304
   404
    Wayland_display_destroy_pointer_constraints(data);
slouken@10304
   405
    Wayland_display_destroy_relative_pointer_manager(data);
gabomdq@8062
   406
gabomdq@8062
   407
    if (data->xkb_context) {
gabomdq@8104
   408
        WAYLAND_xkb_context_unref(data->xkb_context);
gabomdq@8062
   409
        data->xkb_context = NULL;
gabomdq@8062
   410
    }
gabomdq@8082
   411
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   412
    if (data->windowmanager)
gabomdq@8082
   413
        qt_windowmanager_destroy(data->windowmanager);
gabomdq@8082
   414
gabomdq@8082
   415
    if (data->surface_extension)
gabomdq@8082
   416
        qt_surface_extension_destroy(data->surface_extension);
gabomdq@8082
   417
gabomdq@8082
   418
    Wayland_touch_destroy(data);
gabomdq@8082
   419
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8062
   420
gabomdq@8062
   421
    if (data->shm)
gabomdq@8062
   422
        wl_shm_destroy(data->shm);
gabomdq@8062
   423
gabomdq@8062
   424
    if (data->cursor_theme)
gabomdq@8104
   425
        WAYLAND_wl_cursor_theme_destroy(data->cursor_theme);
gabomdq@8062
   426
gabomdq@8062
   427
    if (data->shell)
gabomdq@8062
   428
        wl_shell_destroy(data->shell);
gabomdq@8062
   429
gabomdq@8062
   430
    if (data->compositor)
gabomdq@8062
   431
        wl_compositor_destroy(data->compositor);
gabomdq@8062
   432
linkmauve@9467
   433
    if (data->registry)
linkmauve@9467
   434
        wl_registry_destroy(data->registry);
linkmauve@9467
   435
gabomdq@8062
   436
    if (data->display) {
gabomdq@8104
   437
        WAYLAND_wl_display_flush(data->display);
gabomdq@8104
   438
        WAYLAND_wl_display_disconnect(data->display);
gabomdq@8062
   439
    }
gabomdq@8062
   440
hadess@10302
   441
    SDL_free(data->classname);
gabomdq@8062
   442
    free(data);
gabomdq@8062
   443
    _this->driverdata = NULL;
gabomdq@8062
   444
}
gabomdq@8062
   445
icculus@8116
   446
#endif /* SDL_VIDEO_DRIVER_WAYLAND */
icculus@8116
   447
gabomdq@8062
   448
/* vi: set ts=4 sw=4 expandtab: */