The X server communicates input to a client through input events associated with a window. In the simplest case, when a keyboard or pointer event occurs, the X server sends the event to the client that has expressed interest in events of that type on the window that contains the pointer. However, processing can be more complex. A client can grab a pointer button or key, the pointer or keyboard, or the entire server; the client then receives the relevant events. A client can set the input focus to some window, and the X server then reports events with respect to this window even if the pointer is outside this window.
To insulate applications from such complexities, Xt and Motif supply facilities for low-level processing of user input to an application:
Most applications can use these high-level interfaces, allowing Xt and Motif to process user input at lower levels. If an application needs more control, it can also provide its own event handler, a routine invoked by the Xt dispatching loop when the widget receives events of the specified type. An application can also provide its own event-dispatching loop.
Issues of input, focus, and keyboard navigation are discussed in more detail in Chapter 13.
For most widgets, Xt and Motif handle low-level output processing as well. For example, in a Label or Text widget, when an application changes the text to be displayed, Motif automatically redisplays the contents of the widget. Most widgets have resources that control the appearance of the output, such as the fonts used to display text.
Motif provides the DrawingArea widget for applications that need to produce graphic output or that need more control or flexibility in displaying text. DrawingArea is discussed in more detail in Chapter 15.