Refreshing windows

People might expect lines or other shapes they have put on the screen to stay put. In X they do not. Another way to look at this is that the X window system does not automatically refresh windows when they become damaged; that is, when a window that was occluding another window is moved or unmapped, it leaves the occluded window with the wrong contents. It is always the responsibility of each application to keep its window up to date.

This is a case where procedural drawing (see pxl-bas-lin) determines programming style in ProXL. You start by writing one setup call, which determines all aspects of a window, creates that window, attaches callbacks, and maps the window. Then when the window is damaged, your callback will be executed to refresh the window. The tutorial ends with a simple example of such a program.

Also note that attempts to draw into a window before it is mapped will quietly be ignored. So if you write a program that creates a window, maps it, and then starts drawing in it, you'll often be surprised to find that there's nothing drawn in the window. It is essential to wait for the window to become mapped. The easiest way to do this is to do the drawing in a callback, which will automatically be executed as soon as the window becomes visible (as well as every time it is damaged).