title: How to allow a worker thread to update an X11 Window?
body: <p>I have an application that that I was trying to modify so that a worker thread can tell a window to update itself with new data.</p>
  <p>Variables are defined as follows:</p>
  <pre><code>Display *d;
  Window w;
  XEvent exppp;
  </code></pre>
  <p>The window is started with the following code:</p>
  <pre><code>XEvent e;
  
  d = XOpenDisplay(NULL);
  if (d == NULL) 
    return 0;
  
  s = DefaultScreen(d);
  w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 200, 800, 1,
                          BlackPixel(d, s), WhitePixel(d, s));
  XSelectInput(d, w, ExposureMask | KeyPressMask);
  XMapWindow(d, w);
  
  while (1) {
    XNextEvent(d, &amp;e);
    if (e.type == Expose || e.type == KeyPress) {
      // redraw routine goes here
    }
  }
  </code></pre>
  <p>What I was attempting to use to get the window to redraw is a function that can be called by another thread:</p>
  <pre><code>void graphical_out::redraw()
  {
    exppp.type = Expose;
    XSendEvent(d, w, false, Expose, &amp;exppp);
  }
  </code></pre>
  <p>And the window only updates itself when it is re-sized or receives a key-press. This seems a bit like a newbie question but Google has failed me on this one. Any suggestions to what I am doing wrong?</p>