Fix window focus bug