The Magen Avraham (OC 526 sk 8) quotes the Shelah (here) that one should not look at the moon during kiddush levana but rather glance at it in the beginning and look down. The Shelah referneces what he wrote earlier (here) where he quotes the book Shushan Sodot (bio?) that one should not look at the moon seemingly ever. The Shushan Sodot himself (here) quotes his teacher Rabbi Meir HaLevi as teaching a new law that has no source in Torah, Neviim or Midrash that compares looking at the moon to looking at a rainbow which is forbidden per the Gemara in Chagigah 16a and codified in Shulchan Aruch OC 225:1. He says that the moon represents the House of David and that when the moon is diminished it somehow represents a diminishing of some spiritual forces.
I admit I'm not really sure what's going on here, not being a kabbalist myself. It does at least seem that there is some kabbalistic reason for not looking at the moon even not during kiddush levana and even when not looking through windows.