diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-07-19 19:42:15 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-12-21 10:50:21 +0400 |
commit | 1b17f1e9f962f5ae9cd559d7f23718ceed71b813 (patch) | |
tree | ee3a19c25c8d55254cc6ff77c01931680f6c283c /ui/vdagent.c | |
parent | 59127452883afe3d603e90824bb33ac57b4dbee1 (diff) |
ui: generalize clipboard notifier
Use a QemuClipboardNotify union type for extendable clipboard events.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/vdagent.c')
-rw-r--r-- | ui/vdagent.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/ui/vdagent.c b/ui/vdagent.c index 64e0017001..de827aad27 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -417,10 +417,9 @@ static void vdagent_send_empty_clipboard_data(VDAgentChardev *vd, vdagent_send_clipboard_data(vd, info, type); } -static void vdagent_clipboard_notify(Notifier *notifier, void *data) +static void vdagent_clipboard_update_info(VDAgentChardev *vd, + QemuClipboardInfo *info) { - VDAgentChardev *vd = container_of(notifier, VDAgentChardev, cbpeer.update); - QemuClipboardInfo *info = data; QemuClipboardSelection s = info->selection; QemuClipboardType type; bool self_update = info->owner == &vd->cbpeer; @@ -449,6 +448,19 @@ static void vdagent_clipboard_notify(Notifier *notifier, void *data) } } +static void vdagent_clipboard_notify(Notifier *notifier, void *data) +{ + VDAgentChardev *vd = + container_of(notifier, VDAgentChardev, cbpeer.notifier); + QemuClipboardNotify *notify = data; + + switch (notify->type) { + case QEMU_CLIPBOARD_UPDATE_INFO: + vdagent_clipboard_update_info(vd, notify->info); + return; + } +} + static void vdagent_clipboard_request(QemuClipboardInfo *info, QemuClipboardType qtype) { @@ -658,9 +670,9 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg) if (have_mouse(vd) && vd->mouse_hs) { qemu_input_handler_activate(vd->mouse_hs); } - if (have_clipboard(vd) && vd->cbpeer.update.notify == NULL) { + if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) { vd->cbpeer.name = "vdagent"; - vd->cbpeer.update.notify = vdagent_clipboard_notify; + vd->cbpeer.notifier.notify = vdagent_clipboard_notify; vd->cbpeer.request = vdagent_clipboard_request; qemu_clipboard_peer_register(&vd->cbpeer); } @@ -799,7 +811,7 @@ static void vdagent_disconnect(VDAgentChardev *vd) if (vd->mouse_hs) { qemu_input_handler_deactivate(vd->mouse_hs); } - if (vd->cbpeer.update.notify) { + if (vd->cbpeer.notifier.notify) { qemu_clipboard_peer_unregister(&vd->cbpeer); memset(&vd->cbpeer, 0, sizeof(vd->cbpeer)); } @@ -807,11 +819,8 @@ static void vdagent_disconnect(VDAgentChardev *vd) static void vdagent_chr_set_fe_open(struct Chardev *chr, int fe_open) { - VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(chr); - if (!fe_open) { trace_vdagent_close(); - vdagent_disconnect(vd); return; } |