diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-08-09 02:04:39 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-09 02:04:39 +0300 |
| commit | 1777e9bba32b953ed1ad203b4a16d01105539000 (patch) | |
| tree | 22096973812c9baba822453d8470bdcfe64fc2a6 /src/pane/input.rs | |
| parent | 36a8d36a7258e08b40c01bf521b1f4006525f143 (diff) | |
feat(graphics): add direct pane frame streaming (#2523)
* feat(graphics): add direct pane frame streaming
* feat(graphics): expose pane visibility
* test(graphics): preserve legacy terminal image output
* fix(graphics): harden streaming lifecycle
* fix(input): preserve mouse releases outside panes
Diffstat (limited to 'src/pane/input.rs')
| -rw-r--r-- | src/pane/input.rs | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/pane/input.rs b/src/pane/input.rs index 2e60bfc8..2ff299c9 100644 --- a/src/pane/input.rs +++ b/src/pane/input.rs @@ -60,23 +60,43 @@ pub(super) fn ghostty_mods_from_key_modifiers(modifiers: crossterm::event::KeyMo pub(super) fn ghostty_mouse_encoder_for_terminal( terminal: &crate::ghostty::Terminal, + position: crate::input::mouse::Position, ) -> Option<crate::ghostty::MouseEncoder> { let mut encoder = crate::ghostty::MouseEncoder::new().ok()?; encoder.set_from_terminal(terminal); - if terminal - .mode_get(crate::ghostty::MODE_MOUSE_SGR_PIXELS) - .ok()? - { - // Herdr receives host mouse positions in terminal cells. Downgrade - // SGR-pixels to normal SGR so forwarded coordinates stay cell-local. - encoder.set_format(crate::ghostty::MOUSE_FORMAT_SGR); - } let cols = terminal.cols().ok()? as u32; let rows = terminal.rows().ok()? as u32; - encoder.set_size(cols, rows, 1, 1); + match position { + crate::input::mouse::Position::Cell { .. } => { + if terminal + .mode_get(crate::ghostty::MODE_MOUSE_SGR_PIXELS) + .ok()? + { + encoder.set_format(crate::ghostty::MOUSE_FORMAT_SGR); + } + encoder.set_size(cols, rows, 1, 1); + } + crate::input::mouse::Position::Pixels { .. } => { + let width_px = terminal.width_px().ok()?; + let height_px = terminal.height_px().ok()?; + if width_px == 0 || height_px == 0 || cols == 0 || rows == 0 { + return None; + } + encoder.set_size(width_px, height_px, width_px / cols, height_px / rows); + } + } Some(encoder) } +pub(super) fn ghostty_mouse_position_for_terminal( + position: crate::input::mouse::Position, +) -> Option<(f32, f32)> { + match position { + crate::input::mouse::Position::Pixels { x, y } => Some((x as f32, y as f32)), + crate::input::mouse::Position::Cell { column, row } => Some((column as f32, row as f32)), + } +} + pub(super) fn ghostty_mouse_event_from_button_kind( kind: crossterm::event::MouseEventKind, column: u16, |
