void GrGetNextEvent ( GR_EVENT * ep );
The GrGetNextEvent function flushes any buffered graphics commands and returns the next event from the event queue and waits for the event, if necessary. If a graphics error occurs, the server calls the error handler at this point. The GR_EVENT is a union of all the possible events. The type field of the union indicates which of the possible events took place, and then you can check the correct element of the union to access that particular event type's data.