+ XGCValues gcv;
+
+ /* make it square */
+ st->size = (st->width < st->height) ? st->height : st->width;
+ st->size = to_pow2(st, st->size, st->scale_up); /* round up to power of 2 */
+ { /* don't exceed screen size */
+ int s = XScreenNumberOfScreen(st->xgwa.screen);
+ int w = to_pow2(st, XDisplayWidth(st->dpy, s), False);
+ int h = to_pow2(st, XDisplayHeight(st->dpy, s), False);
+ if (st->size > w) st->size = w;
+ if (st->size > h) st->size = h;
+ }
+
+ st->self = XCreatePixmap (st->dpy, st->window, st->size, st->size, st->xgwa.depth);
+ st->temp = XCreatePixmap (st->dpy, st->window, st->size, st->size, st->xgwa.depth);
+ st->mask = XCreatePixmap (st->dpy, st->window, st->size, st->size, st->xgwa.depth);
+ gcv.foreground = (st->xgwa.depth == 1 ? 1 : (~0));
+ gcv.function=GXset; st->SET = XCreateGC(st->dpy,st->self,GCFunction|GCForeground,&gcv);
+ gcv.function=GXclear;st->CLR = XCreateGC(st->dpy,st->self,GCFunction|GCForeground,&gcv);
+ gcv.function=GXcopy; st->CPY = XCreateGC(st->dpy,st->self,GCFunction|GCForeground,&gcv);
+ gcv.function=GXor; st->IOR = XCreateGC(st->dpy,st->self,GCFunction|GCForeground,&gcv);
+ gcv.function=GXand; st->AND = XCreateGC(st->dpy,st->self,GCFunction|GCForeground,&gcv);
+ gcv.function=GXxor; st->XOR = XCreateGC(st->dpy,st->self,GCFunction|GCForeground,&gcv);
+
+ gcv.foreground = gcv.background = st->bg;
+ st->gc = XCreateGC (st->dpy, st->window, GCForeground|GCBackground, &gcv);
+ /* Clear st->self to the background color (not to 0, which st->CLR does.) */
+ XFillRectangle (st->dpy, st->self, st->gc, 0, 0, st->size, st->size);
+ XSetForeground (st->dpy, st->gc, st->fg);
+
+#if 0
+#ifdef HAVE_COCOA
+ jwxyz_XSetAntiAliasing (st->dpy, st->gc, False);
+ jwxyz_XSetAntiAliasing (st->dpy, st->SET, False);
+ jwxyz_XSetAntiAliasing (st->dpy, st->CLR, False);
+ jwxyz_XSetAntiAliasing (st->dpy, st->CPY, False);
+ jwxyz_XSetAntiAliasing (st->dpy, st->IOR, False);
+ jwxyz_XSetAntiAliasing (st->dpy, st->AND, False);
+ jwxyz_XSetAntiAliasing (st->dpy, st->XOR, False);
+#endif /* HAVE_COCOA */
+#endif
+
+ XCopyArea (st->dpy, st->bitmap, st->self, st->CPY, 0, 0,
+ st->width, st->height,
+ (st->size - st->width) >> 1,
+ (st->size - st->height) >> 1);
+/* XFreePixmap(st->dpy, st->bitmap);*/
+
+ st->qwad = -1;
+ st->first_time = 1;
+}
+
+static void
+display (struct state *st, Pixmap pixmap)
+{
+ XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
+
+ if (st->xgwa.width != st->last_w ||
+ st->xgwa.height != st->last_h)