Hacker News new | ask | show | jobs
by wongarsu 1331 days ago
I assume it's meant as a simplification?

For comparison, when you copy something in Windows, for each offered format the software can decide to either immediately give the data to the OS for safe-keeping, or to just announce the availability of data in that format, and generate it on request. The intention obviously being that for example Excel might immediately put the text representation in the OS buffer, but only create the HTML version if anyone requests it. This was invented in a time when those CPU cycles mattered after all.

The wayland setup reads like someone looked at a Windows-like design, thought having two ways clipboard data could be handled was confusing, and decided to simplify it by axing the straightforward path that 99% of clipboard data takes.

1 comments

I’m a windows desktop dev since the last millennium and tbh never knew that there was an announce api. It seems really difficult to use as a tiered solution where you only return the more complex data when asked. After all, you must then still snapshot that data from the moment the copy occurred to be able to provide a snapshot from the time of the copy later?
You snapshot the data in your application's native data format, then you can convert it later to the best match for the consumer.

Taking the Excel example form above: You got to store the cell layout and values. If it's pasted into a different excel sheet you pass that structure over. If it is pasted in a richt text editor it is converted to some richt text table format. If it is pasted to a plain text editor it is made tab separated or something and if pasted into an image editor it is renders into a bmp (well, Excel doesn't do that, but imagine ...) Doing all those conversions beforehand, just due to pressing Ctrl-C, is expensive as most of the time none is needed.

The Excel clipboard has a more complex model:

- If the copied data is pasted in the same Excel instance, then the system clipboard isn’t used at all and native Excel objects are pasted.

- If data is pasted in an OLE-enabled application (e.g. Word or PowerPoint), then an OLE-specific method is used.

- If the data is pasted into another Excel instance or into another application, then the system clipboard is used, but without the possibility to transfer native Excel objects, only csv, RTF, html, text, image, or an ancient spreadsheet-like format called SYLK.

And at any time during this process you can easily and readily lose the copy from Excel.

God its so annoying to tab back to the sheet to hit Ctrl-C again.

True, but doing it "right" (especially considering 1990ies hardware) isn't easy. And Windows has the option, to just pass it to the system, if you don't have complex needs (only copying plain text etc.)
Usually applications just delete the clipboard data announcement once it first changes in the application