X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Fgrabscreen.c;h=6f88e5a10dc4ad9772c8a9874cf44d41a5968a65;hb=c596d1306f5f92f7eab76224d3b049980a14adcb;hp=edc6acb30819ab8be7a5a38582f2de1f1a005c67;hpb=5b7bc6e70fb439cf4c4bf771ae9f94077fe4fe08;p=xscreensaver diff --git a/utils/grabscreen.c b/utils/grabscreen.c index edc6acb3..6f88e5a1 100644 --- a/utils/grabscreen.c +++ b/utils/grabscreen.c @@ -1,5 +1,5 @@ -/* xscreensaver, Copyright (c) 1992, 1993, 1994, 1997 - * Jamie Zawinski +/* xscreensaver, Copyright (c) 1992, 1993, 1994, 1997, 1998 + * 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 @@ -132,7 +132,10 @@ BadWindow_ehandler (Display *dpy, XErrorEvent *error) if (error->error_code == BadWindow || error->error_code == BadDrawable) return 0; else if (!old_ehandler) - abort(); + { + abort(); + return 0; + } else return (*old_ehandler) (dpy, error); } @@ -245,7 +248,8 @@ grab_screen_image_1 (Screen *screen, Window window) XWindowAttributes xgwa2; XGetWindowAttributes (dpy, window, &xgwa2); fprintf(stderr, "%s: ", progname); - describe_visual(stderr, screen, xgwa2.visual); + describe_visual(stderr, screen, xgwa2.visual, ####); + fprintf (stderr, "\n"); } #endif /* DEBUG */ @@ -284,6 +288,13 @@ grab_screen_image_1 (Screen *screen, Window window) #endif /* DEBUG */ copy_default_colormap_contents (screen, xgwa.colormap, xgwa.visual); raise_window(dpy, window, saver_p); + + /* Generally it's bad news to call XInstallColormap() explicitly, + but this file does a lot of sleazy stuff already... This is to + make sure that the window's colormap is installed, even in the + case where the window is OverrideRedirect. */ + if (xgwa.colormap) XInstallColormap (dpy, xgwa.colormap); + XSync (dpy, False); } } else /* root_p */ @@ -522,13 +533,23 @@ read_display (Screen *screen, Window window, Pixmap into_pixmap, return False; } - /* Uh, this can't be right, can it? But it's necessary. X sucks. - If the visual is of depth 24, but the image came back as depth 32, - hack it to be 24 lest we get a BadMatch from XPutImage. (I presume - I'm expected to look at the server's pixmap formats or some such - nonsense... but fuck it.) + /* XReadDisplay tends to LIE about the depth of the image it read. + It is returning an XImage which has `depth' and `bits_per_pixel' + confused! + + That is, on a 24-bit display, where all visuals claim depth 24, and + where XGetImage would return an XImage with depth 24, and where + XPutImage will get a BadMatch with images that are not depth 24, + XReadDisplay is returning images with depth 32! Fuckwits! + + So if the visual is of depth 24, but the image came back as depth 32, + hack it to be 24 lest we get a BadMatch from XPutImage. + + I wonder what happens on an 8-bit SGI... Probably it still returns + an image claiming depth 32? Certainly it can't be 8. So, let's just + smash it to 32... */ - if (xgwa.depth == 24 && image->depth == 32) + if (image->depth == 32 /* && xgwa.depth == 24 */ ) image->depth = 24; /* If the visual of the window/pixmap into which we're going to draw is