SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Support X11 incremental clipboard transfers

Open raiguard opened this issue 1 year ago • 2 comments

In our game, copy/pasting very large strings is relatively common, as users can share "blueprint strings" that can grow to be several megabytes large. I attempted to change our codebase to rely on SDL's clipboard functions in lieu of our custom implementations, but that made users unable to paste large blueprint strings on X11.

Some investigation has revealed the existence of the INCR mechanism in X11 to transfer large selections in the clipboard. Our custom X11 clipboard code implements this, but it appears that the SDL X11 clipboard does not, meaning that if this mechanism is used, pasting into the SDL application will not work. I would love it if this could be supported so I can fully rely on the SDL clipboard functions in the future!

Attached below is the problematic string.

huge-blueprint.txt

raiguard avatar Jan 18 '24 18:01 raiguard

Apologies, immediately after posting I noticed that there is a FIXME in SDL3 to implement this. I would greatly appreciate if it could be done and backported to SDL2, but it's not an enormous deal since our custom code works well enough.

raiguard avatar Jan 18 '24 18:01 raiguard

We're working on showstoppers for 2.30 and focused on moving towards SDL 3.0 release. Feel free to submit a PR that implements this though!

slouken avatar Jan 18 '24 18:01 slouken

@raiguard When you get a chance to test that PR, let me know; you have the best possible test case for it, so if it covers your needs, I'll merge it.

icculus avatar May 28 '24 06:05 icculus

I made a small app to test this and it appears to work great! Unfortunately I cannot test it with the actual game since we are still on SDL2, but it should theoretically work just the same.

raiguard avatar May 29 '24 19:05 raiguard

Would this be difficult to cherry pick to SDL2? I assume the surrounding code is pretty different.

icculus avatar May 29 '24 19:05 icculus

Would this be difficult to cherry pick to SDL2? I assume the surrounding code is pretty different.

Yep, it is.

slouken avatar May 30 '24 23:05 slouken