+ /* --- Calculate and produce the necessary output --- *
+ *
+ * If we're meant to report on individual screens then try to collect
+ * information about them using the RANDR extension. If that doesn't
+ * exist, or the version is too ancient, or its otherwise not going to
+ * work, then pretend there's just one screen that's the size of the root
+ * window.
+ */
+
+ if (f & f_multi) {
+#ifdef HAVE_XRANDR
+ if (XRRQueryExtension(dpy, &rrev, &rrerr) &&
+ XRRQueryVersion(dpy, &rrmaj, &rrmin) &&
+ (rrmaj > 1 || (rrmaj == 1 && rrmin >= 2))) {
+ root = RootWindow(dpy, sc);
+ res = XRRGetScreenResources(dpy, root);
+ scr = xmalloc(res->ncrtc*sizeof(*scr)); j = 0;
+ for (i = 0; i < res->ncrtc; i++) {
+ crtc = XRRGetCrtcInfo(dpy, res, res->crtcs[i]);
+ if (crtc->mode) {
+ scr[j].x = crtc->x; scr[j].wd = crtc->width;
+ scr[j].y = crtc->y; scr[j].ht = crtc->height;
+ j++;
+ }
+ XRRFreeCrtcInfo(crtc);
+ }
+ nscr = j;
+ XRRFreeScreenResources(res);
+ } else
+#endif
+ {
+ /* --- The RANDR extension isn't available --- */