ui/vdagent: use qemu_clipboard_info helper
The clipboard unit now tracks the current clipboard grab, no need to duplicate this work. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20210805135715.857938-14-marcandre.lureau@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
c98c50de7c
commit
d2ed2c01c2
23
ui/vdagent.c
23
ui/vdagent.c
|
@ -47,7 +47,6 @@ struct VDAgentChardev {
|
||||||
|
|
||||||
/* clipboard */
|
/* clipboard */
|
||||||
QemuClipboardPeer cbpeer;
|
QemuClipboardPeer cbpeer;
|
||||||
QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT];
|
|
||||||
uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT];
|
uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT];
|
||||||
};
|
};
|
||||||
typedef struct VDAgentChardev VDAgentChardev;
|
typedef struct VDAgentChardev VDAgentChardev;
|
||||||
|
@ -384,9 +383,7 @@ static void vdagent_clipboard_notify(Notifier *notifier, void *data)
|
||||||
QemuClipboardType type;
|
QemuClipboardType type;
|
||||||
bool self_update = info->owner == &vd->cbpeer;
|
bool self_update = info->owner == &vd->cbpeer;
|
||||||
|
|
||||||
if (info != vd->cbinfo[s]) {
|
if (info != qemu_clipboard_info(s)) {
|
||||||
qemu_clipboard_info_unref(vd->cbinfo[s]);
|
|
||||||
vd->cbinfo[s] = qemu_clipboard_info_ref(info);
|
|
||||||
vd->cbpending[s] = 0;
|
vd->cbpending[s] = 0;
|
||||||
if (!self_update) {
|
if (!self_update) {
|
||||||
vdagent_send_clipboard_grab(vd, info);
|
vdagent_send_clipboard_grab(vd, info);
|
||||||
|
@ -464,6 +461,7 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev *vd, uint8_t s, uint32_t
|
||||||
static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32_t size, void *data)
|
static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32_t size, void *data)
|
||||||
{
|
{
|
||||||
QemuClipboardType type;
|
QemuClipboardType type;
|
||||||
|
QemuClipboardInfo *info;
|
||||||
|
|
||||||
if (size < sizeof(uint32_t)) {
|
if (size < sizeof(uint32_t)) {
|
||||||
return;
|
return;
|
||||||
|
@ -475,13 +473,14 @@ static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (vd->cbinfo[s] && vd->cbinfo[s]->types[type].available &&
|
|
||||||
vd->cbinfo[s]->owner != &vd->cbpeer) {
|
info = qemu_clipboard_info(s);
|
||||||
if (vd->cbinfo[s]->types[type].data) {
|
if (info && info->types[type].available && info->owner != &vd->cbpeer) {
|
||||||
vdagent_send_clipboard_data(vd, vd->cbinfo[s], type);
|
if (info->types[type].data) {
|
||||||
|
vdagent_send_clipboard_data(vd, info, type);
|
||||||
} else {
|
} else {
|
||||||
vd->cbpending[s] |= (1 << type);
|
vd->cbpending[s] |= (1 << type);
|
||||||
qemu_clipboard_request(vd->cbinfo[s], type);
|
qemu_clipboard_request(info, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -502,7 +501,11 @@ static void vdagent_clipboard_recv_data(VDAgentChardev *vd, uint8_t s, uint32_t
|
||||||
}
|
}
|
||||||
data += 4;
|
data += 4;
|
||||||
size -= 4;
|
size -= 4;
|
||||||
qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, size, data, true);
|
|
||||||
|
if (qemu_clipboard_peer_owns(&vd->cbpeer, s)) {
|
||||||
|
qemu_clipboard_set_data(&vd->cbpeer, qemu_clipboard_info(s),
|
||||||
|
type, size, data, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vdagent_clipboard_recv_release(VDAgentChardev *vd, uint8_t s)
|
static void vdagent_clipboard_recv_release(VDAgentChardev *vd, uint8_t s)
|
||||||
|
|
Loading…
Reference in New Issue