}
}
+#ifdef USE_SHM
+static int
+have_shm_pixmaps(Display *dpy)
+{
+ int major, minor;
+ static int checked = 0;
+ static int have = FALSE;
+
+ if (!checked)
+ {
+ XShmQueryVersion (dpy, &major, &minor, &have);
+ checked = 1;
+ }
+
+ return have;
+}
+#endif
+
static void
gtk_xtext_paint (GtkWidget *widget, GdkRectangle *area)
{
{
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);
xtext_class->word_click = NULL;
}
-GtkType
+GType
gtk_xtext_get_type (void)
{
- static GtkType xtext_type = 0;
+ static GType xtext_type = 0;
if (!xtext_type)
{
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);
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)
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 (
}
#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);
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));