SDL: wayland: Don't retrieve the drag offer strings with every pointer motion event

From 9964e5c5b0e52162308fad2d5936df34ae9384c7 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Thu, 21 Sep 2023 14:05:16 -0400
Subject: [PATCH] wayland: Don't retrieve the drag offer strings with every
 pointer motion event

Querying the drag offer with every pointer movement would require refactoring to work with the portal implementation, however, there is little point, as the event layer just discards the file name. Remove the existing code and note that a new implementation is needed if the name ever starts to be passed though.

In the event that this is reimplemented, it should cache the filenames, as otherwise, this could potentially hammer the DBus interface hundreds or even thousands of times per second.
---
 src/video/wayland/SDL_waylandevents.c | 28 ++++++++-------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index ea2c8a2296d4..498f69c5c3ca 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -1902,26 +1902,14 @@ static void data_device_handle_motion(void *data, struct wl_data_device *wl_data
     SDL_WaylandDataDevice *data_device = data;
 
     if (data_device->drag_offer != NULL && data_device->dnd_window) {
-        /* TODO: SDL Support more mime types */
-        size_t length;
-        void *buffer = Wayland_data_offer_receive(data_device->drag_offer,
-                                                  FILE_MIME, &length);
-        if (buffer) {
-            char *saveptr = NULL;
-            char *token = SDL_strtok_r((char *)buffer, "\r\n", &saveptr);
-            while (token != NULL) {
-                char *fn = Wayland_URIToLocal(token);
-                if (fn) {
-                    double dx;
-                    double dy;
-                    dx = wl_fixed_to_double(x);
-                    dy = wl_fixed_to_double(y);
-                    SDL_SendDropPosition(data_device->dnd_window, fn, (float)dx, (float)dy);
-                }
-                token = SDL_strtok_r(NULL, "\r\n", &saveptr);
-            }
-            SDL_free(buffer);
-        }
+        const float dx = (float)wl_fixed_to_double(x);
+        const float dy = (float)wl_fixed_to_double(y);
+
+        /* XXX: Send the filename here if the event system ever starts passing it though.
+         *      Any future implementation should cache the filenames, as otherwise this could
+         *      hammer the DBus interface hundreds or even thousands of times per second.
+         */
+        SDL_SendDropPosition(data_device->dnd_window, NULL, dx, dy);
     }
 }