golang-design / clipboard

📋 cross-platform clipboard package that supports accessing text and image in Go (macOS/Linux/Windows/Android/iOS)
https://golang.design/x/clipboard
MIT License
585 stars 64 forks source link

Does not completely work on Linux #4

Closed DarkFighterLuke closed 3 years ago

DarkFighterLuke commented 3 years ago

Hi again, I'm testing the library with my Arch Linux+KDE Plasma installation (with X11). It seems that the image that I put in clipboard works only on some application (ie. GIMP), but not in others (ie. Xournal++).

I also tried another solution using xclip and it works fine on both (maybe this information can be useful for you).

changkun commented 3 years ago

I doubt this is not an issue from this clipboard package, but a problem with the Xournal++.

With X11 systems, clipboard requires applications to communicate according to the standards, but not forced. This package certainly subject to the standard where when a target application requests the X11 selection, it returns the supported formats, i.e. UTF8_String and image/png. But it totally depends on the target application to handle this information and further request that specific format. This means if Xournal++ does not request the image/png data, then it is not possible to send such data and allow them to copy. See #2 as an example regarding how GIF support is not possible to do in general. The Linux support works with Chromes (as a standard testing environment because JS requires clipboard spec and restricts a browser to handle it well).

The reason why xclip works are simply because of a bug from xclip where they write every data as text buffer, so the image data was requested but handled differently. See formerly observed issue in https://github.com/changkun/midgard/issues/5 and https://github.com/astrand/xclip/issues/113.

This is very unfortunate but I do not have an idea of what we could improve from here.

DarkFighterLuke commented 3 years ago

Ok, thank you for the clear answer!