Currently, a vnc client has no reliable way of determining if a
guest side clipboard peer is present. Using VNC_ENCODING_CLIPBOARD_EXT
allows the client to try and infer peer presence based on NOTIFY event,
but this only works if the unregistering peer has ownership over the
clipboard, otherwise the loss of peer is silent.

This is solved with the new ClipboardAvailability pseudo-encoding,
which adds a mechanism for explicitly notifying the client of
clipboard availability.

The vnc server will emit a notification in the form of a pseudo-rect
immediately after receiving the pseudo-encoding enabling this feature.
Notification will be repeated when a ClipboardPeer with .guest=true
registers or unregisters.

The commit adding the new vnc feature is preceeded by 3 commits adding the
prerequisite functionality, making it 4 parts in total:

1. Add PEER_UPDATE notification to ui/clipboard and call it on each
    register/unregister.

2. Add *guest* field to ClipboardPeer, which indicates that a peer is
    guest side. Currently it's only set on vdagent's cbpeer.

3. Factor out vnc peer registration into a separate function.
    Currently it's inlined in vnc_server_cut_text_caps.

4. Add the new vnc feature, register the clipboard peer for update
    notifications, emit availability message on set_encodings and
    on peer updates.

Changes from v2:
- Completed the process of adding a new pseudo-encoding into rfbproto.
https://github.com/rfbproto/rfbproto/commit/34f9bb5ec191839683609a7d01552f8e8f16bb22
- Adapted the implementation to reflect latest changes in rfbproto
(new top level pseudo-encoding instead of qemu range, use pseudo-rect
instead of new server msg)
- Prevent qemu-vnc from accepting the new pseudo-encoding, since it
does not implement it.
- Misc fixes.

Lukasz Kornicki (4):
  ui/clipboard: add clipboard peer update notification
  ui/clipboard: keep track of clipboard peer side
  ui/vnc-clipboard: factor out clipboard peer registration
  ui/vnc: notify client of clipboard availability

 include/ui/clipboard.h     | 28 ++++++++++++++++++++
 tools/qemu-vnc/clipboard.c |  3 +++
 tools/qemu-vnc/qemu-vnc.c  |  7 ++++-
 ui/clipboard.c             | 35 +++++++++++++++++++++++++
 ui/cocoa.m                 |  3 +++
 ui/dbus-clipboard.c        |  3 +++
 ui/gtk-clipboard.c         |  3 +++
 ui/trace-events            |  2 ++
 ui/vdagent.c               |  4 +++
 ui/vnc-clipboard.c         | 52 +++++++++++++++++++++++++++++++++-----
 ui/vnc.c                   |  9 +++++++
 ui/vnc.h                   |  9 +++++++
 12 files changed, 151 insertions(+), 7 deletions(-)

-- 
2.43.0


Reply via email to