X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Ferase.c;h=ce48db11a434f8ee6d6dba624a4e60327e3799d2;hb=39809ded547bdbb08207d3e514950425215b4410;hp=feefd69d7d2db06355536ff9ced2fea7680e3d1c;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/utils/erase.c b/utils/erase.c index feefd69d..ce48db11 100644 --- a/utils/erase.c +++ b/utils/erase.c @@ -1,5 +1,5 @@ /* erase.c: Erase the screen in various more or less interesting ways. - * Copyright (c) 1997-2001, 2006 Jamie Zawinski + * Copyright (c) 1997-2008 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 @@ -451,7 +451,7 @@ random_squares (eraser_state *st) { st->cols = 10 + random() % 30; size = st->width / st->cols; - rows = (st->height / size) + 1; + rows = (size ? (st->height / size) : 0) + 1; st->nlines = st->cols * rows; st->lines = (int *) calloc (st->nlines, sizeof(*st->lines)); @@ -469,7 +469,7 @@ random_squares (eraser_state *st) } size = st->width / st->cols; - rows = (st->height / size) + 1; + rows = (size ? (st->height / size) : 0) + 1; for (i = st->nlines * st->prev_ratio; i < st->nlines * st->ratio; @@ -513,7 +513,9 @@ slide_lines (eraser_state *st) for (y = 0; y < st->height; y += h) { - if (tick & 1) + if (st->width <= step) + ; + else if (tick & 1) { XCopyArea (st->dpy, st->window, st->window, st->fg_gc, 0, y, st->width-step, h, step, y); @@ -572,12 +574,7 @@ losira (eraser_state *st) else if (st->ratio < mode2) /* squeeze from the top/bottom */ { double ratio = (st->ratio - mode1) / (mode2 - mode1); - double prev_ratio = (st->prev_ratio - mode1) / (mode2 - mode1); int max = st->height / 2; - int step = (max * ratio) - (max * prev_ratio); - - if (step <= 0) - step = 1; /* fill middle */ XFillRectangle (st->dpy, st->window, st->fg_gc, @@ -734,7 +731,7 @@ eraser_draw (eraser_state *st, Bool first_p) return (st->ratio < 1.0); } -static void +void eraser_free (eraser_state *st) { XClearWindow (st->dpy, st->window);