X Windows System Event Processing
- X Window System Event Processing
- X Window System Components
- xevnts: A Sample Program
- Registering Procedures
- Where to Go from Here, and Code Listings
- Definition and Elaboration of Terms
This article introduces the methods for an X-based application to request and process events required in support of an application's behavior. For example, an application that allows the user to select a color from a palette requires notification when the mouse button is pressed and the cursor is positioned over one of the available color tiles. Furthermore, you might want to know when the mouse enters the area that is unique to each of the color choices in order to update a hints field or to activate bubble help.
Each of the actions — pressing and entering — corresponds to an event in the X Window system and must be requested and subsequently processed by an application that requires them.
Consider first the pressed action. The event known to X for communicating a button press to an application is the XbuttonEvent, and it is supported by the button components (widgets) in both the Athena and the Motif Widget Sets. The entered action, however, is sent to an application as the XCrossingEvent and is not inherently available to most widgets.
The following sections demonstrate the methods provided for developers in the X Window system to employ both the inherent behavior of windowing components (widgets) and the behavior that requires the augmenting of events processed by these components.
Prerequisites
Anyone who is familiar with C language syntax and basic programming constructs, and who also has an interest in X Window programming will benefit from the following discussion.
This article does not explain the programming elements that are required by all X-based applications—:namely, connecting to the X Server, realizing an instance hierarchy, and entering the X Toolkit Intrinsics application loop. The reader should refer to the man pages for a description of unfamiliar Xt library calls.
When You're Finished
Upon completion of this article, you will understand the components that comprise an X-based application, the concept of event-driven program flow, and the hooks that are available for requesting the X Server to communicate events to an application. In addition, you will have read a structured example demonstrating the use of these principles.