title: Setting X11 root window pixmap
body: <p>The code below is supposed to make root window white, but does nothing. Compiles and runs with no errors. I omitted only includes and variable definitions.</p>
  <pre><code>int
  main(int argc, char **argv) {
      dpy = XOpenDisplay(NULL);
      if (!dpy) {
          fputs(&quot;cannot open display\n&quot;, stderr);
          return EXIT_FAILURE;
      }
      screen = DefaultScreen(dpy);
      root   = RootWindow(dpy, screen);
      vis    = DefaultVisual(dpy, screen);
      depth  = DefaultDepth(dpy, screen);
      height = DisplayHeight(dpy, screen);
      width  = DisplayWidth(dpy, screen);
      img = malloc(depth/8 * height * width);
      if (img == NULL) {
          perror(&quot;malloc() failed&quot;);
          return EXIT_FAILURE;
      }
      memset(img, 0xFF, depth/8 * height * width);
      ximg = XCreateImage(dpy, vis, depth, ZPixmap, 0, img, width, height, 32, 0);
      pm = XCreatePixmap(dpy, root, width, height, depth);
      gc = XCreateGC(dpy, pm, 0, NULL);
      XPutImage(dpy, pm, gc, ximg, 0, 0, 0, 0, width, height);
      XSetWindowBackgroundPixmap(dpy, root, pm);
      XClearWindow(dpy, root);
      XFlush(dpy);
      XDestroyImage(ximg);
      XFreePixmap(dpy, pm);
      XFreeGC(dpy, gc);
      XCloseDisplay(dpy);
      return EXIT_SUCCESS;
  }
  </code></pre>
  <p>How do I even start troubleshooting this? removing <code>XClearWindow(dpy, root);</code> does not help.</p>