In message <
gemini.m2dzv70...@alanwrigley.com>
on 12 Apr 2012 Alan Wrigley wrote:
> There's been a discussion in the last couple of days on c.s.a.misc about
> problems with UniClip and the global clipboard. I want to raise the issue
> here to get some feedback from others.
>
> The basic problem is this: UniClip (which attempts to share the clipboard
> between more than one machine running either RISC OS or Windows) can only
> operate properly by taking continual ownership of the 'global' clipboard in
> RISC OS on non-Select machines. UniClip also currently only shares text
> data and so it will not handle formatted data such as that produced by
> Ovation Pro, EasiWriter etc. UniClip's claiming of the clipboard apparently
> loses the formatting when a copy/paste operation is performed within one of
> these apps.
As far as I have followed this, when UniClip receives a Message_ClaimEntity
with bit 2 set (e.g. EasiWriter claiming the clipboard when the user has
pressed Ctrl-C in a document) UniClip immediately requests the data in text
format using Message_DataRequest, and then claims the clipboard itself. It
claims the clipboard because otherwise it might receive no notification if
the same editor (e.g. EasiWriter) subsequently changed the contents of the
clipboard. This is because of the unfortunate recommendation in AppNote 240
where Acorn suggested that the application owning the clipboard should spot
that it already owned it, and not send round a further Message_ClaimEntity.
UniClip needs to know the current clipboard content all the time as it has to
share it with other computers so that the content is present and ready to be
pasted on each other machine. It cannot fetch on demand as Windows doesn't
work that way.
Have I got that right?
> The global clipboard (which is of course not a real clipboard at all) was
> created to enable apps to share clipboard data with each other, which is a
> feature built into Windows but not into RO. Editors on RO have known how to
> move their own data around within themselves long before the global
> clipboard protocol was devised.
>
> So my view at the moment is that when an editor is asked for a clip in text
> format only, it should supply it in text only - which most if not all
> currently do. But if it is an editor such as EasiWriter or OPro whose data
> has a more complex format should keep that data to themselves and not rely
> on the global clipboard to supply anything other than it asked for in the
> first place. After all, the whole purpose of the global clipboard was to
> allow apps to share data, not for apps to pass data around internally.
>
> In other words, IMO a request for TEXT data from the clipboard should not
> cause an app to rely on this for later pasting if its own internal format
> is more complex. It should be able to move formatted data around internally
> without reliance on the clipboard if, and only if, the clipboard has not
> requested the data in the app's format.
But how is EasiWriter to know whether to paste from an internal copy of the
data or from the global clipboard? As far as EasiWriter is concerned,
UniClip's behaviour is indistinguishable from the following sequence of
events:
1. User sends data to clipboard in EasiWriter by copying a selection.
2. Another application (e.g. Zap) requests the clipboard in text format.
3. Zap claims the clipboard (perhaps user has made a selection in Zap and
copied to the clipboard from that? Easiwriter cannot tell.)
4. User presses Ctrl-V in EasiWriter document. EasiWriter goes to external
application to ask for the data back. Zap (or UniClip) does not offer
anything richer than text, so that's what EasiWriter gets.
Possible solutions that come to mind, that don't require an alteration to the
protocol and all the applications:
A.
When EasiWriter loses the clipboard, it could remember what it had had on
it, including a hash of the version of the data supplied to the requester
(e.g. text). When it does a paste and fetches the text back, it could
calculate a hash and note that the text version of the file is unchanged, and
then use its own internal rich copy instead.
Problems with that: it's messy, and the requesting content from EasiWriter
and the claiming of the clipboard are two separate operations which might not
be linked at all.
B.
Instead of claiming the clipboard all the time, UniClip could note when it
does not own the clipboard, and request a text version of the data from the
owner every tenth of a second, or at a suitable interval determined by the
user. UniClip could then compare before transmitting to the other machines.
Could have performance problems if there is a high cost to the application
providing text.
C.
UniClip could request the data in formats other than text and store all of
them ready to send back.
Problems: memory. And there's no easy way to find out what filetypes are
actually available from the clipboard owner: you just provide your own
preferred list and the owner responds with a single version. You would have
to send 4096 Message_DataRequest messages to work out which filetypes were
available, if you were doing a thorough job!
What would happen if another application running on the same machine acted
like UniClip? They would continually be bouncing clipboard claims between
them!
You mention non-Select machines. Can you explain what the difference is with
Select? Could that solution be ported to RO5, and is it a real solution that
is fully compatible with the protocol in AppNote 240?
--
Matthew Phillips
Durham