snowcone-ltd / libmatoya

Cross-platform application development.
MIT License
592 stars 53 forks source link

Local Clipboard Corruption on Linux when Non-Text Items are Copied #81

Closed Tortue95 closed 1 year ago

Tortue95 commented 1 year ago

Problem Description:

When starting Parsec on a Linux system, the local clipboard is corrupted when placing images, files or other items other than text. This issue results in the loss of data and makes it difficult for users to transfer data between different applications.

Steps to Reproduce:

Expected behaviour:

The copied item should be pasted as expected, without loss of data.

Actual behaviour:

The pasted item is replaced by the last copied text, and the image/file/... is lost.

Environment:

Additional Information:

The problem comes from the X11 stock api which has no event on clipboard modifications. The libmatoya library, to work around this lack, retrieves the clipboard property each time it loses its ownership to another application. This is done to detect any modification of the clipboard content by other applications. When the libmatoya library recovers the clipboard ownership, it puts back in the clipboard what was added by the previous application. However, when the content is read, it is converted to UTF-8, which results in data loss if the content is not textual. As a result, the local clipboard is corrupted when non-textual items, such as images or files, are copied.