X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fxjack.c;h=623103c0e3f5c8e47dd3eb3f74279a8058c7ae71;hb=06e9a7886a77cad92f9ddbc169d6d199a4d8b76d;hp=5711be45d8c123d7863d3d158677c6801598b1cb;hpb=0bd2eabab3e404c6769fe8f59b639275e960c415;p=xscreensaver diff --git a/hacks/xjack.c b/hacks/xjack.c index 5711be45..623103c0 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; } @@ -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); } }