Hello,

I'm having a go at making my own window manager (just a model for now, runs under Windows ) and I've got as far as drawing the "desktop" and some windows that change Z order when clicked if not on top, but at the moment I'm redrawing everything on a timer.

What I'd like to do is have a similar painting system to Windows (and I assume, other window managers) whereby whenever you move a window, a rectangle or a list of rectangles is created that describe the region previously occupied by the window and from there determine which parts of which windows occupy the region, respecting Z order, before asking them to repaint their respective parts.

Trouble is, I'm having problems picturing the algorithm.
Does anyone know of some reference material for this concept?