Convert FOR_ALL_WINDOWS to use a locally declared pointer

This method is pretty ridiculous so it is probably worth looking over the changes extra carefully. Also in the future maybe we should clean this up.