To remove the next event that matches both a window and an event mask, use XWindowEvent().
To remove the next event that matches both a window and an event mask (if any), use XCheckWindowEvent().
To remove the next event that matches an event mask, use XMaskEvent().
To return and remove the next event that matches an event mask (if any), use XCheckMaskEvent().
To return and remove the next event in the queue that matches an event type, use XCheckTypedEvent().
To return and remove the next event in the queue that matches an event type and a window, use XCheckTypedWindowEvent().