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.
main
Frank Praznik 2023-09-21 14:05:16 -04:00
parent bac7eeaaae
commit 9964e5c5b0
1 changed files with 8 additions and 20 deletions

View File

@ -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);
}
}