src/video/wayland/SDL_waylandwindow.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 11 Jun 2017 00:50:26 -0400
changeset 11088 69452f9839d5
parent 10737 3406a0f8b041
child 11092 9c9b7b7e46e1
permissions -rw-r--r--
syswm: prevent buffer overflow if SDL and app have different config headers.

This only affects Wayland and DirectFB, as a Unix system generally has X11
support. Other platforms also have different sizes for the C union in
question, but are likely the only target for that platform, etc.

Apps that might run on Wayland or DirectFB will need to be compiled against
new headers from an official 2.0.6 release, or be prepared to force the x11
target, or not use SDL_GetWindowWMInfo().

Fixes Bugzilla #3428.
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 && SDL_VIDEO_OPENGL_EGL
icculus@8116
    25
gabomdq@8062
    26
#include "../SDL_sysvideo.h"
gabomdq@8062
    27
#include "../../events/SDL_windowevents_c.h"
gabomdq@8062
    28
#include "../SDL_egl_c.h"
slouken@10304
    29
#include "SDL_waylandevents_c.h"
gabomdq@8062
    30
#include "SDL_waylandwindow.h"
gabomdq@8062
    31
#include "SDL_waylandvideo.h"
gabomdq@8082
    32
#include "SDL_waylandtouch.h"
arnej@9362
    33
#include "SDL_waylanddyn.h"
m@10614
    34
#include "SDL_hints.h"
gabomdq@8062
    35
gabomdq@8062
    36
static void
gabomdq@8062
    37
handle_ping(void *data, struct wl_shell_surface *shell_surface,
gabomdq@8062
    38
            uint32_t serial)
gabomdq@8062
    39
{
gabomdq@8062
    40
    wl_shell_surface_pong(shell_surface, serial);
gabomdq@8062
    41
}
gabomdq@8062
    42
gabomdq@8062
    43
static void
gabomdq@8062
    44
handle_configure(void *data, struct wl_shell_surface *shell_surface,
gabomdq@8062
    45
                 uint32_t edges, int32_t width, int32_t height)
gabomdq@8062
    46
{
gabomdq@8766
    47
    SDL_WindowData *wind = (SDL_WindowData *)data;
gabomdq@8766
    48
    SDL_Window *window = wind->sdlwindow;
gabomdq@8766
    49
    struct wl_region *region;
gabomdq@8766
    50
slouken@10492
    51
    /* wl_shell_surface spec states that this is a suggestion.
slouken@10492
    52
       Ignore if less than or greater than max/min size. */
slouken@10492
    53
slouken@10492
    54
    if (width == 0 || height == 0) {
slouken@10492
    55
        return;
slouken@10492
    56
    }
slouken@10492
    57
slouken@10492
    58
    if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
slouken@10492
    59
        if ((window->flags & SDL_WINDOW_RESIZABLE)) {
slouken@10492
    60
            if (window->max_w > 0) {
slouken@10492
    61
                width = SDL_min(width, window->max_w);
slouken@10492
    62
            } 
slouken@10492
    63
            width = SDL_max(width, window->min_w);
slouken@10492
    64
slouken@10492
    65
            if (window->max_h > 0) {
slouken@10492
    66
                height = SDL_min(height, window->max_h);
slouken@10492
    67
            }
slouken@10492
    68
            height = SDL_max(height, window->min_h);
slouken@10492
    69
        } else {
slouken@10492
    70
            return;
slouken@10492
    71
        }
slouken@10492
    72
    }
slouken@10492
    73
slouken@10492
    74
    if (width == window->w && height == window->h) {
slouken@10492
    75
        return;
slouken@10492
    76
    }
slouken@10492
    77
gabomdq@8766
    78
    window->w = width;
gabomdq@8766
    79
    window->h = height;
gabomdq@8766
    80
    WAYLAND_wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
gabomdq@8766
    81
gabomdq@8766
    82
    region = wl_compositor_create_region(wind->waylandData->compositor);
gabomdq@8766
    83
    wl_region_add(region, 0, 0, window->w, window->h);
gabomdq@8766
    84
    wl_surface_set_opaque_region(wind->surface, region);
gabomdq@8766
    85
    wl_region_destroy(region);
gabomdq@8766
    86
    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, window->w, window->h);
gabomdq@8062
    87
}
gabomdq@8062
    88
gabomdq@8062
    89
static void
gabomdq@8062
    90
handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
gabomdq@8062
    91
{
gabomdq@8062
    92
}
gabomdq@8062
    93
gabomdq@8062
    94
static const struct wl_shell_surface_listener shell_surface_listener = {
gabomdq@8062
    95
    handle_ping,
gabomdq@8062
    96
    handle_configure,
gabomdq@8062
    97
    handle_popup_done
gabomdq@8062
    98
};
gabomdq@8062
    99
gabomdq@8082
   100
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   101
static void
gabomdq@8082
   102
handle_onscreen_visibility(void *data,
gabomdq@8082
   103
        struct qt_extended_surface *qt_extended_surface, int32_t visible)
gabomdq@8082
   104
{
gabomdq@8082
   105
}
gabomdq@8082
   106
gabomdq@8082
   107
static void
gabomdq@8082
   108
handle_set_generic_property(void *data,
gabomdq@8082
   109
        struct qt_extended_surface *qt_extended_surface, const char *name,
gabomdq@8082
   110
        struct wl_array *value)
gabomdq@8082
   111
{
gabomdq@8082
   112
}
gabomdq@8082
   113
gabomdq@8082
   114
static void
gabomdq@8082
   115
handle_close(void *data, struct qt_extended_surface *qt_extended_surface)
gabomdq@8082
   116
{
gabomdq@8082
   117
    SDL_WindowData *window = (SDL_WindowData *)data;
gabomdq@8082
   118
    SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0);
gabomdq@8082
   119
}
gabomdq@8082
   120
gabomdq@8082
   121
static const struct qt_extended_surface_listener extended_surface_listener = {
gabomdq@8082
   122
    handle_onscreen_visibility,
gabomdq@8082
   123
    handle_set_generic_property,
gabomdq@8082
   124
    handle_close,
gabomdq@8082
   125
};
gabomdq@8082
   126
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8082
   127
gabomdq@8062
   128
SDL_bool
gabomdq@8062
   129
Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
gabomdq@8062
   130
{
gabomdq@8062
   131
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
icculus@11088
   132
    const Uint32 version = ((((Uint32) info->version.major) * 1000000) +
icculus@11088
   133
                            (((Uint32) info->version.minor) * 10000) +
icculus@11088
   134
                            (((Uint32) info->version.patch)));
icculus@11088
   135
icculus@11088
   136
    /* Before 2.0.6, it was possible to build an SDL with Wayland support
icculus@11088
   137
       (SDL_SysWMinfo will be large enough to hold Wayland info), but build
icculus@11088
   138
       your app against SDL headers that didn't have Wayland support
icculus@11088
   139
       (SDL_SysWMinfo could be smaller than Wayland needs. This would lead
icculus@11088
   140
       to an app properly using SDL_GetWindowWMInfo() but we'd accidentally
icculus@11088
   141
       overflow memory on the stack or heap. To protect against this, we've
icculus@11088
   142
       padded out the struct unconditionally in the headers and Wayland will
icculus@11088
   143
       just return an error for older apps using this function. Those apps
icculus@11088
   144
       will need to be recompiled against newer headers or not use Wayland,
icculus@11088
   145
       maybe by forcing SDL_VIDEODRIVER=x11. */
icculus@11088
   146
    if (version < 2000006) {
icculus@11088
   147
        info->subsystem = SDL_SYSWM_UNKNOWN;
icculus@11088
   148
        return SDL_FALSE;
icculus@11088
   149
    }
gabomdq@8062
   150
gabomdq@8062
   151
    info->info.wl.display = data->waylandData->display;
gabomdq@8062
   152
    info->info.wl.surface = data->surface;
gabomdq@8062
   153
    info->info.wl.shell_surface = data->shell_surface;
gabomdq@8062
   154
    info->subsystem = SDL_SYSWM_WAYLAND;
gabomdq@8062
   155
gabomdq@8062
   156
    return SDL_TRUE;
gabomdq@8062
   157
}
gabomdq@8062
   158
icculus@9554
   159
int
icculus@9554
   160
Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
icculus@9554
   161
{
icculus@9554
   162
    return 0;  /* just succeed, the real work is done elsewhere. */
icculus@9554
   163
}
icculus@9554
   164
gabomdq@8062
   165
void Wayland_ShowWindow(_THIS, SDL_Window *window)
gabomdq@8062
   166
{
gabomdq@8062
   167
    SDL_WindowData *wind = window->driverdata;
gabomdq@8062
   168
gabomdq@8062
   169
    if (window->flags & SDL_WINDOW_FULLSCREEN)
gabomdq@8062
   170
        wl_shell_surface_set_fullscreen(wind->shell_surface,
gabomdq@8062
   171
                                        WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
linkmauve@9468
   172
                                        0, (struct wl_output *)window->fullscreen_mode.driverdata);
gabomdq@8062
   173
    else
gabomdq@8062
   174
        wl_shell_surface_set_toplevel(wind->shell_surface);
gabomdq@8062
   175
gabomdq@8104
   176
    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
gabomdq@8062
   177
}
gabomdq@8062
   178
m@10614
   179
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
m@10614
   180
static void QtExtendedSurface_OnHintChanged(void *userdata, const char *name,
m@10614
   181
        const char *oldValue, const char *newValue)
m@10614
   182
{
m@10614
   183
    struct qt_extended_surface *qt_extended_surface = userdata;
m@10614
   184
m@10614
   185
    if (name == NULL) {
m@10614
   186
        return;
m@10614
   187
    }
m@10614
   188
m@10614
   189
    if (strcmp(name, SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION) == 0) {
m@10614
   190
        int32_t orientation = QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION;
m@10614
   191
m@10614
   192
        if (newValue != NULL) {
m@10614
   193
            if (strcmp(newValue, "portrait") == 0) {
m@10614
   194
                orientation = QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION;
m@10614
   195
            } else if (strcmp(newValue, "landscape") == 0) {
m@10614
   196
                orientation = QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION;
m@10614
   197
            } else if (strcmp(newValue, "inverted-portrait") == 0) {
m@10614
   198
                orientation = QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION;
m@10614
   199
            } else if (strcmp(newValue, "inverted-landscape") == 0) {
m@10614
   200
                orientation = QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION;
m@10614
   201
            }
m@10614
   202
        }
m@10614
   203
m@10614
   204
        qt_extended_surface_set_content_orientation(qt_extended_surface, orientation);
m@10614
   205
    } else if (strcmp(name, SDL_HINT_QTWAYLAND_WINDOW_FLAGS) == 0) {
m@10614
   206
        uint32_t flags = 0;
m@10614
   207
m@10614
   208
        if (newValue != NULL) {
m@10614
   209
            char *tmp = strdup(newValue);
m@10614
   210
            char *saveptr = NULL;
m@10614
   211
m@10614
   212
            char *flag = strtok_r(tmp, " ", &saveptr);
m@10614
   213
            while (flag) {
m@10614
   214
                if (strcmp(flag, "OverridesSystemGestures") == 0) {
m@10614
   215
                    flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES;
m@10614
   216
                } else if (strcmp(flag, "StaysOnTop") == 0) {
m@10614
   217
                    flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP;
m@10614
   218
                } else if (strcmp(flag, "BypassWindowManager") == 0) {
m@10614
   219
                    // See https://github.com/qtproject/qtwayland/commit/fb4267103d
m@10614
   220
                    flags |= 4 /* QT_EXTENDED_SURFACE_WINDOWFLAG_BYPASSWINDOWMANAGER */;
m@10614
   221
                }
m@10614
   222
m@10614
   223
                flag = strtok_r(NULL, " ", &saveptr);
m@10614
   224
            }
m@10614
   225
m@10614
   226
            free(tmp);
m@10614
   227
        }
m@10614
   228
m@10614
   229
        qt_extended_surface_set_window_flags(qt_extended_surface, flags);
m@10614
   230
    }
m@10614
   231
}
m@10614
   232
m@10614
   233
static void QtExtendedSurface_Subscribe(struct qt_extended_surface *surface, const char *name)
m@10614
   234
{
m@10614
   235
    SDL_AddHintCallback(name, QtExtendedSurface_OnHintChanged, surface);
m@10614
   236
}
m@10614
   237
m@10614
   238
static void QtExtendedSurface_Unsubscribe(struct qt_extended_surface *surface, const char *name)
m@10614
   239
{
m@10614
   240
    SDL_DelHintCallback(name, QtExtendedSurface_OnHintChanged, surface);
m@10614
   241
}
m@10614
   242
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
m@10614
   243
gabomdq@8062
   244
void
gabomdq@8062
   245
Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
gabomdq@8062
   246
                            SDL_VideoDisplay * _display, SDL_bool fullscreen)
gabomdq@8062
   247
{
gabomdq@8062
   248
    SDL_WindowData *wind = window->driverdata;
gabomdq@8062
   249
gabomdq@8062
   250
    if (fullscreen)
gabomdq@8062
   251
        wl_shell_surface_set_fullscreen(wind->shell_surface,
gabomdq@8062
   252
                                        WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
linkmauve@9468
   253
                                        0, (struct wl_output *)_display->driverdata);
gabomdq@8062
   254
    else
gabomdq@8062
   255
        wl_shell_surface_set_toplevel(wind->shell_surface);
gabomdq@8062
   256
gabomdq@8104
   257
    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
gabomdq@8062
   258
}
gabomdq@8062
   259
slouken@10492
   260
void
slouken@10492
   261
Wayland_RestoreWindow(_THIS, SDL_Window * window)
slouken@10492
   262
{
slouken@10492
   263
    SDL_WindowData *wind = window->driverdata;
slouken@10492
   264
slouken@10492
   265
    wl_shell_surface_set_toplevel(wind->shell_surface);
slouken@10492
   266
slouken@10492
   267
    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
slouken@10492
   268
}
slouken@10492
   269
slouken@10492
   270
void
slouken@10492
   271
Wayland_MaximizeWindow(_THIS, SDL_Window * window)
slouken@10492
   272
{
slouken@10492
   273
    SDL_WindowData *wind = window->driverdata;
slouken@10492
   274
slouken@10492
   275
    wl_shell_surface_set_maximized(wind->shell_surface, NULL);
slouken@10492
   276
slouken@10492
   277
    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
slouken@10492
   278
}
slouken@10492
   279
gabomdq@8062
   280
int Wayland_CreateWindow(_THIS, SDL_Window *window)
gabomdq@8062
   281
{
gabomdq@8062
   282
    SDL_WindowData *data;
gabomdq@8062
   283
    SDL_VideoData *c;
gabomdq@8062
   284
    struct wl_region *region;
gabomdq@8062
   285
gabomdq@8062
   286
    data = calloc(1, sizeof *data);
gabomdq@8062
   287
    if (data == NULL)
philipp@9483
   288
        return SDL_OutOfMemory();
gabomdq@8062
   289
gabomdq@8062
   290
    c = _this->driverdata;
gabomdq@8062
   291
    window->driverdata = data;
gabomdq@8062
   292
gabomdq@8062
   293
    if (!(window->flags & SDL_WINDOW_OPENGL)) {
gabomdq@8062
   294
        SDL_GL_LoadLibrary(NULL);
gabomdq@8062
   295
        window->flags |= SDL_WINDOW_OPENGL;
gabomdq@8062
   296
    }
gabomdq@8062
   297
gabomdq@8062
   298
    if (window->x == SDL_WINDOWPOS_UNDEFINED) {
gabomdq@8062
   299
        window->x = 0;
gabomdq@8062
   300
    }
gabomdq@8062
   301
    if (window->y == SDL_WINDOWPOS_UNDEFINED) {
gabomdq@8062
   302
        window->y = 0;
gabomdq@8062
   303
    }
gabomdq@8062
   304
gabomdq@8062
   305
    data->waylandData = c;
gabomdq@8062
   306
    data->sdlwindow = window;
gabomdq@8062
   307
gabomdq@8062
   308
    data->surface =
gabomdq@8062
   309
        wl_compositor_create_surface(c->compositor);
gabomdq@8062
   310
    wl_surface_set_user_data(data->surface, data);
gabomdq@8062
   311
    data->shell_surface = wl_shell_get_shell_surface(c->shell,
gabomdq@8062
   312
                                                     data->surface);
hadess@10302
   313
    wl_shell_surface_set_class (data->shell_surface, c->classname);
m@10614
   314
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   315
    if (c->surface_extension) {
gabomdq@8082
   316
        data->extended_surface = qt_surface_extension_get_extended_surface(
gabomdq@8082
   317
                c->surface_extension, data->surface);
m@10614
   318
m@10614
   319
        QtExtendedSurface_Subscribe(data->extended_surface, SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION);
m@10614
   320
        QtExtendedSurface_Subscribe(data->extended_surface, SDL_HINT_QTWAYLAND_WINDOW_FLAGS);
gabomdq@8082
   321
    }
gabomdq@8082
   322
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
m@8712
   323
gabomdq@8104
   324
    data->egl_window = WAYLAND_wl_egl_window_create(data->surface,
gabomdq@8062
   325
                                            window->w, window->h);
gabomdq@8062
   326
gabomdq@8062
   327
    /* Create the GLES window surface */
gabomdq@8062
   328
    data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
gabomdq@8062
   329
    
gabomdq@8062
   330
    if (data->egl_surface == EGL_NO_SURFACE) {
philipp@9543
   331
        return SDL_SetError("failed to create a window surface");
gabomdq@8062
   332
    }
gabomdq@8062
   333
gabomdq@8062
   334
    if (data->shell_surface) {
gabomdq@8062
   335
        wl_shell_surface_set_user_data(data->shell_surface, data);
gabomdq@8062
   336
        wl_shell_surface_add_listener(data->shell_surface,
gabomdq@8062
   337
                                      &shell_surface_listener, data);
gabomdq@8062
   338
    }
gabomdq@8062
   339
gabomdq@8082
   340
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
gabomdq@8082
   341
    if (data->extended_surface) {
gabomdq@8082
   342
        qt_extended_surface_set_user_data(data->extended_surface, data);
gabomdq@8082
   343
        qt_extended_surface_add_listener(data->extended_surface,
gabomdq@8082
   344
                                         &extended_surface_listener, data);
gabomdq@8082
   345
    }
gabomdq@8082
   346
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8082
   347
gabomdq@8062
   348
    region = wl_compositor_create_region(c->compositor);
gabomdq@8062
   349
    wl_region_add(region, 0, 0, window->w, window->h);
gabomdq@8062
   350
    wl_surface_set_opaque_region(data->surface, region);
gabomdq@8062
   351
    wl_region_destroy(region);
gabomdq@8062
   352
slouken@10304
   353
    if (c->relative_mouse_mode) {
slouken@10304
   354
        Wayland_input_lock_pointer(c->input);
slouken@10304
   355
    }
slouken@10304
   356
gabomdq@8104
   357
    WAYLAND_wl_display_flush(c->display);
gabomdq@8062
   358
gabomdq@8062
   359
    return 0;
gabomdq@8062
   360
}
gabomdq@8062
   361
gabomdq@8062
   362
void Wayland_SetWindowSize(_THIS, SDL_Window * window)
gabomdq@8062
   363
{
gabomdq@8062
   364
    SDL_VideoData *data = _this->driverdata;
gabomdq@8062
   365
    SDL_WindowData *wind = window->driverdata;
gabomdq@8062
   366
    struct wl_region *region;
gabomdq@8062
   367
gabomdq@8104
   368
    WAYLAND_wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
gabomdq@8062
   369
gabomdq@8104
   370
    region =wl_compositor_create_region(data->compositor);
gabomdq@8062
   371
    wl_region_add(region, 0, 0, window->w, window->h);
gabomdq@8062
   372
    wl_surface_set_opaque_region(wind->surface, region);
gabomdq@8062
   373
    wl_region_destroy(region);
gabomdq@8062
   374
}
gabomdq@8062
   375
slouken@10492
   376
void Wayland_SetWindowTitle(_THIS, SDL_Window * window)
slouken@10492
   377
{
slouken@10492
   378
    SDL_WindowData *wind = window->driverdata;
slouken@10492
   379
    
slouken@10492
   380
    if (window->title != NULL) {
slouken@10492
   381
        wl_shell_surface_set_title(wind->shell_surface, window->title);
slouken@10492
   382
    }
slouken@10492
   383
slouken@10492
   384
    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
slouken@10492
   385
}
slouken@10492
   386
gabomdq@8062
   387
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
gabomdq@8062
   388
{
gabomdq@8062
   389
    SDL_VideoData *data = _this->driverdata;
gabomdq@8062
   390
    SDL_WindowData *wind = window->driverdata;
gabomdq@8062
   391
gabomdq@8062
   392
    if (data) {
gabomdq@8062
   393
        SDL_EGL_DestroySurface(_this, wind->egl_surface);
gabomdq@8104
   394
        WAYLAND_wl_egl_window_destroy(wind->egl_window);
gabomdq@8062
   395
gabomdq@8062
   396
        if (wind->shell_surface)
gabomdq@8062
   397
            wl_shell_surface_destroy(wind->shell_surface);
gabomdq@8062
   398
gabomdq@8082
   399
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
m@10614
   400
        if (wind->extended_surface) {
m@10614
   401
            QtExtendedSurface_Unsubscribe(wind->extended_surface, SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION);
m@10614
   402
            QtExtendedSurface_Unsubscribe(wind->extended_surface, SDL_HINT_QTWAYLAND_WINDOW_FLAGS);
gabomdq@8082
   403
            qt_extended_surface_destroy(wind->extended_surface);
m@10614
   404
        }
gabomdq@8082
   405
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
gabomdq@8062
   406
        wl_surface_destroy(wind->surface);
gabomdq@8062
   407
gabomdq@8062
   408
        SDL_free(wind);
gabomdq@8104
   409
        WAYLAND_wl_display_flush(data->display);
gabomdq@8062
   410
    }
slouken@8978
   411
    window->driverdata = NULL;
gabomdq@8062
   412
}
gabomdq@8062
   413
icculus@8116
   414
#endif /* SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL */
icculus@8116
   415
gabomdq@8062
   416
/* vi: set ts=4 sw=4 expandtab: */