LWJGL3 GLFW clipboard support

Started by Cornix, February 20, 2015, 10:28:49

Previous topic - Next topic

Cornix

Hello everyone.

I was looking into the new smexy lwjgl3, and it is really nice what you guys have done here.
But I would like to know if there is any way to store anything else but Strings in the clipboard.
In AWT you could store any kind of data, images, java objects, etc, in the clipboard and I would like to do this too.
Any advice? Or is this impossible at the moment?

Thanks for the help.

spasi

There's an open issue for image data, currently targeted for GLFW 3.2.

quew8

Well I'm pretty sure the implementation of the clipboard on modern OSs are just pure data storage. The operating system does some wizardry to detect what the data is most likely to be (and according to wikipedia Windows even converts it to other formats that are more likely to be recognized. Hmmm). So you could probably do some of your own wizardry to store any data as a string (pretty difficult if it's an image) but it would be difficult as I'm fairly certain a null character which is just "0" would be interpreted as the end of the string and so you're data might be cut off.

If you were going to try that (and I wouldn't advise it) I expect using GLFW's native method directly would be easier.

Kai

Under Windows the clipboard data is essentially just a byte array accompanied by a format specifier, which tells about the format of the data.
Looking at the definite source for information here, the Win32 API, there are predefined formats, such as raw unformatted text, bitmap, device-independent bitmap (DIB), a list of files in the file system, and so on.
Additionally, an application putting something in the clipboard (the clipboard owner) can register custom formats, in the form of strings/names, if the default ones do not fit its purpose.
This is useful if an application (the clipboard viewer), wants to obtain the clipboard data and see what format it has and whether it understands that data (for example when you press Strg+V).
For example the format name "Rich Text Format" is a commonly agreed-upon format understood by many applications and once an application sees that format, it can assume that the data in the clipboard is a formatted text.

So, if you want to put an image or a list of file system files in the clipboard with LWJGL3 or GLFW, you are going to have to implement that yourself with the help of the Win32 API (or whatever APIs the other OS'es provide for that), since currently there is no way of doing it with GLFW.

Cornix

Its not that important, I was mostly asking out of curiousity.