xwayland/selection: allow simultaneous Wayland-to-X11 transfers

There seems to be no reason why we can't service multiple Wayland-to-X11
transfers concurrently, so long as they are to different windows (or
possibly, same windows but different target properties?)

This commit removes the queuing logic, but retains the request
de-duplication from #2428.
This commit is contained in:
Tudor Brindus 2021-02-01 21:19:00 -05:00 committed by Simon Ser
parent 2fa257313a
commit 3d46d3f7a1
1 changed files with 3 additions and 30 deletions

View File

@ -55,30 +55,11 @@ static int xwm_selection_flush_source_data(
static void xwm_selection_transfer_start_outgoing(
struct wlr_xwm_selection_transfer *transfer);
static struct wlr_xwm_selection_transfer *xwm_selection_transfer_get_first(
struct wlr_xwm_selection *selection) {
struct wlr_xwm_selection_transfer *first = NULL;
if (!wl_list_empty(&selection->outgoing)) {
first = wl_container_of(selection->outgoing.prev, first, link);
}
return first;
}
void xwm_selection_transfer_destroy_outgoing(
struct wlr_xwm_selection_transfer *transfer) {
struct wlr_xwm_selection *selection = transfer->selection;
bool was_first = transfer == xwm_selection_transfer_get_first(selection);
wl_list_remove(&transfer->link);
wlr_log(WLR_DEBUG, "Destroying transfer %p", transfer);
// Start next queued transfer if we just removed the active one.
if (was_first && !wl_list_empty(&selection->outgoing)) {
wlr_log(WLR_DEBUG, "Destroyed transfer was active, starting next");
xwm_selection_transfer_start_outgoing(
xwm_selection_transfer_get_first(selection));
}
xwm_selection_transfer_remove_event_source(transfer);
xwm_selection_transfer_close_wl_client_fd(transfer);
wl_array_release(&transfer->source_data);
@ -232,7 +213,6 @@ static void xwm_selection_transfer_start_outgoing(
struct wl_event_loop *loop =
wl_display_get_event_loop(xwm->xwayland->wl_display);
wlr_log(WLR_DEBUG, "Starting transfer %p", transfer);
assert(transfer == xwm_selection_transfer_get_first(transfer->selection));
transfer->event_source = wl_event_loop_add_fd(loop, transfer->wl_client_fd,
WL_EVENT_READABLE, xwm_data_source_read, transfer);
}
@ -328,21 +308,14 @@ static bool xwm_selection_send_data(struct wlr_xwm_selection *selection,
wlr_log(WLR_DEBUG, "Destroying stale transfer %p", outgoing);
xwm_selection_send_notify(selection->xwm, &outgoing->request, false);
xwm_selection_transfer_destroy_outgoing(outgoing);
} else {
wlr_log(WLR_DEBUG, "Transfer %p still running", outgoing);
}
}
wl_list_insert(&selection->outgoing, &transfer->link);
// We can only handle one transfer at a time
if (wl_list_length(&selection->outgoing) == 1) {
wlr_log(WLR_DEBUG, "No transfer active, starting %p now", transfer);
xwm_selection_transfer_start_outgoing(transfer);
} else {
struct wlr_xwm_selection_transfer *outgoing;
wl_list_for_each(outgoing, &selection->outgoing, link) {
wlr_log(WLR_DEBUG, "Transfer %p still queued", outgoing);
}
}
xwm_selection_transfer_start_outgoing(transfer);
return true;
}