diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-03 02:03:14 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-03 02:03:44 +0300 |
| commit | b695d7cbc0d29540993642c23b3d5798cbf9f7dc (patch) | |
| tree | d7243c891dca6c8991583edd7666ec9fe8cc6f94 /src/pane/input.rs | |
| parent | daf636fef7fd68bcb1e30cfb155883c3b831513c (diff) | |
fix: forward any-motion pane mouse events
refs #419
Diffstat (limited to 'src/pane/input.rs')
| -rw-r--r-- | src/pane/input.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/pane/input.rs b/src/pane/input.rs index 262e036d..6906e77d 100644 --- a/src/pane/input.rs +++ b/src/pane/input.rs @@ -58,6 +58,14 @@ pub(super) fn ghostty_mouse_encoder_for_terminal( ) -> 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); @@ -121,6 +129,24 @@ pub(super) fn ghostty_mouse_event_from_button_kind( Some(event) } +pub(super) fn ghostty_mouse_event_from_motion_kind( + kind: crossterm::event::MouseEventKind, + column: u16, + row: u16, + modifiers: crossterm::event::KeyModifiers, +) -> Option<crate::ghostty::MouseEvent> { + if kind != crossterm::event::MouseEventKind::Moved { + return None; + } + + let mut event = crate::ghostty::MouseEvent::new().ok()?; + event.set_action(crate::ghostty::MOUSE_ACTION_MOTION); + event.clear_button(); + event.set_mods(ghostty_mods_from_key_modifiers(modifiers)); + event.set_position(column as f32, row as f32); + Some(event) +} + pub(super) fn ghostty_mouse_event_from_wheel_kind( kind: crossterm::event::MouseEventKind, column: u16, |
