forked from mpv-player/mpv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclipboard-mac.m
59 lines (52 loc) · 1.87 KB
/
clipboard-mac.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clipboard.h"
#include "osdep/mac/swift.h"
struct clipboard_mac_priv {
Clipboard *clipboard;
};
static int init(struct clipboard_ctx *cl, struct clipboard_init_params *params)
{
struct clipboard_mac_priv *p = cl->priv = talloc_zero(cl, struct clipboard_mac_priv);
p->clipboard = [[Clipboard alloc] init];
return CLIPBOARD_SUCCESS;
}
static bool data_changed(struct clipboard_ctx *cl)
{
struct clipboard_mac_priv *p = cl->priv;
return [p->clipboard changed];
}
static int get_data(struct clipboard_ctx *cl, struct clipboard_access_params *params,
struct clipboard_data *out, void *talloc_ctx)
{
struct clipboard_mac_priv *p = cl->priv;
return [p->clipboard getWithParams:params out:out tallocCtx:talloc_ctx];
}
static int set_data(struct clipboard_ctx *cl, struct clipboard_access_params *params,
struct clipboard_data *data)
{
struct clipboard_mac_priv *p = cl->priv;
return [p->clipboard setWithParams:params data:data];
}
const struct clipboard_backend clipboard_backend_mac = {
.name = "mac",
.desc = "macOS clipboard",
.init = init,
.data_changed = data_changed,
.get_data = get_data,
.set_data = set_data,
};