From 1b17f1e9f962f5ae9cd559d7f23718ceed71b813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 19 Jul 2021 19:42:15 +0400 Subject: ui: generalize clipboard notifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a QemuClipboardNotify union type for extendable clipboard events. Signed-off-by: Marc-André Lureau Acked-by: Gerd Hoffmann --- ui/gtk-clipboard.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'ui/gtk-clipboard.c') diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 35b7a2c228..44ff810234 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -74,10 +74,9 @@ static void gd_clipboard_clear(GtkClipboard *clipboard, gd->cbowner[s] = false; } -static void gd_clipboard_notify(Notifier *notifier, void *data) +static void gd_clipboard_update_info(GtkDisplayState *gd, + QemuClipboardInfo *info) { - GtkDisplayState *gd = container_of(notifier, GtkDisplayState, cbpeer.update); - QemuClipboardInfo *info = data; QemuClipboardSelection s = info->selection; bool self_update = info->owner == &gd->cbpeer; @@ -118,6 +117,19 @@ static void gd_clipboard_notify(Notifier *notifier, void *data) */ } +static void gd_clipboard_notify(Notifier *notifier, void *data) +{ + GtkDisplayState *gd = + container_of(notifier, GtkDisplayState, cbpeer.notifier); + QemuClipboardNotify *notify = data; + + switch (notify->type) { + case QEMU_CLIPBOARD_UPDATE_INFO: + gd_clipboard_update_info(gd, notify->info); + return; + } +} + static void gd_clipboard_request(QemuClipboardInfo *info, QemuClipboardType type) { @@ -172,7 +184,7 @@ static void gd_owner_change(GtkClipboard *clipboard, void gd_clipboard_init(GtkDisplayState *gd) { gd->cbpeer.name = "gtk"; - gd->cbpeer.update.notify = gd_clipboard_notify; + gd->cbpeer.notifier.notify = gd_clipboard_notify; gd->cbpeer.request = gd_clipboard_request; qemu_clipboard_peer_register(&gd->cbpeer); -- cgit v1.2.3