Basic X concepts

The X Window System is a big and complex hairball. The Gnome libraries try to make things easy by wrapping the hard stuff with nice wrappers. Still, there are a few things you should keep in mind in order to write better applications.

This chapter is aimed at programmers with little experience on X programming. If you do not know what graphics contexts, drawables, and visuals are, you should definitely read this chapter. If you already know your way around the X way of doing things, you may skip this chapter and move on to the fun stuff (i.e. writing GNOME applications).

Please note that this chapter is intended to be a small crash course on the X concepts you will need to keep in mind while writing Gnome applications. It is not a replacement for an Xlib manual. You should definitely get your hands on the Xlib programmer's and reference manuals.

Drawables

Drawables are things which you can paint on. X has two types of drawables, windows and pixmaps. Pixmaps are off-screen entities which you cannot see. You can see a window when it is mapped (shown) on the screen.

Windows can be nested in a tree structure. All windows except the root window have a single parent, but all windows may have any number of children. Pixmaps cannot be nested and they don't have parents.

Windows have x/y/width/height properties that define their position within their parent. Pixmaps only have width and height properties.

Windows and pixmaps have many other properties. However, a very important property is the visual class of the drawable, which is what we will discuss next.