src/video/wayland/SDL_waylandvideo.c
author Arne Janbu <arnej@arnej.de>
Sat, 10 Jan 2015 13:47:37 +0100
changeset 9362 dfd8202eb9a7
parent 8160 71639d445b59
child 9467 975453c4e217
permissions -rw-r--r--
Fix build on Linux when wayland is enabled

Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2838
gabomdq@8062
     1
/*
gabomdq@8062
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 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
gabomdq@8062
    38
#include <fcntl.h>
gabomdq@8062
    39
#include <xkbcommon/xkbcommon.h>
gabomdq@8062
    40
gabomdq@8104
    41
#include "SDL_waylanddyn.h"
gabomdq@8104
    42
#include <wayland-util.h>
gabomdq@8104
    43
gabomdq@8062
    44
#define WAYLANDVID_DRIVER_NAME "wayland"
gabomdq@8062
    45
gabomdq@8062
    46
struct wayland_mode {
gabomdq@8062
    47
    SDL_DisplayMode mode;
gabomdq@8062
    48
    struct wl_list link;
gabomdq@8062
    49
};
gabomdq@8062
    50
gabomdq@8062
    51
/* Initialization/Query functions */
gabomdq@8062
    52
static int
gabomdq@8062
    53
Wayland_VideoInit(_THIS);
gabomdq@8062
    54
gabomdq@8062
    55
static void
gabomdq@8062
    56
Wayland_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display);
gabomdq@8062
    57
static int
gabomdq@8062
    58
Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
gabomdq@8062
    59
gabomdq@8062
    60
static void
gabomdq@8062
    61
Wayland_VideoQuit(_THIS);
gabomdq@8062
    62
gabomdq@8062
    63
/* Wayland driver bootstrap functions */
gabomdq@8062
    64
static int
gabomdq@8062
    65
Wayland_Available(void)
gabomdq@8062
    66
{
gabomdq@8062
    67
    struct wl_display *display = NULL;
gabomdq@8104
    68
    if (SDL_WAYLAND_LoadSymbols()) {
gabomdq@8104
    69
        display = WAYLAND_wl_display_connect(NULL);
gabomdq@8104
    70
        if (display != NULL) {
gabomdq@8104
    71
            WAYLAND_wl_display_disconnect(display);
gabomdq@8104
    72
        }
gabomdq@8104
    73
        SDL_WAYLAND_UnloadSymbols();
gabomdq@8062
    74
    }
gabomdq@8062
    75
gabomdq@8062
    76
    return (display != NULL);
gabomdq@8062
    77
}
gabomdq@8062
    78
gabomdq@8062
    79
static void
gabomdq@8062
    80
Wayland_DeleteDevice(SDL_VideoDevice *device)
gabomdq@8062
    81
{
gabomdq@8062
    82
    SDL_free(device);
gabomdq@8104
    83
    SDL_WAYLAND_UnloadSymbols();
gabomdq@8062
    84
}
gabomdq@8062
    85
gabomdq@8062
    86
static SDL_VideoDevice *
gabomdq@8062
    87
Wayland_CreateDevice(int devindex)
gabomdq@8062
    88
{
gabomdq@8062
    89
    SDL_VideoDevice *device;
gabomdq@8104
    90
    
gabomdq@8104
    91
    if (!SDL_WAYLAND_LoadSymbols()) {
gabomdq@8104
    92
        return NULL;
gabomdq@8104
    93
    }
gabomdq@8062
    94
gabomdq@8062
    95
    /* Initialize all variables that we clean on shutdown */
gabomdq@8062
    96
    device = SDL_calloc(1, sizeof(SDL_VideoDevice));
gabomdq@8062
    97
    if (!device) {
icculus@8160
    98
        SDL_WAYLAND_UnloadSymbols();
gabomdq@8062
    99
        SDL_OutOfMemory();
gabomdq@8062
   100
        return NULL;
gabomdq@8062
   101
    }
gabomdq@8062
   102
gabomdq@8062
   103
    /* Set the function pointers */
gabomdq@8062
   104
    device->VideoInit = Wayland_VideoInit;
gabomdq@8062
   105
    device->VideoQuit = Wayland_VideoQuit;
gabomdq@8062
   106
    device->SetDisplayMode = Wayland_SetDisplayMode;
gabomdq@8062
   107
    device->GetDisplayModes = Wayland_GetDisplayModes;
gabomdq@8062
   108
    device->GetWindowWMInfo = Wayland_GetWindowWMInfo;
gabomdq@8062
   109
gabomdq@8062
   110
    device->PumpEvents = Wayland_PumpEvents;
gabomdq@8062
   111
gabomdq@8062
   112
    device->GL_SwapWindow = Wayland_GLES_SwapWindow;
gabomdq@8062
   113
    device->GL_GetSwapInterval = Wayland_GLES_GetSwapInterval;
gabomdq@8062
   114
    device->GL_SetSwapInterval = Wayland_GLES_SetSwapInterval;
gabomdq@8062
   115
    device->GL_MakeCurrent = Wayland_GLES_MakeCurrent;
gabomdq@8062
   116
    device->GL_CreateContext = Wayland_GLES_CreateContext;
gabomdq@8062
   117
    device->GL_LoadLibrary = Wayland_GLES_LoadLibrary;
gabomdq@8062
   118
    device->GL_UnloadLibrary = Wayland_GLES_UnloadLibrary;
gabomdq@8062
   119
    device->GL_GetProcAddress = Wayland_GLES_GetProcAddress;
gabomdq@8062
   120
    device->GL_DeleteContext = Wayland_GLES_DeleteContext;
gabomdq@8062
   121
gabomdq@8062
   122
    device->CreateWindow = Wayland_CreateWindow;
gabomdq@8062
   123
    device->ShowWindow = Wayland_ShowWindow;
gabomdq@8062
   124
    device->SetWindowFullscreen = Wayland_SetWindowFullscreen;
gabomdq@8062
   125
    device->SetWindowSize = Wayland_SetWindowSize;
gabomdq@8062
   126
    device->DestroyWindow = Wayland_DestroyWindow;
gabomdq@8062
   127
gabomdq@8062
   128
    device->free = Wayland_DeleteDevice;
gabomdq@8062
   129
gabomdq@8062
   130
    return device;
gabomdq@8062
   131
}
gabomdq@8062
   132
gabomdq@8062
   133
VideoBootStrap Wayland_bootstrap = {
gabomdq@8062
   134
    WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
gabomdq@8062
   135
    Wayland_Available, Wayland_CreateDevice
gabomdq@8062
   136
};
gabomdq@8062
   137
gabomdq@8062
   138
static void
gabomdq@8062
   139
wayland_add_mode(SDL_VideoData *d, SDL_DisplayMode m)
gabomdq@8062
   140
{
gabomdq@8062
   141
    struct wayland_mode *mode;
gabomdq@8062
   142
gabomdq@8062
   143
    /* Check for duplicate mode */
gabomdq@8062
   144
    wl_list_for_each(mode, &d->modes_list, link)
gabomdq@8062
   145
        if (mode->mode.w == m.w && mode->mode.h == m.h &&
gabomdq@8062
   146
	    mode->mode.refresh_rate == m.refresh_rate)
gabomdq@8062
   147
	    return;
gabomdq@8062
   148
gabomdq@8062
   149
    /* Add new mode to the list */
gabomdq@8104
   150
    mode = (struct wayland_mode *) SDL_calloc(1, sizeof *mode);
gabomdq@8062
   151
gabomdq@8062
   152
    if (!mode)
gabomdq@8062
   153
	return;
gabomdq@8062
   154
gabomdq@8062
   155
    mode->mode = m;
gabomdq@8104
   156
    WAYLAND_wl_list_insert(&d->modes_list, &mode->link);
gabomdq@8062
   157
}
gabomdq@8062
   158
gabomdq@8062
   159
static void
gabomdq@8062
   160
display_handle_geometry(void *data,
gabomdq@8062
   161
                        struct wl_output *output,
gabomdq@8062
   162
                        int x, int y,
gabomdq@8062
   163
                        int physical_width,
gabomdq@8062
   164
                        int physical_height,
gabomdq@8062
   165
                        int subpixel,
gabomdq@8062
   166
                        const char *make,
gabomdq@8062
   167
                        const char *model,
gabomdq@8062
   168
                        int transform)
gabomdq@8062
   169
gabomdq@8062
   170
{
gabomdq@8062
   171
    SDL_VideoData *d = data;
gabomdq@8062
   172
gabomdq@8062
   173
    d->screen_allocation.x = x;
gabomdq@8062
   174
    d->screen_allocation.y = y;
gabomdq@8062
   175
}
gabomdq@8062
   176
gabomdq@8062
   177
static void
gabomdq@8062
   178
display_handle_mode(void *data,
gabomdq@8062
   179
                    struct wl_output *wl_output,
gabomdq@8062
   180
                    uint32_t flags,
gabomdq@8062
   181
                    int width,
gabomdq@8062
   182
                    int height,
gabomdq@8062
   183
                    int refresh)
gabomdq@8062
   184
{
gabomdq@8062
   185
    SDL_VideoData *d = data;
gabomdq@8062
   186
    SDL_DisplayMode mode;
gabomdq@8062
   187
gabomdq@8062
   188
    SDL_zero(mode);
gabomdq@8062
   189
    mode.w = width;
gabomdq@8062
   190
    mode.h = height;
gabomdq@8062
   191
    mode.refresh_rate = refresh / 1000;
gabomdq@8062
   192
gabomdq@8062
   193
    wayland_add_mode(d, mode);
gabomdq@8062
   194
gabomdq@8062
   195
    if (flags & WL_OUTPUT_MODE_CURRENT) {
gabomdq@8062
   196
        d->screen_allocation.width = width;
gabomdq@8062
   197
        d->screen_allocation.height = height;
gabomdq@8062
   198
    }
gabomdq@8062
   199
}
gabomdq@8062
   200
gabomdq@8062
   201
static const struct wl_output_listener output_listener = {
gabomdq@8062
   202
    display_handle_geometry,
gabomdq@8062
   203
    display_handle_mode
gabomdq@8062
   204
};
gabomdq@8062
   205
gabomdq@8062
   206
static void
gabomdq@8062
   207
shm_handle_format(void *data,
gabomdq@8062
   208
                  struct wl_shm *shm,
gabomdq@8062
   209
                  uint32_t format)
gabomdq@8062
   210
{
gabomdq@8062
   211
    SDL_VideoData *d = data;
gabomdq@8062
   212
gabomdq@8062
   213
    d->shm_formats |= (1 << format);
gabomdq@8062
   214
}
gabomdq@8062
   215
gabomdq@8062
   216
static const struct wl_shm_listener shm_listener = {
gabomdq@8062
   217
    shm_handle_format
gabomdq@8062
   218
};
gabomdq@8062
   219
gabomdq@8082
   220
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   221
static void
gabomdq@8082
   222
windowmanager_hints(void *data, struct qt_windowmanager *qt_windowmanager,
gabomdq@8082
   223
        int32_t show_is_fullscreen)
gabomdq@8082
   224
{
gabomdq@8082
   225
}
gabomdq@8082
   226
gabomdq@8082
   227
static void
gabomdq@8082
   228
windowmanager_quit(void *data, struct qt_windowmanager *qt_windowmanager)
gabomdq@8082
   229
{
gabomdq@8082
   230
    SDL_SendQuit();
gabomdq@8082
   231
}
gabomdq@8082
   232
gabomdq@8082
   233
static const struct qt_windowmanager_listener windowmanager_listener = {
gabomdq@8082
   234
    windowmanager_hints,
gabomdq@8082
   235
    windowmanager_quit,
gabomdq@8082
   236
};
gabomdq@8082
   237
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8082
   238
gabomdq@8062
   239
static void
gabomdq@8062
   240
display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
gabomdq@8062
   241
					const char *interface, uint32_t version)
gabomdq@8062
   242
{
gabomdq@8062
   243
    SDL_VideoData *d = data;
gabomdq@8104
   244
    
gabomdq@8062
   245
    if (strcmp(interface, "wl_compositor") == 0) {
gabomdq@8062
   246
        d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, 1);
gabomdq@8062
   247
    } else if (strcmp(interface, "wl_output") == 0) {
gabomdq@8062
   248
        d->output = wl_registry_bind(d->registry, id, &wl_output_interface, 1);
gabomdq@8062
   249
        wl_output_add_listener(d->output, &output_listener, d);
gabomdq@8062
   250
    } else if (strcmp(interface, "wl_seat") == 0) {
gabomdq@8062
   251
        Wayland_display_add_input(d, id);
gabomdq@8062
   252
    } else if (strcmp(interface, "wl_shell") == 0) {
gabomdq@8062
   253
        d->shell = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
gabomdq@8062
   254
    } else if (strcmp(interface, "wl_shm") == 0) {
gabomdq@8062
   255
        d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
gabomdq@8104
   256
        d->cursor_theme = WAYLAND_wl_cursor_theme_load(NULL, 32, d->shm);
gabomdq@8104
   257
        d->default_cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
gabomdq@8062
   258
        wl_shm_add_listener(d->shm, &shm_listener, d);
gabomdq@8082
   259
    
gabomdq@8082
   260
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   261
    } else if (strcmp(interface, "qt_touch_extension") == 0) {
gabomdq@8082
   262
        Wayland_touch_create(d, id);
gabomdq@8082
   263
    } else if (strcmp(interface, "qt_surface_extension") == 0) {
gabomdq@8082
   264
        d->surface_extension = wl_registry_bind(registry, id,
gabomdq@8082
   265
                &qt_surface_extension_interface, 1);
gabomdq@8082
   266
    } else if (strcmp(interface, "qt_windowmanager") == 0) {
gabomdq@8082
   267
        d->windowmanager = wl_registry_bind(registry, id,
gabomdq@8082
   268
                &qt_windowmanager_interface, 1);
gabomdq@8082
   269
        qt_windowmanager_add_listener(d->windowmanager, &windowmanager_listener, d);
gabomdq@8082
   270
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8062
   271
    }
gabomdq@8062
   272
}
gabomdq@8062
   273
gabomdq@8062
   274
static const struct wl_registry_listener registry_listener = {
gabomdq@8062
   275
	display_handle_global
gabomdq@8062
   276
};
gabomdq@8062
   277
gabomdq@8062
   278
int
gabomdq@8062
   279
Wayland_VideoInit(_THIS)
gabomdq@8062
   280
{
gabomdq@8062
   281
    SDL_VideoData *data;
gabomdq@8104
   282
    SDL_VideoDisplay display;
gabomdq@8104
   283
    SDL_DisplayMode mode;
gabomdq@8104
   284
    int i;
gabomdq@8104
   285
    
gabomdq@8062
   286
    data = malloc(sizeof *data);
gabomdq@8062
   287
    if (data == NULL)
gabomdq@8062
   288
        return 0;
gabomdq@8062
   289
    memset(data, 0, sizeof *data);
gabomdq@8062
   290
gabomdq@8062
   291
    _this->driverdata = data;
gabomdq@8062
   292
gabomdq@8104
   293
    WAYLAND_wl_list_init(&data->modes_list);
gabomdq@8062
   294
    
gabomdq@8104
   295
    data->display = WAYLAND_wl_display_connect(NULL);
gabomdq@8062
   296
    if (data->display == NULL) {
gabomdq@8062
   297
        SDL_SetError("Failed to connect to a Wayland display");
gabomdq@8062
   298
        return 0;
gabomdq@8062
   299
    }
gabomdq@8062
   300
gabomdq@8062
   301
    data->registry = wl_display_get_registry(data->display);
gabomdq@8104
   302
   
gabomdq@8104
   303
    if ( data->registry == NULL) {
gabomdq@8104
   304
        SDL_SetError("Failed to get the Wayland registry");
gabomdq@8104
   305
        return 0;
gabomdq@8104
   306
    }
gabomdq@8104
   307
    
gabomdq@8062
   308
    wl_registry_add_listener(data->registry, &registry_listener, data);
gabomdq@8062
   309
gabomdq@8104
   310
    for (i=0; i < 100; i++) {
gabomdq@8104
   311
        if (data->screen_allocation.width != 0 || WAYLAND_wl_display_get_error(data->display) != 0) {
gabomdq@8104
   312
            break;
gabomdq@8104
   313
        }
gabomdq@8104
   314
        WAYLAND_wl_display_dispatch(data->display);
gabomdq@8104
   315
    }
gabomdq@8104
   316
    
gabomdq@8104
   317
    if (data->screen_allocation.width == 0) {
gabomdq@8104
   318
        SDL_SetError("Failed while waiting for screen allocation: %d ", WAYLAND_wl_display_get_error(data->display));
gabomdq@8104
   319
        return 0;
gabomdq@8104
   320
    }
gabomdq@8062
   321
gabomdq@8104
   322
    data->xkb_context = WAYLAND_xkb_context_new(0);
gabomdq@8062
   323
    if (!data->xkb_context) {
gabomdq@8062
   324
        SDL_SetError("Failed to create XKB context");
gabomdq@8062
   325
        return 0;
gabomdq@8062
   326
    }
gabomdq@8062
   327
gabomdq@8062
   328
    /* Use a fake 32-bpp desktop mode */
gabomdq@8062
   329
    mode.format = SDL_PIXELFORMAT_RGB888;
gabomdq@8062
   330
    mode.w = data->screen_allocation.width;
gabomdq@8062
   331
    mode.h = data->screen_allocation.height;
gabomdq@8062
   332
    mode.refresh_rate = 0;
gabomdq@8062
   333
    mode.driverdata = NULL;
gabomdq@8062
   334
    wayland_add_mode(data, mode);
gabomdq@8062
   335
    SDL_zero(display);
gabomdq@8062
   336
    display.desktop_mode = mode;
gabomdq@8062
   337
    display.current_mode = mode;
gabomdq@8062
   338
    display.driverdata = NULL;
gabomdq@8062
   339
    SDL_AddVideoDisplay(&display);
gabomdq@8062
   340
gabomdq@8062
   341
    Wayland_InitMouse ();
gabomdq@8062
   342
gabomdq@8104
   343
    WAYLAND_wl_display_flush(data->display);
gabomdq@8062
   344
gabomdq@8062
   345
    return 0;
gabomdq@8062
   346
}
gabomdq@8062
   347
gabomdq@8062
   348
static void
gabomdq@8062
   349
Wayland_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
gabomdq@8062
   350
{
gabomdq@8062
   351
    SDL_VideoData *data = _this->driverdata;
gabomdq@8062
   352
    SDL_DisplayMode mode;
gabomdq@8062
   353
    struct wayland_mode *m;
gabomdq@8062
   354
gabomdq@8062
   355
    Wayland_PumpEvents(_this);
gabomdq@8062
   356
gabomdq@8062
   357
    wl_list_for_each(m, &data->modes_list, link) {
gabomdq@8062
   358
        m->mode.format = SDL_PIXELFORMAT_RGB888;
gabomdq@8062
   359
        SDL_AddDisplayMode(sdl_display, &m->mode);
gabomdq@8062
   360
        m->mode.format = SDL_PIXELFORMAT_RGBA8888;
gabomdq@8062
   361
        SDL_AddDisplayMode(sdl_display, &m->mode);
gabomdq@8062
   362
    }
gabomdq@8062
   363
gabomdq@8062
   364
    mode.w = data->screen_allocation.width;
gabomdq@8062
   365
    mode.h = data->screen_allocation.height;
gabomdq@8062
   366
    mode.refresh_rate = 0;
gabomdq@8062
   367
    mode.driverdata = NULL;
gabomdq@8062
   368
gabomdq@8062
   369
    mode.format = SDL_PIXELFORMAT_RGB888;
gabomdq@8062
   370
    SDL_AddDisplayMode(sdl_display, &mode);
gabomdq@8062
   371
    mode.format = SDL_PIXELFORMAT_RGBA8888;
gabomdq@8062
   372
    SDL_AddDisplayMode(sdl_display, &mode);
gabomdq@8062
   373
}
gabomdq@8062
   374
gabomdq@8062
   375
static int
gabomdq@8062
   376
Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
gabomdq@8062
   377
{
gabomdq@8062
   378
    return 0;
gabomdq@8062
   379
}
gabomdq@8062
   380
gabomdq@8062
   381
void
gabomdq@8062
   382
Wayland_VideoQuit(_THIS)
gabomdq@8062
   383
{
gabomdq@8062
   384
    SDL_VideoData *data = _this->driverdata;
gabomdq@8062
   385
    struct wayland_mode *t, *m;
gabomdq@8062
   386
gabomdq@8062
   387
    Wayland_FiniMouse ();
gabomdq@8062
   388
gabomdq@8062
   389
    if (data->output)
gabomdq@8062
   390
        wl_output_destroy(data->output);
gabomdq@8062
   391
gabomdq@8062
   392
    Wayland_display_destroy_input(data);
gabomdq@8062
   393
gabomdq@8062
   394
    if (data->xkb_context) {
gabomdq@8104
   395
        WAYLAND_xkb_context_unref(data->xkb_context);
gabomdq@8062
   396
        data->xkb_context = NULL;
gabomdq@8062
   397
    }
gabomdq@8082
   398
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   399
    if (data->windowmanager)
gabomdq@8082
   400
        qt_windowmanager_destroy(data->windowmanager);
gabomdq@8082
   401
gabomdq@8082
   402
    if (data->surface_extension)
gabomdq@8082
   403
        qt_surface_extension_destroy(data->surface_extension);
gabomdq@8082
   404
gabomdq@8082
   405
    Wayland_touch_destroy(data);
gabomdq@8082
   406
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8062
   407
gabomdq@8062
   408
    if (data->shm)
gabomdq@8062
   409
        wl_shm_destroy(data->shm);
gabomdq@8062
   410
gabomdq@8062
   411
    if (data->cursor_theme)
gabomdq@8104
   412
        WAYLAND_wl_cursor_theme_destroy(data->cursor_theme);
gabomdq@8062
   413
gabomdq@8062
   414
    if (data->shell)
gabomdq@8062
   415
        wl_shell_destroy(data->shell);
gabomdq@8062
   416
gabomdq@8062
   417
    if (data->compositor)
gabomdq@8062
   418
        wl_compositor_destroy(data->compositor);
gabomdq@8062
   419
gabomdq@8062
   420
    if (data->display) {
gabomdq@8104
   421
        WAYLAND_wl_display_flush(data->display);
gabomdq@8104
   422
        WAYLAND_wl_display_disconnect(data->display);
gabomdq@8062
   423
    }
gabomdq@8062
   424
    
gabomdq@8062
   425
    wl_list_for_each_safe(m, t, &data->modes_list, link) {
gabomdq@8104
   426
        WAYLAND_wl_list_remove(&m->link);
gabomdq@8062
   427
        free(m);
gabomdq@8062
   428
    }
gabomdq@8062
   429
gabomdq@8062
   430
gabomdq@8062
   431
    free(data);
gabomdq@8062
   432
    _this->driverdata = NULL;
gabomdq@8062
   433
}
gabomdq@8062
   434
icculus@8116
   435
#endif /* SDL_VIDEO_DRIVER_WAYLAND */
icculus@8116
   436
gabomdq@8062
   437
/* vi: set ts=4 sw=4 expandtab: */