Use a type rather than a global variable to deal at trapping signal of window change