Cutting and pasting a file is not possible
Description
Normally, cutting is implemented by send-then-delete. E.g.: a client offers a selection, another accepts, and after sending the data, the first client can delete its copy of it.
This approach does not work when copying files, which are usually offered as mime-type text/uri-list
. The clipboard and files have a slightly different flow: a client offers a selection with mime-type text/uri-list
, and when another client accepts this offer, it receives the URI to the file and can create a copy of the file itself (or do whatever is correct when pasting into the target client).
Cutting, however, is not possible. When the receiving client receives the URI, it has no way of determining if this is a copy or cut operation, so will always copy the file. The sending client also cannot delete the file; it only knows when the URI has been read, but cannot know when the second client has copied the file.
Even if it were possible to determine when the receiving client is done copying the file, this implies that the whole process creates a copy and then deletes an original. This is a very inefficient way to move a file, and is extremely problematic for large files (e.g.: an 8GB ISO image).
Possible solutions
A possible solution is to use the wl_data_source::set_actions and wl_data_offer::action; the copy
actions is essentially what happens now, and the move
action is what would be used in cases when cutting.
The actions, however, are only meaningful in the case of cutting and pasting a file (which is an incredibly common use-case for the clipboard). For the classic scenario of cutting a portion of text or arbitrary bytes, the source client owns this information and can perform the deletion itself after sending.