Xlib tutorial part 5 -- Rearranging

by Alan at Mon 9th Feb 2009 1:00AM EST


In the next few posts, we're going to concentrate on being a good citizen in the X world. This post is about reorganizing code, next will be about obeying the user's preferences, and the following two lessons will be code for supporting non western Europe languages, as well as showing the name of the program in the title bar.

First, grab the code.

The two parts of the program have been broken up into two functions. One to do setup (allocating colours, the font and a pen (GC) and creating a window) , and one to run the main loop. This is more normal for X programs. Usually, your program will spend some time doing setup in a variety of functions, and then run a function that is the main loop collection events and responding to them.

Other than that, we haven't done very much, but we have made way for our later changes.

Things to try:


Comments are closed.