+
+
+static unsigned long
+sonar_draw (Display *dpy, Window window, void *closure)
+{
+ sonar_info *si = (sonar_info *) closure;
+ Bogie *bl;
+ struct timeval start, finish;
+ long delay;
+
+# ifdef HAVE_COCOA /* repaint the whole window so that antialiasing works */
+ XClearWindow (dpy,window);
+ XFillRectangle (dpy, window, si->erase, 0, 0, si->width, si->height);
+# endif
+
+ /* Call the sensor and display the results */
+
+# ifdef GETTIMEOFDAY_TWO_ARGS
+ gettimeofday(&start, (struct timezone *) 0);
+# else
+ gettimeofday(&start);
+# endif
+ bl = si->sensor(si, si->sensor_info);
+ Sonar(si, bl);
+
+ /* Set up and sleep for the next one */
+
+ si->current = (si->current - 1) % 90;
+ if (si->current == 0)
+ si->sweepnum++;
+
+# ifdef GETTIMEOFDAY_TWO_ARGS
+ gettimeofday(&finish, (struct timezone *) 0);
+# else
+ gettimeofday(&finish);
+# endif
+
+ delay = si->delay - delta(&start, &finish);
+ if (delay < 0) delay = 0;
+ return delay;
+}
+
+
+static void
+sonar_reshape (Display *dpy, Window window, void *closure,
+ unsigned int w, unsigned int h)
+{
+ sonar_info *si = (sonar_info *) closure;
+ XClearWindow (si->dpy, si->win);
+ reshape (si);
+}
+
+static Bool
+sonar_event (Display *dpy, Window window, void *closure, XEvent *event)
+{
+ return False;
+}
+
+static void
+sonar_free (Display *dpy, Window window, void *closure)
+{
+}
+
+
+
+static const char *sonar_defaults [] = {
+ ".background: #000000",
+ ".sweepColor: #00FF00",
+ "*delay: 100000",
+ "*scopeColor: #003300",
+ "*gridColor: #00AA00",
+ "*textColor: #FFFF00",
+ "*ttl: 90",
+ "*mode: default",
+ "*font: fixed",
+ "*sweepDegrees: 30",
+
+ "*textSteps: 80", /* npixels */
+ "*sweepSegments: 80", /* npixels */
+
+ "*pingTimeout: 3000",
+
+ "*teamAName: F18",
+ "*teamBName: MIG",
+ "*teamACount: 4",
+ "*teamBCount: 4",
+
+ "*ping: default",
+ "*resolve: true",
+ "*showTimes: true",
+ ".debug: false",
+ 0
+};
+
+static XrmOptionDescRec sonar_options [] = {
+ {"-background", ".background", XrmoptionSepArg, 0 },
+ {"-sweep-color", ".sweepColor", XrmoptionSepArg, 0 },
+ {"-scope-color", ".scopeColor", XrmoptionSepArg, 0 },
+ {"-grid-color", ".gridColor", XrmoptionSepArg, 0 },
+ {"-text-color", ".textColor", XrmoptionSepArg, 0 },
+ {"-ttl", ".ttl", XrmoptionSepArg, 0 },
+ {"-font", ".font", XrmoptionSepArg, 0 },
+#ifdef HAVE_PING
+ {"-ping-timeout", ".pingTimeout", XrmoptionSepArg, 0 },
+#endif /* HAVE_PING */
+ {"-team-a-name", ".teamAName", XrmoptionSepArg, 0 },
+ {"-team-b-name", ".teamBName", XrmoptionSepArg, 0 },
+ {"-team-a-count", ".teamACount", XrmoptionSepArg, 0 },
+ {"-team-b-count", ".teamBCount", XrmoptionSepArg, 0 },
+
+ {"-ping", ".ping", XrmoptionSepArg, 0 },
+ {"-no-dns", ".resolve", XrmoptionNoArg, "False" },
+ {"-no-times", ".showTimes", XrmoptionNoArg, "False" },
+ {"-debug", ".debug", XrmoptionNoArg, "True" },
+ { 0, 0, 0, 0 }
+};
+
+
+XSCREENSAVER_MODULE ("Sonar", sonar)