On Fri, Dec 30, 2022 at 6:49 PM <dengp...@chinatelecom.cn> wrote:
>
> From: "dengp...@chinatelecom.cn" <dengp...@chinatelecom.cn>
>
> Abstract vdagent registry logic into
> vdagent_register_to_qemu_clipboard.
>
> Note that trace log of vdagent_recv_caps also be added.
>
> Signed-off-by: dengp...@chinatelecom.cn <dengp...@chinatelecom.cn>
> Signed-off-by: liuy...@chinatelecom.cn <liuy...@chinatelecom.cn>

Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com>

> ---
>  ui/trace-events |  1 +
>  ui/vdagent.c    | 20 +++++++++++++-------
>  2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/ui/trace-events b/ui/trace-events
> index 977577fbba..5e50b60da5 100644
> --- a/ui/trace-events
> +++ b/ui/trace-events
> @@ -143,6 +143,7 @@ vdagent_cb_grab_selection(const char *name) "selection %s"
>  vdagent_cb_grab_discard(const char *name, int cur, int recv) "selection %s, 
> cur:%d recv:%d"
>  vdagent_cb_grab_type(const char *name) "type %s"
>  vdagent_cb_serial_discard(uint32_t current, uint32_t received) "current=%u, 
> received=%u"
> +vdagent_recv_caps(uint32_t caps) "received caps %u"
>
>  # dbus.c
>  dbus_registered_listener(const char *bus_name) "peer %s"
> diff --git a/ui/vdagent.c b/ui/vdagent.c
> index 645383b4ec..38061d5b38 100644
> --- a/ui/vdagent.c
> +++ b/ui/vdagent.c
> @@ -696,6 +696,16 @@ static void vdagent_chr_open(Chardev *chr,
>      *be_opened = true;
>  }
>
> +static void vdagent_register_to_qemu_clipboard(VDAgentChardev *vd)
> +{
> +    if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) {
> +        vd->cbpeer.name = "vdagent";
> +        vd->cbpeer.notifier.notify = vdagent_clipboard_notify;
> +        vd->cbpeer.request = vdagent_clipboard_request;
> +        qemu_clipboard_peer_register(&vd->cbpeer);
> +    }
> +}
> +
>  static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)
>  {
>      VDAgentAnnounceCapabilities *caps = (void *)msg->data;
> @@ -720,14 +730,10 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, 
> VDAgentMessage *msg)
>          qemu_input_handler_activate(vd->mouse_hs);
>      }
>
> -    memset(vd->last_serial, 0, sizeof(vd->last_serial));
> +    trace_vdagent_recv_caps(vd->caps);
>
> -    if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) {
> -        vd->cbpeer.name = "vdagent";
> -        vd->cbpeer.notifier.notify = vdagent_clipboard_notify;
> -        vd->cbpeer.request = vdagent_clipboard_request;
> -        qemu_clipboard_peer_register(&vd->cbpeer);
> -    }
> +    memset(vd->last_serial, 0, sizeof(vd->last_serial));
> +    vdagent_register_to_qemu_clipboard(vd);
>  }
>
>  static void vdagent_chr_recv_msg(VDAgentChardev *vd, VDAgentMessage *msg)
> --
> 2.27.0
>
>


-- 
Marc-André Lureau

Reply via email to