onDidChangeWindowState

An Event which fires when the focus or activity state of the current window changes. The value of the event represents whether the window is focused.

Online Documentation