Skip to content

Commit

Permalink
command: signal unavailable error when clipboard is unavailable
Browse files Browse the repository at this point in the history
This allows clients to detect if the clipboard is unavailable,
or an error happened.
  • Loading branch information
na-na-hi authored and kasper93 committed Dec 10, 2024
1 parent e121c09 commit 6532856
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -4091,9 +4091,10 @@ static int get_clipboard(struct MPContext *mpctx, void *arg,
struct clipboard_data data;
void *tmp = talloc_new(NULL);

if (mp_clipboard_get_data(mpctx->clipboard, params, &data, tmp) != CLIPBOARD_SUCCESS) {
int ret = mp_clipboard_get_data(mpctx->clipboard, params, &data, tmp);
if (ret != CLIPBOARD_SUCCESS) {
talloc_free(tmp);
return M_PROPERTY_ERROR;
return ret == CLIPBOARD_UNAVAILABLE ? M_PROPERTY_UNAVAILABLE : M_PROPERTY_ERROR;
}

switch (data.type) {
Expand Down Expand Up @@ -4121,9 +4122,10 @@ static int set_clipboard(struct MPContext *mpctx, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}

if (mp_clipboard_set_data(mpctx->clipboard, params, &data) == CLIPBOARD_SUCCESS)
int ret = mp_clipboard_set_data(mpctx->clipboard, params, &data);
if (ret == CLIPBOARD_SUCCESS)
return M_PROPERTY_OK;
return M_PROPERTY_ERROR;
return ret == CLIPBOARD_UNAVAILABLE ? M_PROPERTY_UNAVAILABLE : M_PROPERTY_ERROR;
}

static int mp_property_clipboard(void *ctx, struct m_property *prop,
Expand Down

0 comments on commit 6532856

Please sign in to comment.