src/video/wayland/SDL_waylandvideo.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 02 Feb 2014 00:53:27 -0800
changeset 8149 681eb46b8ac4
parent 8116 f7c2f71251e5
child 8160 71639d445b59
permissions -rw-r--r--
Fixed bug 2374 - Update copyright for 2014...

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