According to the
windows.onFocusChanged event documentation, it returns either the focused window’s ID, or -1 (
windows.WINDOW_ID_NONEif all browser windows have lost focus.
In Windows and some Linux window managers, WINDOW_ID_NONE will always be sent immediately preceding a switch from one browser window to another.
meaning on some (most) OSes (e.g. Windows), a focus switch between windows fires this event twice, one returning -1 and the other a
windowId. While on others (e.g. MacOS), only one is fired, returning
windowId. And I suppose all OSes fire just one, returning -1, when no window has focus.
Given the need to check for these twin simultaneous events, what is the best way to detect each of these conditions on any platform?
- A browser window is minimized
- No browser window has focus
- Both at once