Generalize window handling