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:

  1. Connect to the X server
  2. Create a window
  3. 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)
  4. Decide which events we want the window to receive
  5. Create a graphics context for output
  6. "Map", or show the window
  7. Enter the events loop, which is where the application "does things"

Usage

Execute the program during an X session.

Source and Downloads