mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-24 12:46:10 +03:00

When the focus reporting mode (1004) is enabled, send the current focus state. This allows applications to track their own focus state without first having to wait for a focus event (or query it by sending a DECSET followed by a DECRST). Ghostty's focus state is stored only in the renderer, where the termio thread cannot access it. We duplicate the focus state tracking in the Terminal struct with the addition of a new (1-bit) flag. We duplicate the state because the renderer uses the focus state for its own purposes (in particular, the Metal renderer uses the focus state to manage its DisplayLink), and synchronizing access to the shared terminal state is more cumbersome than simply tracking the focus state in the renderer in addition to the terminal.