--- /dev/null
+/* gcc -o pager pager.c -lX11 -lXmu -ldockapp */
+#if 0
+#include <X11/extensions/Xrender.h>
+#endif
+#include <dockapp.h>
+
+static GC lightGrayGC, darkGrayGC, windowGC[4];
+
+void setup_GCs() {
+ XGCValues gcv;
+
+ /* GC's */
+ gcv.foreground = DAGetColor("darkGray");
+ XChangeGC(DADisplay, DAClearGC, GCForeground, &gcv);
+
+ gcv.foreground = DAGetColor("lightGray");
+ gcv.graphics_exposures = False;
+
+ lightGrayGC = XCreateGC(DADisplay, DAWindow, GCForeground|GCGraphicsExposures, &gcv);
+
+ gcv.foreground = DAGetColor("#222222");
+ darkGrayGC = XCreateGC(DADisplay, DAWindow, GCForeground|GCGraphicsExposures, &gcv);
+
+ gcv.foreground = DAGetColor("#333333");
+ windowGC[0] = XCreateGC(DADisplay, DAWindow, GCForeground|GCGraphicsExposures, &gcv);
+ gcv.foreground = DAGetColor("#777777");
+ windowGC[1] = XCreateGC(DADisplay, DAWindow, GCForeground|GCGraphicsExposures, &gcv);
+ gcv.foreground = DAGetColor("#bbbbbb");
+ windowGC[2] = XCreateGC(DADisplay, DAWindow, GCForeground|GCGraphicsExposures, &gcv);
+ gcv.foreground = DAGetColor("#ffffff");
+ windowGC[3] = XCreateGC(DADisplay, DAWindow, GCForeground|GCGraphicsExposures, &gcv);
+}
+
+void draw_relief(Pixmap pixmap, unsigned int width, unsigned int height) {
+ /* Drawing */
+ XFillRectangle(DADisplay, pixmap, DAClearGC, 0, 0, width, height);
+
+ XDrawLine(DADisplay, pixmap, darkGrayGC, 0, 0, 0, height - 2);
+ XDrawLine(DADisplay, pixmap, darkGrayGC, 1, 0, width - 1, 0);
+
+ XDrawLine(DADisplay, pixmap, lightGrayGC, 0, height - 1, width - 1, height - 1);
+ XDrawLine(DADisplay, pixmap, lightGrayGC, width - 1, 1, width - 1, height - 2);
+}
+
+void page() {
+ Window dockapp, root, qroot, qparent, *wins;
+ XWindowAttributes attr;
+ Pixmap pixmap;
+ DARect rect;
+ unsigned int i, nwins;
+ unsigned int root_width, root_height;
+ unsigned int dockapp_width, dockapp_height;
+ double scale;
+
+ root = DefaultRootWindow(DADisplay);
+ root_width = DisplayWidth(DADisplay, DefaultScreen(DADisplay));
+ root_height = DisplayWidth(DADisplay, DefaultScreen(DADisplay));
+
+ XGetWindowAttributes(DADisplay, DAGetWindow(), &attr);
+ dockapp_width = attr.width;
+ dockapp_height = attr.height;
+ scale = (double) root_width / (double) dockapp_width;
+
+ pixmap = DAMakePixmap();
+ draw_relief(pixmap, dockapp_width, dockapp_height);
+
+ Picture picture = XRenderCreatePicture(DADisplay, pixmap, XRenderFindVisualFormat(DADisplay, DefaultVisual(DADisplay, DefaultScreen(DADisplay))), 0, 0);
+ XQueryTree(DADisplay, root, &qroot, &qparent, &wins, &nwins);
+ for (i = 0; i < nwins; i++) {
+ Window root;
+
+ Window client = XmuClientWindow(DADisplay, wins[i]);
+ XGetWindowAttributes(DADisplay, client, &attr);
+ unsigned int x, y, width, height, border, depth;
+ if (attr.override_redirect) continue;
+ if (attr.map_state != IsViewable) continue;
+
+ if (! XGetGeometry(DADisplay, wins[i], &root, &x, &y, &width, &height, &border, &depth)) continue;
+ rect.x = (double) x / scale;
+ rect.y = (double) y / scale;
+ rect.width = (double) width / scale;
+ rect.height = (double) height / scale;
+
+ XFillRectangle(DADisplay, pixmap, windowGC[(int) wins[i] % 4], rect.x, rect.y, rect.width, rect.height);
+
+ /* Thumbnail. */
+#if 0
+ XRenderPictureAttributes pa;
+ Pixmap client_pixmap = XCreatePixmap(DADisplay, wins[i], width, height, DefaultDepth(DADisplay, DefaultScreen(DADisplay)));
+ //XCopyArea(DADisplay, wins[i], client_pixmap, DefaultGC(DADisplay, DefaultScreen(DADisplay)), 0, 0, width, height, 0, 0);
+ Picture client_picture = XRenderCreatePicture(DADisplay, client_pixmap, XRenderFindVisualFormat(DADisplay, attr.visual), CPSubwindowMode, &pa);
+
+ XTransform xform = {{
+ { XDoubleToFixed(1.0), 0, 0 },
+ { 0, XDoubleToFixed(1.0), 0 },
+ { 0, 0, XDoubleToFixed(scale) },
+ }};
+
+ XRenderSetPictureFilter(DADisplay, client_picture, FilterBilinear, 0, 0);
+ XRenderSetPictureTransform(DADisplay, client_picture, &xform);
+ XRenderComposite(DADisplay, PictOpSrc, client_picture, None, picture, 0, 0, 0, 0, rect.x, rect.y, rect.width, rect.height);
+ XFreePixmap(DADisplay, client_pixmap);
+ XSync(DADisplay, False);
+#endif
+
+ XDrawLine(DADisplay, pixmap, darkGrayGC, rect.x, rect.y, rect.x, rect.y + rect.height - 2);
+ XDrawLine(DADisplay, pixmap, darkGrayGC, rect.x + 1, rect.y, rect.x + rect.width - 1, rect.y);
+ XDrawLine(DADisplay, pixmap, lightGrayGC, rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1);
+ XDrawLine(DADisplay, pixmap, lightGrayGC, rect.x + rect.width - 1, rect.y + 1, rect.x + rect.width - 1, rect.y + rect.height - 2);
+ }
+
+ DASetPixmap(pixmap);
+ XFreePixmap(DADisplay, pixmap);
+}
+
+#define DOCKAPP_SIZE 56
+#define SPEED 100
+
+int main(int argc, char **argv) {
+ Display *display;
+ unsigned int root_width, root_height;
+ unsigned int dockapp_width, dockapp_height;
+ double aspect;
+ DACallbacks callbacks = { 0, 0, 0, 0, 0, 0, page };
+
+ DASetExpectedVersion(20020126);
+
+ display = XOpenDisplay(0);
+
+ root_width = DisplayWidth(display, DefaultScreen(display));
+ root_height = DisplayHeight(display, DefaultScreen(display));
+ aspect = (double) root_width / (double) root_height;
+
+ if (root_width > root_height) {
+ dockapp_width = DOCKAPP_SIZE;
+ dockapp_height = (double) DOCKAPP_SIZE / aspect;
+ }
+ else {
+ dockapp_height = DOCKAPP_SIZE;
+ dockapp_width = (double) DOCKAPP_SIZE / aspect;
+ }
+
+ DAParseArguments(argc, argv, 0, 0, "BLURB", "BLORB");
+ DAOpenDisplay(0, argc, argv);
+ DACreateIcon("pager", dockapp_width, dockapp_height, argc, argv);
+
+ DASetCallbacks(&callbacks);
+ DASetTimeout(SPEED);
+
+ setup_GCs();
+ DAShow();
+ DAEventLoop();
+}