src/video/wayland/SDL_waylandopengles.c
changeset 12400 28303fca62bd
parent 11811 5d94cb6b24d3
child 12503 806492103856
     1.1 --- a/src/video/wayland/SDL_waylandopengles.c	Tue Nov 06 23:45:50 2018 +0300
     1.2 +++ b/src/video/wayland/SDL_waylandopengles.c	Wed Nov 07 01:08:35 2018 +0100
     1.3 @@ -22,12 +22,17 @@
     1.4  
     1.5  #if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL
     1.6  
     1.7 +#include "../SDL_sysvideo.h"
     1.8 +#include "../../events/SDL_windowevents_c.h"
     1.9  #include "SDL_waylandvideo.h"
    1.10  #include "SDL_waylandopengles.h"
    1.11  #include "SDL_waylandwindow.h"
    1.12  #include "SDL_waylandevents_c.h"
    1.13  #include "SDL_waylanddyn.h"
    1.14  
    1.15 +#include "xdg-shell-client-protocol.h"
    1.16 +#include "xdg-shell-unstable-v6-client-protocol.h"
    1.17 +
    1.18  /* EGL implementation of SDL OpenGL ES support */
    1.19  
    1.20  int
    1.21 @@ -57,10 +62,37 @@
    1.22  int
    1.23  Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
    1.24  {
    1.25 -    if (SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface) < 0) {
    1.26 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.27 +    struct wl_region *region;
    1.28 +
    1.29 +    if (SDL_EGL_SwapBuffers(_this, data->egl_surface) < 0) {
    1.30          return -1;
    1.31      }
    1.32 -    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
    1.33 +
    1.34 +    // Wayland-EGL forbids drawing calls in-between SwapBuffers and wl_egl_window_resize
    1.35 +    if (data->resize.pending) {
    1.36 +        SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, data->resize.width, data->resize.height);
    1.37 +        window->w = data->resize.width;
    1.38 +        window->h = data->resize.height;
    1.39 +
    1.40 +        WAYLAND_wl_egl_window_resize(data->egl_window, window->w, window->h, 0, 0);
    1.41 +
    1.42 +        if (data->waylandData->shell.xdg) {
    1.43 +           xdg_surface_ack_configure(data->shell_surface.xdg.surface, data->resize.serial);
    1.44 +        } else if (data->waylandData->shell.zxdg) {
    1.45 +           zxdg_surface_v6_ack_configure(data->shell_surface.zxdg.surface, data->resize.serial);
    1.46 +        }
    1.47 +
    1.48 +        region = wl_compositor_create_region(data->waylandData->compositor);
    1.49 +        wl_region_add(region, 0, 0, window->w, window->h);
    1.50 +        wl_surface_set_opaque_region(data->surface, region);
    1.51 +        wl_region_destroy(region);
    1.52 +
    1.53 +        data->resize.pending = SDL_FALSE;
    1.54 +    }
    1.55 +
    1.56 +    WAYLAND_wl_display_flush( data->waylandData->display );
    1.57 +
    1.58      return 0;
    1.59  }
    1.60