X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fxscreensaver-getimage.c;h=24c0246e262d2c1a1214f5e5d666121c5f2f8fd8;hb=0d6b320def9180cf907ceaed56b23a972a11b757;hp=bf0feef95785248736844599af396396086a9e44;hpb=2d04c4f22466851aedb6ed0f2919d148f726b889;p=xscreensaver diff --git a/driver/xscreensaver-getimage.c b/driver/xscreensaver-getimage.c index bf0feef9..24c0246e 100644 --- a/driver/xscreensaver-getimage.c +++ b/driver/xscreensaver-getimage.c @@ -136,6 +136,7 @@ ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error) return 0; } +#ifndef USE_EXTERNAL_SCREEN_GRABBER static int ignore_badmatch_ehandler (Display *dpy, XErrorEvent *error) { @@ -144,6 +145,7 @@ ignore_badmatch_ehandler (Display *dpy, XErrorEvent *error) else return x_ehandler (dpy, error); } +#endif /* ! USE_EXTERNAL_SCREEN_GRABBER */ /* Returns True if the given Drawable is a Window; False if it's a Pixmap. @@ -295,6 +297,7 @@ compute_image_scaling (int src_w, int src_h, If out of memory, returns False, and the XImage will have been destroyed and freed. */ +#ifndef USE_EXTERNAL_SCREEN_GRABBER static Bool scale_ximage (Screen *screen, Visual *visual, XImage *ximage, int new_width, int new_height) @@ -342,6 +345,7 @@ scale_ximage (Screen *screen, Visual *visual, return True; } +#endif /* ! USE_EXTERNAL_SCREEN_GRABBER */ #ifdef HAVE_GDK_PIXBUF @@ -1197,7 +1201,8 @@ get_filename_1 (Screen *screen, const char *directory, grab_type type, close (out); /* don't need this one */ *buf = 0; - fgets (buf, sizeof(buf)-1, f); + if (! fgets (buf, sizeof(buf)-1, f)) + *buf = 0; fclose (f); /* Wait for the child to die. */ @@ -1451,7 +1456,6 @@ get_image (Screen *screen, { Display *dpy = DisplayOfScreen (screen); grab_type which = GRAB_BARS; - int count = 0; struct stat st; const char *file_prop = 0; XRectangle geom = { 0, 0, 0, 0 }; @@ -1546,24 +1550,28 @@ get_image (Screen *screen, } # endif /* !USE_EXTERNAL_SCREEN_GRABBER */ - count = 0; - if (desk_p) count++; - if (video_p) count++; - if (image_p) count++; - - if (count == 0) + if (! (desk_p || video_p || image_p)) which = GRAB_BARS; else { int i = 0; - while (1) /* loop until we get one that's permitted */ - { - which = (random() % 3); - if (which == GRAB_DESK && desk_p) break; - if (which == GRAB_VIDEO && video_p) break; - if (which == GRAB_FILE && image_p) break; - if (++i > 200) abort(); - } + int n; + /* Loop until we get one that's permitted. + If files or video are permitted, do them more often + than desktop. + + D+V+I: 10% + 45% + 45%. + V+I: 50% + 50% + D+V: 18% + 82% + D+I: 18% + 82% + */ + AGAIN: + n = (random() % 100); + if (++i > 300) abort(); + else if (desk_p && n < 10) which = GRAB_DESK; /* 10% */ + else if (video_p && n < 55) which = GRAB_VIDEO; /* 45% */ + else if (image_p) which = GRAB_FILE; /* 45% */ + else goto AGAIN; }