Add direct method to query whether application window has focus. Warning:
code is not cross platform.