ecore-wl2: add functions for proxying a selection receive externally

in some cases (e.g,, x11 bridged selections) it is necessary to use
alternate means when transferring a selection, and so performing the
entire piped receive is not necessary. instead, extend the lifetime
of the data offer until the proxied receive has completed

@feature
This commit is contained in:
Mike Blumenkrantz 2017-05-12 12:08:32 -04:00
parent 8afdbaba48
commit 68a3f43d1e
2 changed files with 43 additions and 0 deletions

View File

@ -1411,6 +1411,28 @@ EAPI void ecore_wl2_offer_accept(Ecore_Wl2_Offer *offer, const char *mime_type);
*/
EAPI void ecore_wl2_offer_receive(Ecore_Wl2_Offer *offer, char *mime);
/**
* Request the data from this offer on an externally managed fd.
* The event ECORE_WL2_EVENT_OFFER_DATA_READY is called when the data is available.
* There offer will be not destroyed as long as requested data is not emitted by the event.
*
* @param offer the offer to use
* @param mime the mimetype to receive
* @param fd the fd to pass for receiving
*
* @since 1.20
*/
EAPI void ecore_wl2_offer_proxy_receive(Ecore_Wl2_Offer *offer, const char *mime, int fd);
/**
* End the use of a proxy received offer. This may invalidate the offer object
*
* @param offer the offer
*
* @since 1.20
*/
EAPI void ecore_wl2_offer_proxy_receive_end(Ecore_Wl2_Offer *offer);
/**
* Check if the given offer supports the given mimetype
*

View File

@ -54,6 +54,7 @@ struct _Ecore_Wl2_Offer
Eina_List *reads;
int ref;
unsigned int window_id;
Eina_Bool proxied : 1;
};
static int
@ -861,6 +862,26 @@ ecore_wl2_offer_receive(Ecore_Wl2_Offer *offer, char *mime)
return;
}
EAPI void
ecore_wl2_offer_proxy_receive(Ecore_Wl2_Offer *offer, const char *mime, int fd)
{
EINA_SAFETY_ON_NULL_RETURN(offer);
if (!offer->proxied) offer->ref++;
offer->proxied = 1;
wl_data_offer_receive(offer->offer, mime, fd);
}
EAPI void
ecore_wl2_offer_proxy_receive_end(Ecore_Wl2_Offer *offer)
{
EINA_SAFETY_ON_NULL_RETURN(offer);
if (!offer->proxied) return;
offer->proxied = 0;
_ecore_wl2_offer_unref(offer);
}
EAPI void
ecore_wl2_offer_finish(Ecore_Wl2_Offer *offer)
{