ui/clipboard: add a clipboard reset serial event

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-07-19 19:49:56 +04:00
parent 349504e5a1
commit 505dbf9b99
6 changed files with 37 additions and 0 deletions

View File

@ -73,11 +73,13 @@ struct QemuClipboardPeer {
* enum QemuClipboardNotifyType
*
* @QEMU_CLIPBOARD_UPDATE_INFO: clipboard info update
* @QEMU_CLIPBOARD_RESET_SERIAL: reset clipboard serial
*
* Clipboard notify type.
*/
enum QemuClipboardNotifyType {
QEMU_CLIPBOARD_UPDATE_INFO,
QEMU_CLIPBOARD_RESET_SERIAL,
};
/**
@ -230,6 +232,13 @@ void qemu_clipboard_info_unref(QemuClipboardInfo *info);
*/
void qemu_clipboard_update(QemuClipboardInfo *info);
/**
* qemu_clipboard_reset_serial
*
* Reset the clipboard serial.
*/
void qemu_clipboard_reset_serial(void);
/**
* qemu_clipboard_request
*

View File

@ -129,6 +129,13 @@ void qemu_clipboard_request(QemuClipboardInfo *info,
info->owner->request(info, type);
}
void qemu_clipboard_reset_serial(void)
{
QemuClipboardNotify notify = { .type = QEMU_CLIPBOARD_RESET_SERIAL };
notifier_list_notify(&clipboard_notifiers, &notify);
}
void qemu_clipboard_set_data(QemuClipboardPeer *peer,
QemuClipboardInfo *info,
QemuClipboardType type,

View File

@ -1837,6 +1837,9 @@ static void cocoa_clipboard_notify(Notifier *notifier, void *data)
case QEMU_CLIPBOARD_UPDATE_INFO:
cocoa_clipboard_update_info(notify->info);
return;
case QEMU_CLIPBOARD_RESET_SERIAL:
/* ignore */
return;
}
}

View File

@ -127,6 +127,9 @@ static void gd_clipboard_notify(Notifier *notifier, void *data)
case QEMU_CLIPBOARD_UPDATE_INFO:
gd_clipboard_update_info(gd, notify->info);
return;
case QEMU_CLIPBOARD_RESET_SERIAL:
/* ignore */
return;
}
}

View File

@ -466,6 +466,15 @@ static void vdagent_clipboard_update_info(VDAgentChardev *vd,
}
}
static void vdagent_clipboard_reset_serial(VDAgentChardev *vd)
{
Chardev *chr = CHARDEV(vd);
/* reopen the agent connection to reset the serial state */
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
qemu_chr_be_event(chr, CHR_EVENT_OPENED);
}
static void vdagent_clipboard_notify(Notifier *notifier, void *data)
{
VDAgentChardev *vd =
@ -476,6 +485,9 @@ static void vdagent_clipboard_notify(Notifier *notifier, void *data)
case QEMU_CLIPBOARD_UPDATE_INFO:
vdagent_clipboard_update_info(vd, notify->info);
return;
case QEMU_CLIPBOARD_RESET_SERIAL:
vdagent_clipboard_reset_serial(vd);
return;
}
}

View File

@ -230,6 +230,9 @@ static void vnc_clipboard_notify(Notifier *notifier, void *data)
case QEMU_CLIPBOARD_UPDATE_INFO:
vnc_clipboard_update_info(vs, notify->info);
return;
case QEMU_CLIPBOARD_RESET_SERIAL:
/* ignore */
return;
}
}