X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fbarcode.c;h=271aad9948283fbf212d26b80356a6ee537507eb;hb=39809ded547bdbb08207d3e514950425215b4410;hp=61b0c237b76ceecd38452d84eaa3949857ff2473;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/barcode.c b/hacks/barcode.c index 61b0c237..271aad99 100644 --- a/hacks/barcode.c +++ b/hacks/barcode.c @@ -14,6 +14,7 @@ */ #include +#include #include "screenhack.h" /* non-user-modifiable immutable definitions */ @@ -824,7 +825,7 @@ static void drawDigitChar (struct state *st, Bitmap *b, int x, int y, char c) if ((c < '0') || (c > '9')) c = '0'; - bitmapDrawChar5x8 (b, x, y, c); + bitmapDrawChar5x8 (b, x, y, c); } /* draw a upc/ean digit at the given coordinates */ @@ -1634,6 +1635,12 @@ static void scrollModel (struct state *st) st->barcodes[st->barcode_count - 1].mag * BARCODE_WIDTH); barcode->x += RAND_FLOAT_01 * 100; barcode->mag = RAND_FLOAT_01 * MAX_MAG; + + if (st->windowWidth < 100 || st->windowHeight < 100) { + barcode->mag *= 0.5; + if (barcode->mag <= 0) barcode->mag = 1; + } + barcode->y = RAND_FLOAT_01 * (st->windowHeight - BARCODE_HEIGHT * barcode->mag); if (barcode->y < 0) @@ -1728,7 +1735,7 @@ static void updateGrid (struct state *st) s[j] = (random() % 10) + '0'; s[j++] = '?'; s[j++] = ':'; - s[j++] = 0; + s[j] = 0; } /* change one digit in this barcode */ @@ -1898,6 +1905,9 @@ static void barcode_reshape (Display *dpy, Window window, void *closure, unsigned int w, unsigned int h) { + struct state *st = (struct state *) closure; + st->windowWidth = w; + st->windowHeight = h; } static void