title: Get event's in X11
body: <p>I am using Canon SDK to get the events from the camera. In the SDK, we register a callback function, which is called when a particular event occurs. I have built a Java wrapper, which communicates with the SDK.</p>
  
  <p>But when the event is triggered, my window doesn't get the event directly. Infact on windows, this is how I get the event and dispatch it to myself:</p>
  
  <pre><code>private static final User32 lib = User32.INSTANCE;
  boolean hasMessage = lib.PeekMessage( msg, null, 0, 0, 1 ); // peek and remove
  if( hasMessage ){
  lib.TranslateMessage( msg ); 
  lib.DispatchMessage( msg ); //message gets dispatched and hence the callback function is     called
  }
  </code></pre>
  
  <p>Basically one peeps if the window has received an event or not and then proceeds. On Mac, one can do it using <code>Cocoa</code> by having a NSApplication and <code>WindowServer</code> sends events if any.</p>
  
  <p>I am looking for similar alternative using <code>X11</code>. Any sample code/link will suffice.</p>
  
  <p>PS: This a follow up question to <a href="https://stackoverflow.com/questions/15216740/get-events-from-os">this.</a></p>