SmartForest is an X Windows application. It is therefore inherently an asynchronous application. Program control does not simply start in main(), run sequentially and then end. Instead, main() ``bootstraps'' the program by reading the input files, preparing a few internal data structures, displaying the Map View and the Forest View windows and creating a map for the windows manager that associates certain events (such as clicking the left mouse button, pressing the ESC key, etc.) with the corresponding functions to execute in SmartForest. It then issues a call to XtAppMainLoop. XtAppMainLoop is an infinite loop that dispatches events to their handlers. The call to XtAppMainLoop registers the current SmartForest process with the windows manager. Metaphorically speaking, the windows manager takes control of the program from main() so main() does not need to run further. Any further actions that are performed by the user are first interpreted by the windows manager using the map that was created earlier in main(). The windows manager calls the appropriate SmartForest function to handle the user's action. The term callback is used to refer to these asynchronous functions that the windows manager calls to handle the user's actions. The term event is used to describe the user's actions. main() has nothing to do with any events that occur after control has been passed to the windows manager. This is the architecture that all X Windows programs utilize.
The remainder of this section is organized as follows: We first describe main() in more detail than appears above. The sequence of initialization will be discussed, however the fine details of each data structure will be delayed -- details are presented in each data structure's section that follows the discussion of main(). A discussion of the callbacks that handle the bulk of SmartForest's capabilities ends the section.