From 84d047cc11ad09b5554d0191bbd9c4629a2f5f3b Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Fri, 7 Mar 2025 12:51:28 -0500 Subject: [PATCH] wayland: Rollback the round trip when reading data offers The bug this appeared to fix turned out to be randomly occurring and has other causes, and the read pipe is already polled for readiness, so this extra overhead isn't necessary. --- src/video/wayland/SDL_waylanddatamanager.c | 14 ++------------ src/video/wayland/SDL_waylandsym.h | 1 - 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index b8f4078752..fec2c3eb1d 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -370,15 +370,10 @@ void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); } else { - struct wl_event_queue *queue = WAYLAND_wl_display_create_queue(data_device->video_data->display); - WAYLAND_wl_proxy_set_queue((struct wl_proxy *)offer->offer, queue); - wl_data_offer_receive(offer->offer, mime_type, pipefd[1]); close(pipefd[1]); - WAYLAND_wl_display_roundtrip_queue(data_device->video_data->display, queue); - WAYLAND_wl_proxy_set_queue((struct wl_proxy *)offer->offer, NULL); - WAYLAND_wl_event_queue_destroy(queue); + WAYLAND_wl_display_flush(data_device->video_data->display); while (read_pipe(pipefd[0], &buffer, length) > 0) { } @@ -409,15 +404,10 @@ void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer * } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); } else { - struct wl_event_queue *queue = WAYLAND_wl_display_create_queue(primary_selection_device->video_data->display); - WAYLAND_wl_proxy_set_queue((struct wl_proxy *)offer->offer, queue); - zwp_primary_selection_offer_v1_receive(offer->offer, mime_type, pipefd[1]); close(pipefd[1]); - WAYLAND_wl_display_roundtrip_queue(primary_selection_device->video_data->display, queue); - WAYLAND_wl_proxy_set_queue((struct wl_proxy *)offer->offer, NULL); - WAYLAND_wl_event_queue_destroy(queue); + WAYLAND_wl_display_flush(primary_selection_device->video_data->display); while (read_pipe(pipefd[0], &buffer, length) > 0) { } diff --git a/src/video/wayland/SDL_waylandsym.h b/src/video/wayland/SDL_waylandsym.h index a21659539c..846c876a87 100644 --- a/src/video/wayland/SDL_waylandsym.h +++ b/src/video/wayland/SDL_waylandsym.h @@ -65,7 +65,6 @@ SDL_WAYLAND_SYM(void, wl_display_cancel_read, (struct wl_display *)) SDL_WAYLAND_SYM(int, wl_display_get_error, (struct wl_display *)) SDL_WAYLAND_SYM(int, wl_display_flush, (struct wl_display *)) SDL_WAYLAND_SYM(int, wl_display_roundtrip, (struct wl_display *)) -SDL_WAYLAND_SYM(int, wl_display_roundtrip_queue, (struct wl_display *, struct wl_event_queue *)) SDL_WAYLAND_SYM(struct wl_event_queue *, wl_display_create_queue, (struct wl_display *)) SDL_WAYLAND_SYM(void, wl_event_queue_destroy, (struct wl_event_queue *)) SDL_WAYLAND_SYM(void, wl_log_set_handler_client, (wl_log_func_t))