From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[xscreensaver] / hacks / xjack.c
index ac037357e065ababec598c53c2643dd279d7622b..1765243cba111240466aa8045a2f238c39a49c66 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1997, 2006 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1997-2012 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -62,12 +62,18 @@ xjack_reshape (Display *dpy, Window window, void *closure,
   st->rows--;
   st->columns--;
 
+  /* If the window is stupidly small, just truncate. */
+  if (st->rows < 4)     st->rows = 4;
+  if (st->columns < 12) st->columns = 12;
+
   if (st->y > st->rows)    st->y = st->rows-1;
   if (st->x > st->columns) st->x = st->columns-2;
 
   if (st->right > st->columns) st->right = st->columns;
   if (st->left > st->columns-20) st->left = st->columns-20;
   if (st->left < 0) st->left = 0;
+
+  XClearWindow (st->dpy, st->window);
 }
 
 
@@ -83,6 +89,12 @@ xjack_init (Display *dpy, Window window)
   st->s = source;
   st->delay = get_integer_resource (st->dpy, "delay", "Integer");
   fontname = get_string_resource (st->dpy, "font", "Font");
+
+  XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
+
+  if (st->xgwa.width <= 480)
+    fontname = "-*-courier-medium-r-*-*-*-180-*-*-m-*-*-*";
+
   st->font = XLoadQueryFont (st->dpy, fontname);
 
   if (!st->font)
@@ -98,8 +110,6 @@ xjack_init (Display *dpy, Window window)
       exit(1);
     }
 
-  XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
-
   gcv.font = st->font->fid;
   gcv.foreground = get_pixel_resource (st->dpy, st->xgwa.colormap,
                                        "foreground", "Foreground");
@@ -116,9 +126,12 @@ xjack_init (Display *dpy, Window window)
 
   xjack_reshape (dpy, window, st, st->xgwa.width, st->xgwa.height);
 
-  st->left = 0xFF & (random() % ((st->columns / 2)+1));
-  st->right = st->left + (0xFF & (random() % (st->columns - st->left - 10)
-                                  + 10));
+  if (st->columns >= 21)
+    {
+      st->left = 0xFF & (random() % ((st->columns / 2)+1));
+      st->right = st->left + (0xFF & (random() % (st->columns - st->left - 10)
+                                      + 10));
+    }
   st->x = 0;
   st->y = 0;
 
@@ -452,6 +465,7 @@ xjack_free (Display *dpy, Window window, void *closure)
 static const char *xjack_defaults [] = {
   ".background:                #FFF0B4",
   ".foreground:                #000000",
+  "*fpsSolid:          true",
 #ifdef HAVE_COCOA
   ".font:              American Typewriter 24",
 #else