|
Make it run
All X programs need an event loop which processes events from the X server until the program wants to quit. As events will be covered in tutorial 2, a fake eventloop will do the trick. It let's the program sleep for 10 seconds then exits our "event loop". Finally we clean up the resources we have allocated. Usually most located X resources are freed with XFree(). Fonts and GC's are exceptions and are freed with XFreeFont and XFreeGC. XCloseDisplay disconnects us from the X server and frees the resources used by the Display struct. Naturaly you can't use resources after they have been freed. Final wordsThis tutorial has shown some basic features of the Xlib library. However a more object oriented approach is preferable when dealing with larger applications. I have enhanced the tutorial code to include a painter and a font class which hides some of the X details from the user. The next tutorial will be based on the object oriented version. Also worth noting is that repainting after resize or covering does not work. This will be handled in the second tutorial. The latest version of this tutorial is part of the frekko project and can always be found here. Attached files: Comment ListThere are no comments. |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||