diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-13 14:14:40 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-13 14:15:26 +0300 |
| commit | 4600309051e5d6bea1f64e72cec585b102117ce5 (patch) | |
| tree | 8ca78803bbef8453bdd2d9a0de312201cd0ee60d /src/server/client_transport.rs | |
| parent | fb9aff54087aa8a606e9260a689986d2bd76f5fa (diff) | |
feat: support kitty graphics in attached clients
Diffstat (limited to 'src/server/client_transport.rs')
| -rw-r--r-- | src/server/client_transport.rs | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/server/client_transport.rs b/src/server/client_transport.rs index c4c1acc0..a74bf7f6 100644 --- a/src/server/client_transport.rs +++ b/src/server/client_transport.rs @@ -51,6 +51,8 @@ pub(crate) enum ServerEvent { client_id: u64, cols: u16, rows: u16, + cell_width_px: u32, + cell_height_px: u32, render_encoding: RenderEncoding, writer: ClientWriter, }, @@ -61,6 +63,8 @@ pub(crate) enum ServerEvent { client_id: u64, cols: u16, rows: u16, + cell_width_px: u32, + cell_height_px: u32, }, /// A client detached gracefully. ClientDetach { client_id: u64 }, @@ -113,11 +117,13 @@ pub(crate) fn handle_client_handshake( } }; - let (client_cols, client_rows, render_encoding) = match hello { + let (client_cols, client_rows, cell_width_px, cell_height_px, render_encoding) = match hello { ClientMessage::Hello { version, cols, rows, + cell_width_px, + cell_height_px, requested_encoding, } => { // Version check. @@ -137,7 +143,13 @@ pub(crate) fn handle_client_handshake( // Clamp size. let (clamped_cols, clamped_rows) = clamp_terminal_size(cols, rows); - (clamped_cols, clamped_rows, requested_encoding) + ( + clamped_cols, + clamped_rows, + cell_width_px.max(1), + cell_height_px.max(1), + requested_encoding, + ) } _ => { // First message must be Hello. @@ -176,6 +188,8 @@ pub(crate) fn handle_client_handshake( client_id, cols: client_cols, rows: client_rows, + cell_width_px, + cell_height_px, render_encoding, writer, }); @@ -324,12 +338,19 @@ fn client_read_loop( ServerEvent::ClientInput { client_id, data } } } - ClientMessage::Resize { cols, rows } => { + ClientMessage::Resize { + cols, + rows, + cell_width_px, + cell_height_px, + } => { let (clamped_cols, clamped_rows) = clamp_terminal_size(cols, rows); ServerEvent::ClientResize { client_id, cols: clamped_cols, rows: clamped_rows, + cell_width_px: cell_width_px.max(1), + cell_height_px: cell_height_px.max(1), } } ClientMessage::Detach => ServerEvent::ClientDetach { client_id }, @@ -399,6 +420,8 @@ mod tests { version: PROTOCOL_VERSION, cols: 100, rows: 30, + cell_width_px: 8, + cell_height_px: 16, requested_encoding: RenderEncoding::TerminalAnsi, }, ) @@ -427,11 +450,14 @@ mod tests { client_id, cols, rows, + cell_width_px, + cell_height_px, render_encoding, writer, } => { assert_eq!(client_id, 42); assert_eq!((cols, rows), (100, 30)); + assert_eq!((cell_width_px, cell_height_px), (8, 16)); assert_eq!(render_encoding, RenderEncoding::TerminalAnsi); drop(writer); } |
