+ /* Ok, this like, sucks and stuff. There are some XFree86 systems
+ that have depth-24 visuals, that do not accept depth-32 XImages!
+ Which if you ask me is just absurd, since all it would take is
+ for the server to truncate the bits in that case. So, this crap
+ here detects the specific case of: we have chosen depth 32;
+ and the server does not support depth 32. In that case, we
+ try and use depth 16 instead.
+
+ The real fix would be to rewrite this program to deal with
+ depth 24 directly (or even better, arbitrary depths, but that
+ would mean going through the XImage routines instead of messing
+ with the XImage->data directly.)
+
+ jwz, 18-Mar-99: well, the X servers I have access to these days do
+ support 32-deep images on deep visuals, so I no longer have the
+ ability to test this code -- but it was causing problems on the
+ visuals that I do have, and I think that's because I mistakenly
+ wrote `pfv[i].depth' when I meant to write `pfv[i].bits_per_pixel'.
+ The symptom I was seeing was that the grid was 64x64, but the
+ images were being drawn 32x32 -- so there was a black stripe on
+ every other row. Wow, this code sucks so much.
+ */
+ if (st->pdepth == 32)
+ {
+ int i, pfvc = 0;
+ Bool ok = False;
+ XPixmapFormatValues *pfv = XListPixmapFormats (st->dpy, &pfvc);
+ for (i = 0; i < pfvc; i++)
+ if (pfv[i].bits_per_pixel == st->pdepth)
+ ok = True;
+ if (!ok)
+ st->pdepth = 16;
+ }
+
+ st->cmap = st->xgwa.colormap;
+ st->ncolors = get_integer_resource (st->dpy, "colors", "Integer");