X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fxjack.c;h=6279000dcef5424a61a48e304a198305d932492d;hb=93f25dc6827112d98b8b855ea85c8f5eb8123086;hp=6bc76ff27c43af1bbd9df24fe39c39ecac4acc3b;hpb=c6b273ef7292ba10943694df1656b05203d7b62f;p=xscreensaver diff --git a/hacks/xjack.c b/hacks/xjack.c index 6bc76ff2..6279000d 100644 --- a/hacks/xjack.c +++ b/hacks/xjack.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1997 Jamie Zawinski +/* xscreensaver, Copyright (c) 1997 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 @@ -23,8 +23,8 @@ char *progclass = "XJack"; char *defaults [] = { - "*background: black", - "*foreground: #00EE00", + ".background: #FFF0B4", + ".foreground: #000000", "XJack.font: -*-courier-medium-r-*-*-*-240-*-*-m-*-*-*", "*delay: 50000", 0 @@ -40,6 +40,8 @@ void screenhack (Display *dpy, Window window) { static const char *source = "All work and no play makes Jack a dull boy. "; + /* If you're here because you're thinking about making the above string be + customizable, then you don't get the joke. You loser. */ const char *s = source; int columns, rows; /* characters */ int left, right; /* characters */ @@ -154,25 +156,38 @@ screenhack (Display *dpy, Window window) while (lines > 0) { - XCopyArea (dpy, window, window, gc, - 0, hspace + line_height, - xgwa.width, - xgwa.height - vspace - vspace - line_height, - 0, vspace); - XClearArea (dpy, window, - 0, xgwa.height - vspace - line_height, - xgwa.width, - line_height + vspace + vspace, - False); - XClearArea (dpy, window, 0, 0, xgwa.width, vspace, False); - /* See? It's OK. He saw it on the television. */ - XClearArea (dpy, window, 0, 0, hspace, xgwa.height, False); - XClearArea (dpy, window, xgwa.width - vspace, 0, - hspace, xgwa.height, False); + int i; + int inc = line_height / 7; + int pix_delay = delay / 1000; + if (inc <= 0) inc = 1; + for (i = 0; i < line_height; i += inc) + { + if (i > line_height) + i = line_height; + XCopyArea (dpy, window, window, gc, + 0, inc, + xgwa.width, xgwa.height - inc, + 0, 0); + XSync (dpy, False); + if (pix_delay) usleep (pix_delay); + } y--; lines--; - XSync (dpy, True); - if (delay) usleep (delay * 10); + + /* See? It's OK. He saw it on the television. */ + XClearArea (dpy, window, + 0, xgwa.height - vspace - line_height, + xgwa.width, line_height + vspace + vspace, + False); + XSync (dpy, False); + + XGetWindowAttributes (dpy, window, &xgwa); + columns = (xgwa.width - hspace - hspace) / char_width; + rows = (xgwa.height - vspace - vspace) / line_height; + if (y > rows) y = rows-1; + if (x > columns) x = columns-2; + + if (delay) usleep (delay); } if (y < 0) y = 0; } @@ -207,7 +222,7 @@ screenhack (Display *dpy, Window window) while (typo[i] && typo[i][0] != c) i++; if (typo[i]) - c = typo[i][0xFF & (random() % strlen(typo[i]+1))]; + c = typo[i][0xFF & ((random() % strlen(typo[i]+1)) + 1)]; } /* caps typo */ @@ -238,7 +253,7 @@ screenhack (Display *dpy, Window window) { x--; s--; - XSync (dpy, True); + XSync (dpy, False); if (delay) usleep (0xFFFF & (delay + (random() % (delay * 10)))); } } @@ -306,7 +321,7 @@ screenhack (Display *dpy, Window window) s = source; } - XSync (dpy, True); + XSync (dpy, False); if (delay) { usleep (delay); @@ -340,7 +355,7 @@ screenhack (Display *dpy, Window window) if (x >= columns) x = 0, y++; n1++; } - XSync (dpy, True); + XSync (dpy, False); usleep (5000000); while (*n2) { @@ -353,9 +368,10 @@ screenhack (Display *dpy, Window window) n2++; } y++; - XSync (dpy, True); + XSync (dpy, False); usleep (500000); } } + screenhack_handle_events (dpy); } }