src/video/wayland/SDL_waylandwindow.c
author Gabriel Jacobo <gabomdq@gmail.com>
Sat, 14 Dec 2013 20:18:43 -0300
changeset 8062 4fc5f66d63cc
child 8082 5b83ad3f01ac
permissions -rw-r--r--
Wayland support Based on the original port to Wayland by: Joel Teichroeb, Benjamin Franzke, Scott Moreau, et al. Additional changes in this commit, done by me: * Wayland uses the common EGL framework * EGL can now create a desktop OpenGL context * testgl2 loads GL functions dynamically, no need to link to libGL anymore * Assorted fixes to the Wayland backend Tested on the Weston Compositor (v1.0.5) that ships with Ubuntu 13.10, running Weston under X. Tests ran: testrendercopyex (all backends), testgl2, testgles2,testintersections
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     1
/*
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     2
  Simple DirectMedia Layer
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     4
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     7
  arising from the use of this software.
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     8
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    12
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    16
     appreciated but is not required.
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    18
     misrepresented as being the original software.
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    20
*/
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    21
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    22
#include "SDL_config.h"
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    23
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    24
#include "../SDL_sysvideo.h"
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    25
#include "../../events/SDL_windowevents_c.h"
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    26
#include "../SDL_egl_c.h"
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    27
#include "SDL_waylandwindow.h"
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    28
#include "SDL_waylandvideo.h"
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    29
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    30
static void
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    31
handle_ping(void *data, struct wl_shell_surface *shell_surface,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    32
            uint32_t serial)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    33
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    34
    wl_shell_surface_pong(shell_surface, serial);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    35
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    36
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    37
static void
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    38
handle_configure(void *data, struct wl_shell_surface *shell_surface,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    39
                 uint32_t edges, int32_t width, int32_t height)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    40
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    41
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    42
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    43
static void
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    44
handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    45
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    46
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    47
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    48
static const struct wl_shell_surface_listener shell_surface_listener = {
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    49
    handle_ping,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    50
    handle_configure,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    51
    handle_popup_done
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    52
};
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    53
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    54
SDL_bool
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    55
Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    56
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    57
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    58
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    59
    info->info.wl.display = data->waylandData->display;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    60
    info->info.wl.surface = data->surface;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    61
    info->info.wl.shell_surface = data->shell_surface;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    62
    info->subsystem = SDL_SYSWM_WAYLAND;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    63
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    64
    return SDL_TRUE;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    65
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    67
void Wayland_ShowWindow(_THIS, SDL_Window *window)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    68
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    69
    SDL_WindowData *wind = window->driverdata;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    70
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    71
    if (window->flags & SDL_WINDOW_FULLSCREEN)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    72
        wl_shell_surface_set_fullscreen(wind->shell_surface,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    73
                                        WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    74
                                        0, NULL);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    75
    else
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    76
        wl_shell_surface_set_toplevel(wind->shell_surface);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    77
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    78
    wayland_schedule_write(_this->driverdata);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    79
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    80
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    81
void
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    82
Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    83
                            SDL_VideoDisplay * _display, SDL_bool fullscreen)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    84
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    85
    SDL_WindowData *wind = window->driverdata;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    86
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    87
    if (fullscreen)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
        wl_shell_surface_set_fullscreen(wind->shell_surface,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    89
                                        WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    90
                                        0, NULL);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    91
    else
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    92
        wl_shell_surface_set_toplevel(wind->shell_surface);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    93
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
    wayland_schedule_write(_this->driverdata);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    95
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    97
int Wayland_CreateWindow(_THIS, SDL_Window *window)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    98
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    99
    SDL_WindowData *data;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   100
    SDL_VideoData *c;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   101
    struct wl_region *region;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   102
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   103
    data = calloc(1, sizeof *data);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   104
    if (data == NULL)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   105
        return 0;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   106
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   107
    c = _this->driverdata;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   108
    window->driverdata = data;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   109
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   110
    if (!(window->flags & SDL_WINDOW_OPENGL)) {
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   111
        SDL_GL_LoadLibrary(NULL);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   112
        window->flags |= SDL_WINDOW_OPENGL;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   113
    }
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   114
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   115
    if (window->x == SDL_WINDOWPOS_UNDEFINED) {
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   116
        window->x = 0;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   117
    }
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   118
    if (window->y == SDL_WINDOWPOS_UNDEFINED) {
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   119
        window->y = 0;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   120
    }
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   121
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   122
    data->waylandData = c;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   123
    data->sdlwindow = window;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   124
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   125
    data->surface =
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   126
        wl_compositor_create_surface(c->compositor);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   127
    wl_surface_set_user_data(data->surface, data);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   128
    data->shell_surface = wl_shell_get_shell_surface(c->shell,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   129
                                                     data->surface);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   130
    data->egl_window = wl_egl_window_create(data->surface,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   131
                                            window->w, window->h);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   132
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   133
    /* Create the GLES window surface */
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   134
    data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   135
    
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   136
    if (data->egl_surface == EGL_NO_SURFACE) {
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   137
        SDL_SetError("failed to create a window surface");
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   138
        return -1;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   139
    }
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   140
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   141
    if (data->shell_surface) {
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   142
        wl_shell_surface_set_user_data(data->shell_surface, data);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   143
        wl_shell_surface_add_listener(data->shell_surface,
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   144
                                      &shell_surface_listener, data);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   145
    }
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   146
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   147
    region = wl_compositor_create_region(c->compositor);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   148
    wl_region_add(region, 0, 0, window->w, window->h);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   149
    wl_surface_set_opaque_region(data->surface, region);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   150
    wl_region_destroy(region);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   152
    wayland_schedule_write(c);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   153
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   154
    return 0;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   155
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   156
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   157
void Wayland_SetWindowSize(_THIS, SDL_Window * window)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   158
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   159
    SDL_VideoData *data = _this->driverdata;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   160
    SDL_WindowData *wind = window->driverdata;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   161
    struct wl_region *region;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   162
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   163
    wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   164
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   165
    region = wl_compositor_create_region(data->compositor);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   166
    wl_region_add(region, 0, 0, window->w, window->h);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   167
    wl_surface_set_opaque_region(wind->surface, region);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   168
    wl_region_destroy(region);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   169
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   170
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   171
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   172
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   173
    SDL_VideoData *data = _this->driverdata;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   174
    SDL_WindowData *wind = window->driverdata;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   175
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   176
    window->driverdata = NULL;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   177
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   178
    if (data) {
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   179
        SDL_EGL_DestroySurface(_this, wind->egl_surface);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   180
        wl_egl_window_destroy(wind->egl_window);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   181
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   182
        if (wind->shell_surface)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   183
            wl_shell_surface_destroy(wind->shell_surface);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   184
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   185
        wl_surface_destroy(wind->surface);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   186
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   187
        SDL_free(wind);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   188
        wayland_schedule_write(data);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   189
    }
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   190
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   191
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   192
/* vi: set ts=4 sw=4 expandtab: */