The X11 application draws rectangles and ellipses as well. The structure of the application is basically the same but the details vary.
Xlib, the implementation library of X11, is not multithread-safe. The use of fibers here is a big win. The X11 GUI application that you will create now looks as follows:
Coding for X11 requires the development libraries. Depending on your operating system, you have to install them as follows:
$ sudo apt-get install libx11-dev
$ sudo yum install –y libX11-dev