X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Fvisual.c;h=670ea0edb1b390608f834832c21f1412e5c02bd9;hb=cf665b135b41d4f42067f9d9a8111c9602777cc1;hp=42ce36e88ab2ac1eff3a8d53fb27922382a42525;hpb=f3e0240915ed9f9b3a61781f5c7002d587563fe0;p=xscreensaver diff --git a/utils/visual.c b/utils/visual.c index 42ce36e8..670ea0ed 100644 --- a/utils/visual.c +++ b/utils/visual.c @@ -1,5 +1,5 @@ -/* xscreensaver, Copyright (c) 1993, 1994, 1995, 1996, 1997 - * by Jamie Zawinski +/* xscreensaver, Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 + * by Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -303,6 +303,39 @@ visual_depth (Screen *screen, Visual *visual) } +#if 0 +/* You very probably don't want to be using this. + Pixmap depth doesn't refer to the depths of pixmaps, but rather, to + the depth of protocol-level on-the-wire pixmap data, that is, XImages. + To get this info, you should be looking at XImage->bits_per_pixel + instead. (And allocating the data for your XImage structures by + multiplying ximage->bytes_per_line by ximage->height.) + */ +int +visual_pixmap_depth (Screen *screen, Visual *visual) +{ + Display *dpy = DisplayOfScreen (screen); + int vdepth = visual_depth (screen, visual); + int pdepth = vdepth; + int i, pfvc = 0; + XPixmapFormatValues *pfv = XListPixmapFormats (dpy, &pfvc); + + /* Return the first matching depth in the pixmap formats. If there are no + matching pixmap formats (which shouldn't be able to happen at all) then + return the visual depth instead. */ + for (i = 0; i < pfvc; i++) + if (pfv[i].depth == vdepth) + { + pdepth = pfv[i].bits_per_pixel; + break; + } + if (pfv) + XFree (pfv); + return pdepth; +} +#endif /* 0 */ + + int visual_class (Screen *screen, Visual *visual) { @@ -340,8 +373,9 @@ has_writable_cells (Screen *screen, Visual *visual) } void -describe_visual (FILE *f, Screen *screen, Visual *visual) +describe_visual (FILE *f, Screen *screen, Visual *visual, Bool private_cmap_p) { + char n[10]; Display *dpy = DisplayOfScreen (screen); XVisualInfo vi_in, *vi_out; int out_count; @@ -350,7 +384,12 @@ describe_visual (FILE *f, Screen *screen, Visual *visual) vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask), &vi_in, &out_count); if (! vi_out) abort (); - fprintf (f, "0x%02x (%s depth: %2d, cmap: %3d)\n", + if (private_cmap_p) + sprintf(n, "%3d", vi_out->colormap_size); + else + strcpy(n, "default"); + + fprintf (f, "0x%02x (%s depth: %2d, cmap: %s)\n", (unsigned int) vi_out->visualid, (vi_out->class == StaticGray ? "StaticGray, " : vi_out->class == StaticColor ? "StaticColor," : @@ -359,7 +398,7 @@ describe_visual (FILE *f, Screen *screen, Visual *visual) vi_out->class == PseudoColor ? "PseudoColor," : vi_out->class == DirectColor ? "DirectColor," : "UNKNOWN: "), - vi_out->depth, vi_out->colormap_size /*, vi_out->bits_per_rgb*/); + vi_out->depth, n); XFree ((char *) vi_out); }