next up previous contents
Next: KeyBoard Encoding Up: Events: Input from a Previous: Events: Input from a

Event types

There now follows a complete list of events

tabular338

The usual call to get events is the following.

XNextEvent(display,rep)      /* flush output then fill in struct with event */
    XEvent *rep;     /* RETURN next event removed from the queue 
                        If queue is empty it waits until an event arrives */
Note that the returned event might well need to be cast before its fields are accessed. If, for example, you declare XEvent event and find by looking at event's type field that it's a ButtonEvent then you can use C's union concept to correctly access the x field by doing event.xbutton.x.

XSelectInput(display,w, mask)/* declare which events you wish to receive */
    int mask;        /* event mask: each bit permits 1 event type*/

XFlush(display)              /* flush all output buffers */

XSync(display,discard)       /* flush output buffers & wait till all events */
    int discard;     /* have been delivered.  If discard <> 0 
                        throw all the events away. */


XPeekEvent(display,rep)      /* flush output then fill in struct with event */
    XEvent *rep;     /* RETURN next event but DONT remove from queue
                        if queue is empty it waits until an event arrives */

int XQLength(display)        /* returns the length of the waiting event
                                queue as an integer */

XPutBackEvent(display,event) /* push an event back unto the top of the queue */
    XEvent *event;   /* the event which you want to push back    */

XWindowEvent(display,w, mask, rep) /* flush bufs then look down the queue for*/
    long mask;       /* event which matches this event mask */
    XEvent *rep;     /* RETURN the first event of this sort found
                        If there's no suitable event, wait */

Bool XCheckWindowEvent(display,w, mask, rep) /* flush bufs then look down the 
                        queue for event which fits mask and window */
    long mask;
    XEvent *rep;     /* RETURN the first event of this sort found.
                        If there is no suitable event, 0 is returned */

XMaskEvent(display,mask, rep)/* flush buffers then look down the queue for   */
    int mask;        /* an event which matches this event mask   */
    XEvent *rep;     /* RETURN the first event of this sort found
                        If there's no suitable event, wait */

Bool XCheckMaskEvent(display,mask, rep)/* flush buffers then look down the queue for   */
    int mask;        /* an event which matches this event mask   */
    XEvent *rep;     /* RETURN the first event of this sort found
                        If there's no suitable event, 0 is returned */

int XPending(display) /* flush output & return no of events in input queue */


Tim Love
Mon Mar 11 17:03:18 GMT 1996