Process resize entirely on server
This commit is contained in:
+28
-6
@@ -1,8 +1,11 @@
|
||||
#include "completeterminal.hpp"
|
||||
|
||||
#include "hostinput.pb.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Parser;
|
||||
using namespace Terminal;
|
||||
using namespace HostBuffers;
|
||||
|
||||
string Complete::act( const string &str )
|
||||
{
|
||||
@@ -33,17 +36,36 @@ string Complete::act( const Action *act )
|
||||
/* interface for Network::Transport */
|
||||
string Complete::diff_from( const Complete &existing )
|
||||
{
|
||||
if ( existing.get_fb() == get_fb() ) {
|
||||
return "";
|
||||
} else {
|
||||
return Terminal::Display::new_frame( true, existing.get_fb(), terminal.get_fb() );
|
||||
HostBuffers::HostMessage output;
|
||||
|
||||
if ( !(existing.get_fb() == get_fb()) ) {
|
||||
if ( (existing.get_fb().ds.get_width() != terminal.get_fb().ds.get_width())
|
||||
|| (existing.get_fb().ds.get_height() != terminal.get_fb().ds.get_height()) ) {
|
||||
Instruction *new_res = output.add_instruction();
|
||||
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( Terminal::Display::new_frame( true, existing.get_fb(), terminal.get_fb() ) );
|
||||
}
|
||||
|
||||
return output.SerializeAsString();
|
||||
}
|
||||
|
||||
void Complete::apply_string( string diff )
|
||||
{
|
||||
string terminal_to_host = act( diff );
|
||||
assert( terminal_to_host.empty() );
|
||||
HostBuffers::HostMessage input;
|
||||
assert( input.ParseFromString( diff ) );
|
||||
|
||||
for ( int i = 0; i < input.instruction_size(); i++ ) {
|
||||
if ( input.instruction( i ).HasExtension( hostbytes ) ) {
|
||||
string terminal_to_host = act( input.instruction( i ).GetExtension( hostbytes ).hoststring() );
|
||||
assert( terminal_to_host.empty() ); /* server never interrogates client terminal */
|
||||
} else if ( input.instruction( i ).HasExtension( resize ) ) {
|
||||
act( new Resize( input.instruction( i ).GetExtension( resize ).width(),
|
||||
input.instruction( i ).GetExtension( resize ).height() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Complete::operator==( Complete const &x ) const
|
||||
|
||||
Reference in New Issue
Block a user