+ m_window->ClearUpdateRegion();
+}
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+/*
+ Used when copying between drawables on different (Display*) m_displays. Not
+ very fast, but better than giving up.
+*/
+
+static void XCopyRemote(Display *src_display, Display *dest_display,
+ Drawable src, Drawable dest,
+ GC destgc,
+ int srcx, int srcy,
+ unsigned int w, unsigned int h,
+ int destx, int desty,
+ bool more, XImage **cache)
+{
+ XImage *image, *destimage;
+ Colormap destcm, srccm;
+ static const int CACHE_SIZE = 256;
+
+ unsigned int i, j;
+ unsigned long cachesrc[CACHE_SIZE], cachedest[CACHE_SIZE];
+ int k, cache_pos, all_cache;
+
+ if (!cache || !*cache)
+ image = XGetImage(src_display, src, srcx, srcy, w, h, AllPlanes, ZPixmap);
+ else
+ image = *cache;
+
+ destimage = XGetImage(dest_display, dest, destx, desty, w, h, AllPlanes, ZPixmap);
+
+ srccm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) src_display);
+ destcm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dest_display);
+
+ cache_pos = 0;
+ all_cache = FALSE;
+
+ for (i = 0; i < w; i++)
+ for (j = 0; j < h; j++) {
+ unsigned long pixel;
+ XColor xcol;
+
+ pixel = XGetPixel(image, i, j);
+ for (k = cache_pos; k--; )
+ if (cachesrc[k] == pixel) {
+ pixel = cachedest[k];
+ goto install;
+ }
+ if (all_cache)
+ for (k = CACHE_SIZE; k-- > cache_pos; )
+ if (cachesrc[k] == pixel) {
+ pixel = cachedest[k];
+ goto install;
+ }
+
+ cachesrc[cache_pos] = xcol.pixel = pixel;
+ XQueryColor(src_display, srccm, &xcol);
+ if (!XAllocColor(dest_display, destcm, &xcol))
+ xcol.pixel = 0;
+ cachedest[cache_pos] = pixel = xcol.pixel;
+
+ if (++cache_pos >= CACHE_SIZE) {
+ cache_pos = 0;
+ all_cache = TRUE;
+ }
+
+install:
+ XPutPixel(destimage, i, j, pixel);
+ }
+
+ XPutImage(dest_display, dest, destgc, destimage, 0, 0, destx, desty, w, h);
+ XDestroyImage(destimage);
+
+ if (more)
+ *cache = image;
+ else
+ XDestroyImage(image);
+}
+
+#if 0
+
+/* Helper function for 16-bit fonts */
+static int str16len(const char *s)
+{
+ int count = 0;
+
+ while (s[0] && s[1]) {
+ count++;
+ s += 2;
+ }
+
+ return count;