From a08dfaef2f13873fc85dc9e1357235b8b0703a46 Mon Sep 17 00:00:00 2001 From: Can Celik Date: Sun, 5 Apr 2026 02:24:57 +0300 Subject: feat: forward ghostty pane focus events on focus changes --- src/app/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/app/mod.rs') diff --git a/src/app/mod.rs b/src/app/mod.rs index 914c6ca4..b53024b1 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -738,7 +738,13 @@ impl App { return; } + #[cfg(feature = "ghostty-vt")] + if let Some((ws_idx, pane_id)) = self.last_focus { + self.send_pane_focus_event(ws_idx, pane_id, crate::ghostty::FocusEvent::Lost); + } if let Some((ws_idx, pane_id)) = current_focus { + #[cfg(feature = "ghostty-vt")] + self.send_pane_focus_event(ws_idx, pane_id, crate::ghostty::FocusEvent::Gained); self.emit_event(crate::api::schema::EventEnvelope { event: crate::api::schema::EventKind::WorkspaceFocused, data: crate::api::schema::EventData::WorkspaceFocused { @@ -770,6 +776,24 @@ impl App { self.last_focus = current_focus; } + #[cfg(feature = "ghostty-vt")] + fn send_pane_focus_event( + &self, + ws_idx: usize, + pane_id: crate::layout::PaneId, + event: crate::ghostty::FocusEvent, + ) { + let Some(runtime) = self + .state + .workspaces + .get(ws_idx) + .and_then(|ws| ws.runtime(pane_id)) + else { + return; + }; + runtime.try_send_focus_event(event); + } + fn find_pane( &self, pane_id: crate::layout::PaneId, -- cgit v1.2.3