1 #include "qemu/osdep.h"
2 #include "ui/clipboard.h"
4 static NotifierList clipboard_notifiers
=
5 NOTIFIER_LIST_INITIALIZER(clipboard_notifiers
);
7 void qemu_clipboard_peer_register(QemuClipboardPeer
*peer
)
9 notifier_list_add(&clipboard_notifiers
, &peer
->update
);
12 void qemu_clipboard_peer_unregister(QemuClipboardPeer
*peer
)
14 notifier_remove(&peer
->update
);
17 void qemu_clipboard_update(QemuClipboardInfo
*info
)
19 notifier_list_notify(&clipboard_notifiers
, info
);
22 QemuClipboardInfo
*qemu_clipboard_info_new(QemuClipboardPeer
*owner
,
23 QemuClipboardSelection selection
)
25 QemuClipboardInfo
*info
= g_new0(QemuClipboardInfo
, 1);
28 info
->selection
= selection
;
34 QemuClipboardInfo
*qemu_clipboard_info_ref(QemuClipboardInfo
*info
)
40 void qemu_clipboard_info_unref(QemuClipboardInfo
*info
)
49 if (info
->refcount
> 0) {
53 for (type
= 0; type
< QEMU_CLIPBOARD_TYPE__COUNT
; type
++) {
54 g_free(info
->types
[type
].data
);
59 void qemu_clipboard_request(QemuClipboardInfo
*info
,
60 QemuClipboardType type
)
62 if (info
->types
[type
].data
||
63 info
->types
[type
].requested
||
64 !info
->types
[type
].available
||
68 info
->types
[type
].requested
= true;
69 info
->owner
->request(info
, type
);
72 void qemu_clipboard_set_data(QemuClipboardPeer
*peer
,
73 QemuClipboardInfo
*info
,
74 QemuClipboardType type
,
80 info
->owner
!= peer
) {
84 g_free(info
->types
[type
].data
);
85 info
->types
[type
].data
= g_memdup(data
, size
);
86 info
->types
[type
].size
= size
;
87 info
->types
[type
].available
= true;
90 qemu_clipboard_update(info
);