This patch changes three things:
FVWM now keeps track of window stacking order
First, it makes FVWM keep track of the stacking order of the windows, by using a second set of chain pointers (the original chain keeps track of the order in which windows have been focused, which is often not the same as the stacking order). So now FVWM can easily answer the question "who's on third?" at any time.*
Reversal of window stacking order when FVWM restarts
Second, by using this new-found knowledge, FVWM will reparent windows back to the root window (on a Restart or a Recapture operation) in the reverse of the current stacking order. This eliminates the old quirk of having the stacking order appear more or less reversed after restarting FVWM.
Smoother, faster page/desk transition
Third, it restructures the the Desktop and Viewport (page) switching routines to perform a simultaneous bidirectional loop through the window list (via the new stacking order chain). Windows that are moving off the visible screen are unmapped/moved from the bottom of the stacking order upwards. Windows that are moving onto the visible screen are mapped/moved from the top down.
The intent is to minimize the amount of expose/redraw overhead during these operations when there are a number of overlapping windows involved. It also serves to equalize the visual disturbance between the moving-out and the moving-in operations. Previously, moving out of a page/desktop with many overlapping windows could be disturbing and slow because, as the windows moved from the top down, the ones underneath got redrawn as they were exposed. Moving into such a page/desktop, on the other hand, would appear quick and smooth because, as the upper windows appeared first, the underlying portions of the subsequently mapped/moved windows didn't need to get drawn.
Now, if you never have any overlapping windows on your desktop, you
won't see any improvement from this. If you only occasionally have a couple
of overlapping windows, you might not notice any difference. But if you have
several windows that overlap significantly, the transition to or from the
page where they are should be very noticeably quicker and smoother.