From 80c0c07250d22f69d3fa05cb1700302d66180eb8 Mon Sep 17 00:00:00 2001 From: Can Celik Date: Mon, 28 Sep 2026 16:19:42 +0300 Subject: perf: send scrolling pane output as row shifts and skip blank cells (#4711) * perf: send scrolling pane output as row shifts and skip blank cells * fix: keep expanded scroll patches disjoint for the fast presentation path --- src/client/mod.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/client/mod.rs') diff --git a/src/client/mod.rs b/src/client/mod.rs index 2cec6d2d..b78517ac 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -145,6 +145,16 @@ use crate::protocol::{self, ClientMessage, ServerMessage, MAX_GRAPHICS_FRAME_SIZ use crate::protocol::{AttachScrollDirection, AttachScrollSource, NotifyKind}; use crate::server::socket_paths::client_socket_path; +/// The decoder for whichever optional surface encodings this connection negotiated. +fn negotiated_surface_decoder( + negotiation: &endpoint::EndpointNegotiation, +) -> Option { + let reuse = negotiation.supports_capability(protocol::surface_reuse::CAPABILITY); + let delta = negotiation.supports_capability(protocol::surface_delta::CAPABILITY); + let scroll = negotiation.supports_capability(protocol::surface_scroll::CAPABILITY); + (reuse || delta || scroll).then(|| protocol::surface_reuse::Decoder::new(delta, scroll)) +} + fn run_client_with_mode( attach_request: Option<(String, bool)>, attach_escape: Option, @@ -588,10 +598,7 @@ async fn run_client_loop( handshake.endpoint_methods.unwrap_or_default(), handshake.endpoint_capabilities.unwrap_or_default(), ); - let surface_reuse = negotiation.supports_capability(protocol::surface_reuse::CAPABILITY); - let surface_delta = negotiation.supports_capability(protocol::surface_delta::CAPABILITY); - let surface_decoder = (surface_reuse || surface_delta) - .then(|| protocol::surface_reuse::Decoder::new(surface_delta)); + let surface_decoder = negotiated_surface_decoder(&negotiation); let transport = start_endpoint_transport( stream, (), @@ -1285,10 +1292,7 @@ async fn run_client_loop( ) { continue; } - let surface_reuse = - negotiation.supports_capability(protocol::surface_reuse::CAPABILITY); - let surface_delta = - negotiation.supports_capability(protocol::surface_delta::CAPABILITY); + let surface_decoder = negotiated_surface_decoder(&negotiation); let agent_view_projection_supported = negotiation.supports_capability( crate::protocol::endpoint::AGENT_VIEW_PROJECTION_CAPABILITY, ); @@ -1313,8 +1317,6 @@ async fn run_client_loop( if let Some(frame) = frame { state.present_frame(frame); } - let surface_decoder = (surface_reuse || surface_delta) - .then(|| protocol::surface_reuse::Decoder::new(surface_delta)); let reader_tx = event_tx.clone(); std::thread::spawn(move || { server_reader_thread( -- cgit v1.2.3