title: XNextEvent Doesn't works for some reason
body: <p>I'm trying to catch keypress events using XLib. But for some reasons XNextEvent not working.
  I'm not receiving any errors, but it looks like my program stuck on the line of "XNextEvent" call.
  Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdio&gt;
  #include &lt;cstdlib&gt;
  #include &lt;X11/Xlib.h&gt;
  #include &lt;X11/Xutil.h&gt;
  
  using namespace std;
  
  
  int main()
  {
      XEvent event;
      KeySym key;
      char text[255];
      Display *dis;
  
      dis = XOpenDisplay(NULL);
      while (1) {
          XNextEvent(dis, &amp;event);
          if (event.type==KeyPress &amp;&amp; XLookupString(&amp;event.xkey,text,255,&amp;key,0) == 1) {
              if (text[0]=='q') {
                  XCloseDisplay(dis);
                  return 0;
              }
              printf("You pressed the %c key!\n", text[0]);
          }
      }
      return 0;
  }
  </code></pre>