Next: The General Plan Up: Introduction Previous: Prerequisites

Some terminology

Before we can start, you need to know a few things first. Xwindows code runs on Unix machines. Unix can be considered the "bottom level" of code. On top of Unix run some system libaries (the normal things like stdio.h, math.h, etc.). On top of that runs the X windows system, which is made up of the X windows libraries (from a programmer's view). This is sometimes called Xlib (pronounced "ecks-libe"). On top of that runs the "Xt intrinsics", which is another group of C library routines. Finally, teetering on top of all of this is something called the Motif widget set. Motif tries to be an object oriented set of routines that allows a programmer to build an X windows user interface in a finite amount of time. Then on top of the pile you write your application program.

When you build a Motif application, you make calls into the Motif library, the Xt library, Xlib, and the normal Unix system libraries. This is one of the things that makes Motif programming so complicated - you have to know a ton of stuff to know what to call when, and to know how things react with one another. On the other hand, you can do useful work by knowing a small subset of the total, and then incrementally increase your knowledge as the need arises.

"Why", you might ask, "should I use Motif rather than writing to Xlib directly?" Basically because Motif is a time-saver. Complete, nice-looking user interfaces written in X tend to be EXTREMELY long. "How long?", you ask. Well, there's the story about the guy who wanted to write a "hello world" type program using Xlib, and it took him four pages of code to do it. Motif tends to make the user interface code shorter and much easier.

You also need to know that XWindows, and therefore Motif, is an "event driven programming environment". This means that the user interface is programmed to respond to user "events". When the user hits a key on the keyboard, that generates an "event" that the program must then respond to. When the user moves or clicks the mouse, events are also generated. An "event loop" sits and waits for user events. When events occur, the event loop calls the correct piece of code to handle them. One of the joys of programming in Motif is that the Motif code handles almost all of the low-level user-generated events, updates the screen based on those events, and only then (after all the hard stuff is done) does it call the code you have written.

A lot of this might not make much sense to you at this moment, and if that's the case don't panic. It will make more sense as we go through examples.



Next: The General Plan Up: Introduction Previous: Prerequisites


morbe@enstb.enst-bretagne.fr