+/*
+ * Creates and returns a drawing mask for the scope:
+ * mask out anything outside of the disc.
+ */
+static Pixmap
+scope_mask (Display *dpy, Window win, sonar_info *si)
+{
+ XGCValues gcv;
+ Pixmap mask = XCreatePixmap(dpy, win, si->width, si->height, 1);
+ GC gc = XCreateGC (dpy, mask, 0, &gcv);
+ XSetFunction (dpy, gc, GXclear);
+ XFillRectangle (dpy, mask, gc, 0, 0, si->width, si->height);
+ XSetFunction (dpy, gc, GXset);
+ XFillArc(dpy, mask, gc, si->minx, si->miny,
+ si->maxx - si->minx, si->maxy - si->miny,
+ 0, 360 * 64);
+ return mask;
+}
+
+
+static void
+reshape (sonar_info *si)
+{
+ XWindowAttributes xgwa;
+ Pixmap mask;
+ XGetWindowAttributes(si->dpy, si->win, &xgwa);
+ si->width = xgwa.width;
+ si->height = xgwa.height;
+ si->centrex = si->width / 2;
+ si->centrey = si->height / 2;
+ si->maxx = si->centrex + MY_MIN(si->centrex, si->centrey) - 10;
+ si->minx = si->centrex - MY_MIN(si->centrex, si->centrey) + 10;
+ si->maxy = si->centrey + MY_MIN(si->centrex, si->centrey) - 10;
+ si->miny = si->centrey - MY_MIN(si->centrex, si->centrey) + 10;
+ si->radius = si->maxx - si->centrex;
+
+ /* Install the clip mask... */
+ mask = scope_mask (si->dpy, si->win, si);
+ XSetClipMask(si->dpy, si->text, mask);
+ XSetClipMask(si->dpy, si->erase, mask);
+ XFreePixmap (si->dpy, mask); /* it's been copied into the GCs */
+}
+