mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
clipboard: add CLIPBOARD_UNAVAILABLE error code
This makes it possible to distinguish between unavailable or unsupported, and error.
This commit is contained in:
@@ -43,7 +43,9 @@ static int get_data(struct clipboard_ctx *cl, struct clipboard_access_params *pa
|
||||
.talloc_ctx = talloc_ctx,
|
||||
};
|
||||
|
||||
if (vo && vo_control(vo, VOCTRL_GET_CLIPBOARD, &vc) == VO_TRUE) {
|
||||
if (!vo)
|
||||
return CLIPBOARD_UNAVAILABLE;
|
||||
if (vo_control(vo, VOCTRL_GET_CLIPBOARD, &vc) == VO_TRUE) {
|
||||
*out = vc.data;
|
||||
return CLIPBOARD_SUCCESS;
|
||||
} else {
|
||||
@@ -62,7 +64,9 @@ static int set_data(struct clipboard_ctx *cl, struct clipboard_access_params *pa
|
||||
.params = *params,
|
||||
};
|
||||
|
||||
if (vo && vo_control(vo, VOCTRL_SET_CLIPBOARD, &vc) == VO_TRUE) {
|
||||
if (!vo)
|
||||
return CLIPBOARD_UNAVAILABLE;
|
||||
if (vo_control(vo, VOCTRL_SET_CLIPBOARD, &vc) == VO_TRUE) {
|
||||
return CLIPBOARD_SUCCESS;
|
||||
} else {
|
||||
MP_WARN(cl, "VO is not initialized, or it does not support setting clipboard.\n");
|
||||
|
||||
@@ -96,7 +96,7 @@ int mp_clipboard_get_data(struct clipboard_ctx *cl, struct clipboard_access_para
|
||||
{
|
||||
if (cl && cl->backend->get_data)
|
||||
return cl->backend->get_data(cl, params, out, talloc_ctx);
|
||||
return CLIPBOARD_FAILED;
|
||||
return CLIPBOARD_UNAVAILABLE;
|
||||
}
|
||||
|
||||
int mp_clipboard_set_data(struct clipboard_ctx *cl, struct clipboard_access_params *params,
|
||||
@@ -104,7 +104,7 @@ int mp_clipboard_set_data(struct clipboard_ctx *cl, struct clipboard_access_para
|
||||
{
|
||||
if (cl && cl->backend->set_data)
|
||||
return cl->backend->set_data(cl, params, data);
|
||||
return CLIPBOARD_FAILED;
|
||||
return CLIPBOARD_UNAVAILABLE;
|
||||
}
|
||||
|
||||
void reinit_clipboard(struct MPContext *mpctx)
|
||||
|
||||
@@ -39,6 +39,7 @@ enum clipboard_target {
|
||||
enum clipboard_result {
|
||||
CLIPBOARD_SUCCESS = 0,
|
||||
CLIPBOARD_FAILED = -1,
|
||||
CLIPBOARD_UNAVAILABLE = -2,
|
||||
};
|
||||
|
||||
struct clipboard_data {
|
||||
|
||||
Reference in New Issue
Block a user