From: Lukasz Kornicki <[email protected]> Add a new QEMU_CLIPBOARD_PEER_UPDATE notify type which carries a payload with affected peer and whether it just registered or unregistered.
All existing notifier handlers are updated to explicitly ignore the new event so that the enum switch remains exhaustive. Signed-off-by: Lukasz Kornicki <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-ID: <[email protected]> --- include/ui/clipboard.h | 19 +++++++++++++++++++ tools/qemu-vnc/clipboard.c | 3 +++ ui/clipboard.c | 18 ++++++++++++++++++ ui/cocoa.m | 3 +++ ui/dbus-clipboard.c | 3 +++ ui/gtk-clipboard.c | 3 +++ ui/trace-events | 1 + ui/vdagent.c | 3 +++ ui/vnc-clipboard.c | 3 +++ 9 files changed, 56 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index 62a96ce9ff56..6166af513906 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -25,6 +25,7 @@ typedef enum QemuClipboardNotifyType QemuClipboardNotifyType; typedef enum QemuClipboardSelection QemuClipboardSelection; typedef struct QemuClipboardPeer QemuClipboardPeer; typedef struct QemuClipboardNotify QemuClipboardNotify; +typedef struct QemuClipboardPeerUpdate QemuClipboardPeerUpdate; typedef struct QemuClipboardInfo QemuClipboardInfo; typedef struct QemuClipboardContent QemuClipboardContent; @@ -78,12 +79,27 @@ struct QemuClipboardPeer { * * @QEMU_CLIPBOARD_UPDATE_INFO: clipboard info update * @QEMU_CLIPBOARD_RESET_SERIAL: reset clipboard serial + * @QEMU_CLIPBOARD_PEER_UPDATE: peer registered/unregistered * * Clipboard notify type. */ enum QemuClipboardNotifyType { QEMU_CLIPBOARD_UPDATE_INFO, QEMU_CLIPBOARD_RESET_SERIAL, + QEMU_CLIPBOARD_PEER_UPDATE, +}; + +/** + * struct QemuClipboardPeerUpdate + * + * @peer: the peer affected by this event + * @registered: whether @peer registered or unregistered. + * + * Clipboard peer update event data. + */ +struct QemuClipboardPeerUpdate { + QemuClipboardPeer *peer; + bool registered; }; /** @@ -91,6 +107,8 @@ enum QemuClipboardNotifyType { * * @type: the type of event. * @info: a QemuClipboardInfo event. + * @peer_update: a peer register/unregister event + * (valid for QEMU_CLIPBOARD_PEER_UPDATE). * * Clipboard notify data. */ @@ -98,6 +116,7 @@ struct QemuClipboardNotify { QemuClipboardNotifyType type; union { QemuClipboardInfo *info; + QemuClipboardPeerUpdate peer_update; }; }; diff --git a/tools/qemu-vnc/clipboard.c b/tools/qemu-vnc/clipboard.c index 81a09ec5adfa..3ce994c9edbd 100644 --- a/tools/qemu-vnc/clipboard.c +++ b/tools/qemu-vnc/clipboard.c @@ -174,6 +174,9 @@ vnc_dbus_clipboard_notify(Notifier *notifier, void *data) -1, NULL, NULL, NULL); } return; + case QEMU_CLIPBOARD_PEER_UPDATE: + /* ignore */ + return; } } diff --git a/ui/clipboard.c b/ui/clipboard.c index 46e602dfef43..3d8f58a85508 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -59,6 +59,21 @@ static void qemu_clipboard_change_state(void *opaque, bool running, RunState sta } +static void qemu_clipboard_notify_peer_update(QemuClipboardPeer *peer, + bool registered) +{ + QemuClipboardNotify notify = { + .type = QEMU_CLIPBOARD_PEER_UPDATE, + .peer_update = { + .peer = peer, + .registered = registered, + }, + }; + + trace_clipboard_peer_update(peer->name, registered); + notifier_list_notify(&clipboard_notifiers, ¬ify); +} + void qemu_clipboard_peer_register(QemuClipboardPeer *peer) { if (cb_change_state_entry == NULL) { @@ -66,6 +81,7 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *peer) } notifier_list_add(&clipboard_notifiers, &peer->notifier); + qemu_clipboard_notify_peer_update(peer, true); } void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer) @@ -76,6 +92,8 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer) qemu_clipboard_peer_release(peer, i); } notifier_remove(&peer->notifier); + qemu_clipboard_notify_peer_update(peer, false); + if (QLIST_EMPTY(&clipboard_notifiers.notifiers)) { g_clear_pointer(&cb_change_state_entry, qemu_del_vm_change_state_handler); diff --git a/ui/cocoa.m b/ui/cocoa.m index 3751be379220..4587547c98ca 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1860,6 +1860,9 @@ static void cocoa_clipboard_notify(Notifier *notifier, void *data) case QEMU_CLIPBOARD_RESET_SERIAL: /* ignore */ return; + case QEMU_CLIPBOARD_PEER_UPDATE: + /* ignore */ + return; } } diff --git a/ui/dbus-clipboard.c b/ui/dbus-clipboard.c index 90318384ee48..6940f719ffb6 100644 --- a/ui/dbus-clipboard.c +++ b/ui/dbus-clipboard.c @@ -125,6 +125,9 @@ dbus_clipboard_notify(Notifier *notifier, void *data) case QEMU_CLIPBOARD_RESET_SERIAL: dbus_clipboard_reset_serial(dpy); return; + case QEMU_CLIPBOARD_PEER_UPDATE: + /* ignore */ + return; } } diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 476e6b8303c9..6bb3d7f3fcb9 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -133,6 +133,9 @@ static void gd_clipboard_notify(Notifier *notifier, void *data) case QEMU_CLIPBOARD_RESET_SERIAL: /* ignore */ return; + case QEMU_CLIPBOARD_PEER_UPDATE: + /* ignore */ + return; } } diff --git a/ui/trace-events b/ui/trace-events index 339a61f34153..917d116d90e1 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -171,6 +171,7 @@ xkeymap_keymap(const char *name) "keymap '%s'" # clipboard.c clipboard_check_serial(int cur, int recv, bool ok) "cur:%d recv:%d %d" clipboard_reset_serial(void) "" +clipboard_peer_update(const char *name, bool registered) "peer '%s' registered=%d" # vdagent.c vdagent_fe_open(bool fe_open) "fe_open=%d" diff --git a/ui/vdagent.c b/ui/vdagent.c index b9784d4d9b9e..cc32a94fb9c0 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -477,6 +477,9 @@ static void vdagent_clipboard_notify(Notifier *notifier, void *data) case QEMU_CLIPBOARD_RESET_SERIAL: vdagent_clipboard_reset_serial(vd); return; + case QEMU_CLIPBOARD_PEER_UPDATE: + /* ignore */ + return; } } diff --git a/ui/vnc-clipboard.c b/ui/vnc-clipboard.c index fa05d86f424a..dfe830f8199b 100644 --- a/ui/vnc-clipboard.c +++ b/ui/vnc-clipboard.c @@ -236,6 +236,9 @@ static void vnc_clipboard_notify(Notifier *notifier, void *data) case QEMU_CLIPBOARD_RESET_SERIAL: /* ignore */ return; + case QEMU_CLIPBOARD_PEER_UPDATE: + /* ignore */ + return; } } -- 2.56.0.116.g6de20f6092dc
