An Alt+Tab that only ever reached two windows
Three floating windows on one workspace, and a window switcher that flipped between two of them forever.
One workspace holds three floating windows. Alt+Tab only ever switched between two of them.
The binding cycled backward and raised the window it landed on, and on a
floating workspace the raise is required, or the focused window can sit
under another one. The trap is in the raise. bring_to_top moves the
focused window to the end of the list that cyclenext walks. A backward
step from the end lands on the window before it, which is then raised to
the end, and the next backward step lands on the first one again. Two
windows, back and forth, forever.
The same trap had already been written up in an earlier change, which avoided it on tiled workspaces. Floating ones kept it, because that is where the raise could not be dropped.
So the direction changed instead. On a floating workspace Alt+Tab now
cycles forward and raises, which walks all three. Shift reverses it
exactly: alter_zorder sends the top window to the bottom, index zero,
and a backward step from there wraps to the new last window, the one that
was under it. Tiled workspaces keep the old cycle with no raise.
Three presses reaching three windows has not yet been checked by hand.
The bug was never the direction. It was moving the list while walking it.