| 15 | } |
| 16 | |
| 17 | function initWindowIsFocused() { |
| 18 | DomUtils.documentReady().then(() => windowHasFocus = document.hasFocus()); |
| 19 | globalThis.addEventListener( |
| 20 | "focus", |
| 21 | forTrusted(function (event) { |
| 22 | if (event.target === window) { |
| 23 | windowHasFocus = true; |
| 24 | } |
| 25 | return true; |
| 26 | }), |
| 27 | true, |
| 28 | ); |
| 29 | globalThis.addEventListener( |
| 30 | "blur", |
| 31 | forTrusted(function (event) { |
| 32 | if (event.target === window) { |
| 33 | windowHasFocus = false; |
| 34 | } |
| 35 | return true; |
| 36 | }), |
| 37 | true, |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | // True if this window should be focusable by various Vim commands (e.g. "nextFrame"). |
| 42 | function isWindowFocusable() { |