Window focus bug fix