--- /dev/null
+diff -ruN xchat-2.8.6.orig/src/fe-gtk/xtext.c xchat-2.8.6/src/fe-gtk/xtext.c
+--- xchat-2.8.6.orig/src/fe-gtk/xtext.c 2008-02-24 06:04:30.000000000 +0100
++++ xchat-2.8.6/src/fe-gtk/xtext.c 2008-10-14 11:04:57.000000000 +0200
+@@ -1350,6 +1350,22 @@
+ }
+ }
+
++#ifdef USE_SHM
++static int
++have_shm_pixmaps(Display *dpy)
++{
++ static int checked = 0, major, minor;
++ static Bool have = FALSE;
++
++ if (!checked) {
++ XShmQueryVersion(dpy, &major, &minor, &have);
++ checked = 1;
++ }
++
++ return have;
++}
++#endif
++
+ static void
+ gtk_xtext_paint (GtkWidget *widget, GdkRectangle *area)
+ {
+@@ -1366,8 +1382,12 @@
+ {
+ xtext->last_win_x = x;
+ xtext->last_win_y = y;
+-#if !defined(USE_SHM) && !defined(WIN32)
++#ifndef WIN32
++#ifdef USE_SHM
++ if (xtext->shaded && !have_shm_pixmaps(GDK_WINDOW_XDISPLAY (xtext->draw_buf)))
++#else
+ if (xtext->shaded)
++#endif
+ {
+ xtext->recycle = TRUE;
+ gtk_xtext_load_trans (xtext);
+@@ -3559,6 +3579,11 @@
+ GC tgc;
+ Display *xdisplay = GDK_WINDOW_XDISPLAY (xtext->draw_buf);
+
++#ifdef USE_SHM
++ int shm_pixmaps;
++ shm_pixmaps = have_shm_pixmaps(xdisplay);
++#endif
++
+ XGetGeometry (xdisplay, p, &root, &dummy, &dummy, &width, &height,
+ &dummy, &depth);
+
+@@ -3576,18 +3601,20 @@
+ XFreeGC (xdisplay, tgc);
+
+ #ifdef USE_SHM
+- ximg = get_image (xtext, xdisplay, &xtext->shminfo, 0, 0, w, h, depth, tmp);
+-#else
+- ximg = XGetImage (xdisplay, tmp, 0, 0, w, h, -1, ZPixmap);
++ if (shm_pixmaps)
++ ximg = get_image (xtext, xdisplay, &xtext->shminfo, 0, 0, w, h, depth, tmp);
++ else
+ #endif
++ ximg = XGetImage (xdisplay, tmp, 0, 0, w, h, -1, ZPixmap);
+ XFreePixmap (xdisplay, tmp);
+ } else
+ {
+ #ifdef USE_SHM
+- ximg = get_image (xtext, xdisplay, &xtext->shminfo, x, y, w, h, depth, p);
+-#else
+- ximg = XGetImage (xdisplay, p, x, y, w, h, -1, ZPixmap);
++ if (shm_pixmaps)
++ ximg = get_image (xtext, xdisplay, &xtext->shminfo, x, y, w, h, depth, p);
++ else
+ #endif
++ ximg = XGetImage (xdisplay, p, x, y, w, h, -1, ZPixmap);
+ }
+
+ if (!ximg)
+@@ -3612,7 +3639,7 @@
+ else
+ {
+ #ifdef USE_SHM
+- if (xtext->shm)
++ if (xtext->shm && shm_pixmaps)
+ {
+ #if (GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION == 0)
+ shaded_pix = gdk_pixmap_foreign_new (
+@@ -3630,7 +3657,7 @@
+ }
+
+ #ifdef USE_SHM
+- if (!xtext->shm)
++ if (!xtext->shm || !shm_pixmaps)
+ #endif
+ XPutImage (xdisplay, GDK_WINDOW_XWINDOW (shaded_pix),
+ GDK_GC_XGC (xtext->fgc), ximg, 0, 0, 0, 0, w, h);
+@@ -3650,7 +3677,7 @@
+ if (xtext->pixmap)
+ {
+ #ifdef USE_SHM
+- if (xtext->shm)
++ if (xtext->shm && have_shm_pixmaps(GDK_WINDOW_XDISPLAY (xtext->draw_buf)))
+ {
+ XFreePixmap (GDK_WINDOW_XDISPLAY (xtext->pixmap),
+ GDK_WINDOW_XWINDOW (xtext->pixmap));