From 58bcec9d9490b1421611854aaf5ca3ece4581f27 Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Thu, 2 Jul 2020 19:25:25 -0700 Subject: xwm: end transfers when the requestor is destroyed This improves the failure cases when incremental transfers fail to complete successfully for one reason or another. --- xwayland/selection/outgoing.c | 21 +++++++++++++++++++++ xwayland/xwm.c | 1 + 2 files changed, 22 insertions(+) (limited to 'xwayland') diff --git a/xwayland/selection/outgoing.c b/xwayland/selection/outgoing.c index fd5021d5..169f516e 100644 --- a/xwayland/selection/outgoing.c +++ b/xwayland/selection/outgoing.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -417,3 +418,23 @@ void xwm_handle_selection_request(struct wlr_xwm *xwm, free(mime_type); } } + +void xwm_handle_selection_destroy_notify(struct wlr_xwm *xwm, + xcb_destroy_notify_event_t *event) { + struct wlr_xwm_selection *selections[] = { + &xwm->clipboard_selection, + &xwm->primary_selection, + &xwm->dnd_selection, + }; + + for (size_t i = 0; i < sizeof(selections)/sizeof(selections[0]); ++i) { + struct wlr_xwm_selection *selection = selections[i]; + + struct wlr_xwm_selection_transfer *outgoing, *tmp; + wl_list_for_each_safe(outgoing, tmp, &selection->outgoing, outgoing_link) { + if (event->window == outgoing->request.requestor) { + xwm_selection_transfer_destroy_outgoing(outgoing); + } + } + } +} diff --git a/xwayland/xwm.c b/xwayland/xwm.c index a0ff4d90..28e329f3 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -846,6 +846,7 @@ static void xwm_handle_destroy_notify(struct wlr_xwm *xwm, return; } xwayland_surface_destroy(xsurface); + xwm_handle_selection_destroy_notify(xwm, ev); } static void xwm_handle_configure_request(struct wlr_xwm *xwm, -- cgit v1.2.3