CS 460 Computer Graphics

Introduction to X Windows

X windows was developed at MIT to enable users to run more than one process and to look at multiple output screens. X windows is a policy free system where the user/programmer can employ or develop whatever scheme to be used to display screens. X windows uses a X server that interfaces with the operating system and hardware and a window manager to provide a consistent "feel". Several window managers are available for X, including Motif, OpenLook, twm, fvwm95 (a Win95 look-alike). MS Windows 9x, on the otherhand, provides its own window manager and programmers must use its API under that operating system.

The X windows architecture is based on the X server / X client model. The X clients are separate processes that use interprocess communications to operate with the X server. This has the advantage of being able to run processes on remote machines. The major disadvantage is that even the window manager is a X client using the overhead of interprocess communications.

The X server has standard X functions stored in Xlib to provide the basic API. A set of X Intrinsics, aka X Toolkit or Xt, provides bundled calls to the Xlib to make programming bearable. Graphical Objects, better known as widgets, are developed using the Xt to provide the scroll bars, window borders, buttons, etc. that makeup a desktop environment (Motif's fast widgets are called gadgets).

Windows programming can be broken down into 5 generic activities:

  1. Initialize system
  2. Build graphical objects
  3. Register events and callbacks
  4. Realize graphical objects
  5. Event loop

The rubber_band.c program is used as an example. (Annotated listing is included in today's notes.) The implementation of the 5 generic activities is illustrated.

Events are used to drive the program which are selectively detected using event masks. These masks are a string of bits that can be anded together to check during the event loop. The Expose, MotionNotify, and ButtonPress events are used in the example program.

Detailed notes in pdf format

G. Hill Price