http://ftp.ksu.edu.tw/FTP/FreeBSD/distfiles/xscreensaver-4.20.tar.gz
[xscreensaver] / hacks / xanalogtv.c
index 605acac6b32734d5071cf6dd4f24b9da9a1a6580..9d65586f1cf084819e4913dd7c56d8fa90a77efa 100644 (file)
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <time.h>
 #include <sys/time.h>
+#include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Intrinsic.h>
 
@@ -194,6 +195,8 @@ draw_color_square(analogtv_input *input)
 char *progclass = "XAnalogTV";
 
 char *defaults [] = {
+  ".background:             black",
+  ".foreground:             white",
   "*delay:          5",
   ANALOGTV_DEFAULTS
   0,
@@ -241,6 +244,37 @@ getticks(void)
           (tv.tv_usec - basetime.tv_usec)/1000);
 }
 
+
+/* The first time we grab an image, do it the default way.
+   The second and subsequent times, add "-no-desktop" to the command.
+   That way we don't have to watch the window un-map 5+ times in a row.
+   Also, we end up with the desktop on only one channel, and pictures
+   on all the others (or colorbars, if no imageDirectory is set.)
+ */
+static void
+hack_resources (void)
+{
+  static int count = -1;
+  count++;
+
+  if (count == 0)
+    return;
+  else if (count == 1)
+    {
+      char *res = "desktopGrabber";
+      char *val = get_string_resource (res, "DesktopGrabber");
+      char buf1[255];
+      char buf2[255];
+      XrmValue value;
+      sprintf (buf1, "%.100s.%.100s", progclass, res);
+      sprintf (buf2, "%.200s -no-desktop", val);
+      value.addr = buf2;
+      value.size = strlen(buf2);
+      XrmPutResource (&db, buf1, "String", &value);
+    }
+}
+
+
 int
 analogtv_load_random_image(analogtv *it, analogtv_input *input)
 {
@@ -252,7 +286,8 @@ analogtv_load_random_image(analogtv *it, analogtv_input *input)
 
   pixmap=XCreatePixmap(it->dpy, it->window, width, height, it->visdepth);
   XSync(it->dpy, False);
-  load_random_image(it->screen, it->window, pixmap, NULL);
+  hack_resources();
+  load_random_image(it->screen, it->window, pixmap, NULL, NULL);
   image = XGetImage(it->dpy, pixmap, 0, 0, width, height, ~0L, ZPixmap);
   XFreePixmap(it->dpy, pixmap);
 
@@ -318,6 +353,7 @@ void add_stations(void)
   }
 }
 
+
 void
 screenhack (Display *dpy, Window window)
 {