10.3 Event Masks

Clients select event reporting of most events relative to a window. To do this, pass an event mask to an Xlib event-handling function that takes an event_mask argument. The bits of the event mask are defined in X11/X.h. Each bit in the event mask maps to an event mask name, which describes the event or events you want the X server to return to a client application.

Unless the client has specifically asked for them, most events are not reported to clients when they are generated. Unless the client suppresses them by setting graphics-exposures in the GC to False , GraphicsExpose and NoExpose are reported by default as a result of XCopyPlane() and XCopyArea(). SelectionClear, SelectionRequest, SelectionNotify, or ClientMessage cannot be masked. Selection related events are only sent to clients cooperating with selections (see section "Selections"). When the keyboard or pointer mapping is changed, MappingNotify is always sent to clients.

The following table lists the event mask constants you can pass to the event_mask argument and the circumstances in which you would want to specify the event mask:


Event Mask Circumstances

NoEventMask No events wanted
KeyPressMask Keyboard down events wanted
KeyReleaseMask Keyboard up events wanted
ButtonPressMask Pointer button down events wanted
ButtonReleaseMask Pointer button up events wanted
EnterWindowMask Pointer window entry events wanted
LeaveWindowMask Pointer window leave events wanted
PointerMotionMask Pointer motion events wanted
PointerMotionHintMask Pointer motion hints wanted
Button1MotionMask Pointer motion while button 1 down
Button2MotionMask Pointer motion while button 2 down
Button3MotionMask Pointer motion while button 3 down
Button4MotionMask Pointer motion while button 4 down
Button5MotionMask Pointer motion while button 5 down
ButtonMotionMask Pointer motion while any button down
KeymapStateMask Keyboard state wanted at window entry and focus in
ExposureMask Any exposure wanted
VisibilityChangeMask Any change in visibility wanted
StructureNotifyMask Any change in window structure wanted
ResizeRedirectMask Redirect resize of this window
SubstructureNotifyMask Substructure notification wanted
SubstructureRedirectMask Redirect structure requests on children
FocusChangeMask Any change in input focus wanted
PropertyChangeMask Any change in property wanted
ColormapChangeMask Any change in colormap wanted
OwnerGrabButtonMask Automatic grabs should activate with owner_events set to True

Next: Event Processing Overview

Christophe Tronche, [email protected]