Added code so that we can check if the window has focus or not.