aboutsummaryrefslogtreecommitdiff
path: root/ui/gtk-clipboard.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2021-07-19 19:42:15 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2021-12-21 10:50:21 +0400
commit1b17f1e9f962f5ae9cd559d7f23718ceed71b813 (patch)
treeee3a19c25c8d55254cc6ff77c01931680f6c283c /ui/gtk-clipboard.c
parent59127452883afe3d603e90824bb33ac57b4dbee1 (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/gtk-clipboard.c')
-rw-r--r--ui/gtk-clipboard.c20
1 files changed, 16 insertions, 4 deletions
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);