xwayland/selection: extract out property requests

Apart from reducing duplication, this has the positive side-effect of
allowing all deallocs to use
`xwm_selection_transfer_destroy_property_reply`, as opposed to the
latter and a mix of ad-hoc `free`s.
This commit is contained in:
Tudor Brindus 2021-01-26 18:41:57 -05:00 committed by Simon Ser
parent dea94f2bad
commit 23148d283f
3 changed files with 39 additions and 41 deletions

View file

@ -33,6 +33,32 @@ void xwm_selection_transfer_destroy_property_reply(
transfer->property_reply = NULL;
}
bool xwm_selection_transfer_get_selection_property(
struct wlr_xwm_selection_transfer *transfer, bool delete) {
struct wlr_xwm *xwm = transfer->selection->xwm;
xcb_get_property_cookie_t cookie = xcb_get_property(
xwm->xcb_conn,
delete,
transfer->selection->window,
xwm->atoms[WL_SELECTION],
XCB_GET_PROPERTY_TYPE_ANY,
0, // offset
0x1fffffff // length
);
transfer->property_start = 0;
transfer->property_reply =
xcb_get_property_reply(xwm->xcb_conn, cookie, NULL);
if (!transfer->property_reply) {
wlr_log(WLR_ERROR, "cannot get selection property");
return false;
}
return true;
}
xcb_atom_t xwm_mime_type_to_atom(struct wlr_xwm *xwm, char *mime_type) {
if (strcmp(mime_type, "text/plain;charset=utf-8") == 0) {
return xwm->atoms[UTF8_STRING];