Hi All,

    xclip can be used to inspect the clipboard:

$ xclip -verbose -o -t TARGETS
Connected to X server.
Using TARGETS.
Type is ATOM.
TARGETS
image/png
image/jpeg

and the source code is available.  Using it the code in sqUnixX11.c should be fixable.  Good luck!


On Tue, Mar 28, 2023 at 1:47 PM Eliot Miranda <eliot.miranda@gmail.com> wrote:
Hi Hilaire, Hi unix/linux bods,

    I've got the ClipboardExtendedPlugin to compile and run on linux, but the results are disappointing.  The guts of the implementation is in this interfacer in platforms/unix/vm-display/x11/sqUnixX11.c:

char **clipboardGetTypeNames();
sqInt clipboardSizeWithType(char *typeName, int ntypeName);
sqInt clipboardReadIntoAt(sqInt count, sqInt byteArrayIndex, sqInt startIndex);
void *firstIndexableField(sqInt oop);
void clipboardWriteWithType(char *data, size_t ndata, char *typeName, size_t ntypeName, int isDnd, int isClaiming);

At a trivial level the code in platforms/unix/plugins/ClipboardExtendedPlugin/sqUnixExtendedClipboard.c ncould be improved if

// TODO: clipboardGetTypeNames() should be cached. And the simplest way to do
// this is to have display_clipboardGetTypeNames do the cacheing and freeing,
// it freeing the previous invocation's data if the clipboard has changed,
// then all the multiple frees below can disappear. Further, the signature can
// be changed to include a pointer to the item count and then the indexing
// can safely be done directly. eem. '23/3/25

But more fundamentally the API implementation in sqUnixX11.c needs extending.  I recommend playing with e.g. firefox and the file finder, copying various items, and observing the state of the clipboard, through a suitable viewer. I prematurely deleted some dubious code from sqUnixExtendedClipboard.c that one might be able to construct a simple viewer/lister from.  In any case, the relevant information does not percolate up from the sqUnixX11.c API to allow the sqUnixExtendedClipboard.c API to pass the desired information up to Squeak.  An X11 maven should be able to get this going quickly.  Any HPI linux users feel like having a go?

If so, viel Glück!

On Thu, Mar 23, 2023 at 5:58 PM Eliot Miranda <eliot.miranda@gmail.com> wrote:
Hi Hilaire,

On Mar 23, 2023, at 2:38 PM, Hilaire Fernandes <hfern@free.fr> wrote:



Hi Eliot,

I will try to take a deep look as I have also interest for tablet support on Linux. This is a completely new domain (VM) for me.


I hope you find it fun!

Your job is to implement this interface:

void sqPasteboardClear(void *inPasteboard); sqInt sqPasteboardGetItemCount(void *inPasteboard); sqInt sqPasteboardCopyItemFlavorsitemNumber(void *inPasteboard, sqInt formatNumber); void *sqCreateClipboard(void); void sqPasteboardPutItemFlavordatalengthformatTypeformatLength(void *inPasteboard, char *inData, sqInt dataLength, char *format, sqInt formatLength); void sqPasteboardPutItemFlavordatalengthformatType(void *inPasteboard, char *inData, sqInt dataLength, sqInt format); sqInt sqPasteboardCopyItemFlavorDataformatformatLength(void *inPasteboard, char *format, sqInt formatLength); sqInt sqPasteboardCopyItemFlavorDataformat(void *inPasteboard, sqInt format); sqInt sqPasteboardhasDataInFormatformatLength(void *inPasteboard, char *format, sqInt formatLength); sqInt sqPasteboardhasDataInFormat(void *inPasteboard, sqInt format); which is present only in src/plugins/ClipboardExtendedPlugin/ClipboardExtendedPlugin.c, a departure from the house style which would have put it in platforms/Cross/plugins/ClipboardExtendedPlugin/ClipboardExtendedPlugin.h; no doubt John had his reasons.

Use 
platforms/iOS/plugins/ClipboardExtendedPlugin/sqMacExtendedClipboard.m & platforms/win32/plugins/ClipboardExtendedPlugin/sqWin32ExtendedClipboard.c as guides. The Mac uses strings to identify clipboard types (the char *format, sqInt formatLength) variant, as opposed to win32, which uses integers (the sqInt format variant). Whichever works.

You’ll implement it in 
platforms/unix/plugins/ClipboardExtendedPlugin/sqUnixExtendedClipboard.c

Thanks

Hilaire

Le 23/03/2023 à 21:05, Eliot Miranda a écrit :
As John said it doesn't appear to exist for Linux.  But X11 has a clipboard and implementing the innards for X11 shouldn't be that difficult.  The only complication is that if one wants to do the job "properly" one has to extend the indirection scheme Ian Piumarta came up with so that it can work on the other graphical back-ends such as the raw frame buffer.  Hillaire, if you're interested in implementing the X11 ExtendedClipboard internals I'm happy to answer any questions you have.
-- 
GNU Dr. Geo
http://drgeo.eu
http://blog.drgeo.eu


--
_,,,^..^,,,_
best, Eliot


--
_,,,^..^,,,_
best, Eliot