title: Weird ass XLib bug; XDrawString only works after a sleep
body: <p>So I have the following code, notsure if I have added too much/little but its there for conext anyway.</p>
  
  <pre><code>Window root = XCreateWindow(proc-&gt;display,    
                             RootWindow(proc-&gt;display, screen),
                             0, 0, width + 500, height + 500, 0, 
                             CopyFromParent, InputOutput,
                             CopyFromParent, CWEventMask, &amp;attr);
  
  XSetWindowBackground(proc-&gt;display, root, WhitePixel(proc-&gt;display, screen));
  
  XFlush(proc-&gt;display);
  XMapWindow(proc-&gt;display, root);
  
  Window avaliableDevices = XCreateSimpleWindow(proc-&gt;display, root, 10, 50,
              220, 650, 5, BlackPixel(proc-&gt;display, screen), 
              WhitePixel(proc-&gt;display, screen));
  
  XFlush(proc-&gt;display);
  XMapWindow(proc-&gt;display, avaliableDevices);
  
  sleep(1);
  XDrawString(proc-&gt;display, root, DefaultGC(proc-&gt;display, DefaultScreen(proc-&gt;display))
      , 20, 20, "hello", strlen("hello"));
  
  Window networkedDevices = XCreateSimpleWindow(proc-&gt;display, root, /* display, parent */
              900, 50, /* x, y: the window manager will place the window elsewhere */
              220, 650, /* width, height */
              5, BlackPixel(proc-&gt;display, screen), /* border width &amp; colour, unless you have a window manager */
              WhitePixel(proc-&gt;display, screen)); /* background colour */
  
  XDrawString(proc-&gt;display, root, DefaultGC(proc-&gt;display, DefaultScreen(proc-&gt;display))
      , 920, 40, "NETWORKED DEVICES", strlen("NETWORKED DEVICES"));
  </code></pre>
  
  <p>The problem I am having is that without the sleep(1), the string will not get drawn on the screen, slightly confused as to why any ideas?</p>
  
  <p>The first time i call it, it needs a sleep but the second time it is fine :/</p>