XFlush(), XSync(), XEventsQueued(), XPending() - handle output buffer or event queue
XFlush (Display *display)
XSync (Display *display, Bool discard)
int XEventsQueued (Display *display, int mode)
int XPending (Display *display)
The XFlush(3) function flushes the output buffer. Most client applications need not use this function because the output buffer is automatically flushed as needed by calls to XPending(3), XNextEvent(3), and XWindowEvent(3). Events generated by the server may be queued into the library's event queue.
The XSync(3) function flushes the output buffer and then waits until all requests have been received and processed by the X server. Any errors generated must be handled by the error handler. For each protocol error received by Xlib, XSync(3) calls the client application's error handling routine (see section 11.8.2). Any events generated by the server are enqueued into the library's event queue.
Finally, if you passed False, XSync(3) does not discard the events in the queue. If you passed True, XSync(3) discards all events in the queue, including those events that were on the queue before XSync(3) was called. Client applications seldom need to call XSync(3).
If mode is QueuedAlready, XEventsQueued(3) returns the number of events already in the event queue (and never performs a system call). If mode is QueuedAfterFlush, XEventsQueued(3) returns the number of events already in the queue if the number is nonzero. If there are no events in the queue, XEventsQueued(3) flushes the output buffer, attempts to read more events out of the application's connection, and returns the number read. If mode is QueuedAfterReading, XEventsQueued(3) returns the number of events already in the queue if the number is nonzero. If there are no events in the queue, XEventsQueued(3) attempts to read more events out of the application's connection without flushing the output buffer and returns the number read.
XEventsQueued(3) always returns immediately without I/O if there are events already in the queue. XEventsQueued(3) with mode QueuedAfterFlush is identical in behavior to XPending(3). XEventsQueued(3) with mode QueuedAlready is identical to the XQLength() function.
The XPending(3) function returns the number of events that have been received from the X server but have not been removed from the event queue. XPending(3) is identical to XEventsQueued(3) with the mode QueuedAfterFlush specified.
XIfEvent()
Xlib