diff options
author | Tudor Brindus <me@tbrindus.ca> | 2021-01-26 18:41:57 -0500 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-01-29 10:18:03 +0100 |
commit | 23148d283fb00bff0dff6f0f8126b9f940d07544 (patch) | |
tree | a6b3e13a21ba143b84627d0e9df536397be437ba /xwayland/selection/selection.c | |
parent | dea94f2bad74bf3edf8ff9c44191c076b23efa23 (diff) |
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.
Diffstat (limited to 'xwayland/selection/selection.c')
-rw-r--r-- | xwayland/selection/selection.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/xwayland/selection/selection.c b/xwayland/selection/selection.c index d27e0507..c57bf3e5 100644 --- a/xwayland/selection/selection.c +++ b/xwayland/selection/selection.c @@ -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]; |