From dec7875a6e23212021e4d9080330a42832dfe02a Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 15 Jun 2021 01:40:19 +0000
Subject: [PATCH] update SDL soruce to 2.0.14

---
 source/src/video/wayland/SDL_waylandvideo.c |   75 ++++++++++++++++++-------------------
 1 files changed, 36 insertions(+), 39 deletions(-)

diff --git a/source/src/video/wayland/SDL_waylandvideo.c b/source/src/video/wayland/SDL_waylandvideo.c
index 5c331f3..469bb73 100644
--- a/source/src/video/wayland/SDL_waylandvideo.c
+++ b/source/src/video/wayland/SDL_waylandvideo.c
@@ -120,25 +120,15 @@
     return SDL_strdup("SDL_App");
 }
 
-/* Wayland driver bootstrap functions */
-static int
-Wayland_Available(void)
-{
-    struct wl_display *display = NULL;
-    if (SDL_WAYLAND_LoadSymbols()) {
-        display = WAYLAND_wl_display_connect(NULL);
-        if (display != NULL) {
-            WAYLAND_wl_display_disconnect(display);
-        }
-        SDL_WAYLAND_UnloadSymbols();
-    }
-
-    return (display != NULL);
-}
-
 static void
 Wayland_DeleteDevice(SDL_VideoDevice *device)
 {
+    SDL_VideoData *data = (SDL_VideoData *)device->driverdata;
+    if (data->display) {
+        WAYLAND_wl_display_flush(data->display);
+        WAYLAND_wl_display_disconnect(data->display);
+    }
+    SDL_free(data);
     SDL_free(device);
     SDL_WAYLAND_UnloadSymbols();
 }
@@ -147,18 +137,40 @@
 Wayland_CreateDevice(int devindex)
 {
     SDL_VideoDevice *device;
+    SDL_VideoData *data;
+    struct wl_display *display;
 
     if (!SDL_WAYLAND_LoadSymbols()) {
         return NULL;
     }
 
-    /* Initialize all variables that we clean on shutdown */
-    device = SDL_calloc(1, sizeof(SDL_VideoDevice));
-    if (!device) {
+    display = WAYLAND_wl_display_connect(NULL);
+    if (display == NULL) {
+        SDL_WAYLAND_UnloadSymbols();
+        return NULL;
+    }
+
+    data = SDL_calloc(1, sizeof(*data));
+    if (data == NULL) {
+        WAYLAND_wl_display_disconnect(display);
         SDL_WAYLAND_UnloadSymbols();
         SDL_OutOfMemory();
         return NULL;
     }
+
+    data->display = display;
+
+    /* Initialize all variables that we clean on shutdown */
+    device = SDL_calloc(1, sizeof(SDL_VideoDevice));
+    if (!device) {
+        SDL_free(data);
+        WAYLAND_wl_display_disconnect(display);
+        SDL_WAYLAND_UnloadSymbols();
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    device->driverdata = data;
 
     /* Set the function pointers */
     device->VideoInit = Wayland_VideoInit;
@@ -184,6 +196,7 @@
     device->ShowWindow = Wayland_ShowWindow;
     device->SetWindowFullscreen = Wayland_SetWindowFullscreen;
     device->MaximizeWindow = Wayland_MaximizeWindow;
+    device->SetWindowGrab = Wayland_SetWindowGrab;
     device->RestoreWindow = Wayland_RestoreWindow;
     device->SetWindowBordered = Wayland_SetWindowBordered;
     device->SetWindowSize = Wayland_SetWindowSize;
@@ -210,7 +223,7 @@
 
 VideoBootStrap Wayland_bootstrap = {
     WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver",
-    Wayland_Available, Wayland_CreateDevice
+    Wayland_CreateDevice
 };
 
 static void
@@ -261,7 +274,7 @@
 {
     /* !!! FIXME: this will fail on any further property changes! */
     SDL_VideoDisplay *display = data;
-    SDL_AddVideoDisplay(display);
+    SDL_AddVideoDisplay(display, SDL_FALSE);
     wl_output_set_user_data(output, display->driverdata);
     SDL_free(display->name);
     SDL_free(display);
@@ -364,7 +377,7 @@
     } else if (strcmp(interface, "wl_output") == 0) {
         Wayland_add_display(d, id);
     } else if (strcmp(interface, "wl_seat") == 0) {
-        Wayland_display_add_input(d, id);
+        Wayland_display_add_input(d, id, version);
     } else if (strcmp(interface, "xdg_wm_base") == 0) {
         d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, 1);
         xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL);
@@ -412,20 +425,11 @@
 int
 Wayland_VideoInit(_THIS)
 {
-    SDL_VideoData *data = SDL_calloc(1, sizeof(*data));
-    if (data == NULL)
-        return SDL_OutOfMemory();
-
-    _this->driverdata = data;
+    SDL_VideoData *data = (SDL_VideoData*)_this->driverdata;
 
     data->xkb_context = WAYLAND_xkb_context_new(0);
     if (!data->xkb_context) {
         return SDL_SetError("Failed to create XKB context");
-    }
-
-    data->display = WAYLAND_wl_display_connect(NULL);
-    if (data->display == NULL) {
-        return SDL_SetError("Failed to connect to a Wayland display");
     }
 
     data->registry = wl_display_get_registry(data->display);
@@ -524,14 +528,7 @@
     if (data->registry)
         wl_registry_destroy(data->registry);
 
-    if (data->display) {
-        WAYLAND_wl_display_flush(data->display);
-        WAYLAND_wl_display_disconnect(data->display);
-    }
-
     SDL_free(data->classname);
-    SDL_free(data);
-    _this->driverdata = NULL;
 }
 
 #endif /* SDL_VIDEO_DRIVER_WAYLAND */

--
Gitblit v1.9.3