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