Another quick and dirty patch:
Its made according to these instructions:
The patch gives a nice speedup boost. Juce feels much better now.
I have not checked for XShmCompletionEvent events, because I don’t know the internals of juce enough to know whether its necessary. So an XIfEvent call or something after blitting might be needed. But so far, I haven’t seen any problems with the current state.
XDestroyImage gives me a freeing-illegal-memory-block error, no matter what I do. After many hours trying to figure out why, I gave up and commented out the call. This probably needs a proper solution…
You probably need to fix the 24/32 stuff better than I did here. Turns out that the server stores 32 bit images no matter what, although the depth is set to 24. My solution is probably working correctly enough though, but the code is not pretty.
I did not add support for XShm for 16 bit displays. Its not difficult, everything just got a bit messy for me. I also guess that you probably will rewrite most of it anyway, and then adding hacks for 16 bit display could make the patch harder to read.
Please apply something like this for the next release.