Depending on the type, you should access members of each event by using the XEvent union. The second member always is the serial number of the protocol request that generated the event. The fourth member always is a display, which is the display that the event was read from. Except for keymap events, the fifth member always is a window, which has been carefully selected to be useful to toolkit dispatchers. To avoid breaking toolkits, the order of these first five entries is not to change.
Most events also contain a time member, which is the time at which an event occurred.
In addition, a pointer to the generic event must be cast before it is used to access any other information in the structure.