From 81f21fc7acff783732417bfcf8b88d012431f51c Mon Sep 17 00:00:00 2001 From: John Hood Date: Sat, 24 Oct 2015 23:07:38 -0400 Subject: [PATCH] Don't send empty HostBytes strings. This allows more Resize instructions to be elided. It also keeps the server from sending empty updates when the screen has been written but not changed. --- src/statesync/completeterminal.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/statesync/completeterminal.cc b/src/statesync/completeterminal.cc index d65ff9d..c22c6d0 100644 --- a/src/statesync/completeterminal.cc +++ b/src/statesync/completeterminal.cc @@ -87,8 +87,11 @@ string Complete::diff_from( const Complete &existing ) const new_res->MutableExtension( resize )->set_width( terminal.get_fb().ds.get_width() ); new_res->MutableExtension( resize )->set_height( terminal.get_fb().ds.get_height() ); } - Instruction *new_inst = output.add_instruction(); - new_inst->MutableExtension( hostbytes )->set_hoststring( display.new_frame( true, existing.get_fb(), terminal.get_fb() ) ); + string update = display.new_frame( true, existing.get_fb(), terminal.get_fb() ); + if ( !update.empty() ) { + Instruction *new_inst = output.add_instruction(); + new_inst->MutableExtension( hostbytes )->set_hoststring( update ); + } } return output.SerializeAsString();