Hello, world! — Xlib
This is another good old "Hello, World!" application, this time using the Xlib interface to the X Window System. Because an X application is event driven (i.e. program execution is determined by the user, rather than by the application itself), there is a certain amount of overhead involved. Most of the code shown here will be common to all X applications.
Programming Issues
There are a number of basic steps involved in creating an X application:
- Connect to the X server
- Create a window
- Set some "hints" for the window manager, to suggest how the window manager should display the window (e.g. in terms of size, initial state)
- Decide which events we want the window to receive
- Create a graphics context for output
- "Map", or show the window
- Enter the events loop, which is where the application "does things"
Usage
Execute the program during an X session.