code: function drawWithKids(list, cb)
          {
              if (list.length == 0)
                  return cb();
              var p = list.pop();
              var win = p.win;
              if (win == dispwin)
                  return drawWithKids(list, cb);
  
              X.GetWindowAttributes(win, function(err, res) {
                  if (res[8] == 0)
                      return drawWithKids(list, cb);
                  X.GetGeometry(win, function(err, geom) {
                      // (srcDrawable, dstDrawable, gc, srcX, srcY, dstX, dstY, width, height)
                      if (win != root)
                          X.CopyArea(win, dispwin, gc, 0, 0, p.x + geom.xPos, p.y + geom.yPos, geom.width, geom.height);
                      //X.CopyArea(win, idScreenshot, gc, 0, 0, p.x + geom.xPos, p.y + geom.yPos, geom.width, geom.height);
                      X.QueryTree(win, function(tree) {
                          tree.children.reverse().forEach(function(subwin) {
                              list.push({win: subwin, x: p.x + geom.xPos, y: p.y + geom.yPos});
                          });
                          drawWithKids(list, cb);
                      });
                  });
              });
          }
docs: var idScreenshot = X.AllocID(); X.CreatePixmap(idScreenshot, root, 24, clientGeom.width, clientGeom.height); ask recursively each window to copy itself to pixmap