From 03f8528315fa46c95991a34f3325d7b33ae5538c Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Sat, 02 May 2020 21:48:36 +0000
Subject: [PATCH] Update source to SDL2 2.0.12

---
 source/src/video/wayland/SDL_waylandopengles.c |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/source/src/video/wayland/SDL_waylandopengles.c b/source/src/video/wayland/SDL_waylandopengles.c
index 9c0b845..b5771e0 100644
--- a/source/src/video/wayland/SDL_waylandopengles.c
+++ b/source/src/video/wayland/SDL_waylandopengles.c
@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
+  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -22,11 +22,16 @@
 
 #if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL
 
+#include "../SDL_sysvideo.h"
+#include "../../events/SDL_windowevents_c.h"
 #include "SDL_waylandvideo.h"
 #include "SDL_waylandopengles.h"
 #include "SDL_waylandwindow.h"
 #include "SDL_waylandevents_c.h"
 #include "SDL_waylanddyn.h"
+
+#include "xdg-shell-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 
 /* EGL implementation of SDL OpenGL ES support */
 
@@ -57,10 +62,17 @@
 int
 Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
 {
-    if (SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface) < 0) {
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+
+    if (SDL_EGL_SwapBuffers(_this, data->egl_surface) < 0) {
         return -1;
     }
-    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
+
+    // Wayland-EGL forbids drawing calls in-between SwapBuffers and wl_egl_window_resize
+    Wayland_HandlePendingResize(window);
+
+    WAYLAND_wl_display_flush( data->waylandData->display );
+
     return 0;
 }
 
@@ -81,6 +93,23 @@
     return ret;
 }
 
+void
+Wayland_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
+{
+    SDL_WindowData *data;
+    if (window->driverdata) {
+        data = (SDL_WindowData *) window->driverdata;
+
+        if (w) {
+            *w = window->w * data->scale_factor;
+        }
+
+        if (h) {
+            *h = window->h * data->scale_factor;
+        }
+    }
+}
+
 void 
 Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context)
 {

--
Gitblit v1.9.3