title: X11 how to listen real-time moving window events
body: <p>I can only get events after the window has moved, not while it is moving.</p>
  <p>I want to get moving events in real time. Please,what should I do?</p>
  <pre class="lang-c prettyprint-override"><code>#include &lt;X11/X.h&gt;
  #include &lt;X11/Xlib.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(int argv, char **agrc)
  {
      Display *dpy = XOpenDisplay(NULL);
      Window w = XCreateSimpleWindow(dpy, RootWindow(dpy, DefaultScreen(dpy)), 10, 10, 800, 400, 1, BlackPixel(dpy, DefaultScreen(dpy)), WhitePixel(dpy, DefaultScreen(dpy)));
      XSelectInput(dpy, w, StructureNotifyMask);
      XMapWindow(dpy, w);
      XEvent event;
      for (;;)
      {
          XNextEvent(dpy, &amp;event);
  
          if(event.type == ConfigureNotify)
          {
              XConfigureEvent x = event.xconfigure;
              printf(&quot;config[%d]{%d,%d,%d,%d}\n&quot;, x.window, x.x, x.y, x.width, x.height);
          }
      }
  
      XDestroyWindow(dpy, w);
      XCloseDisplay(dpy);
      return 0;
  }
  </code></pre>