Permalink
Browse files

add support for resize events

Signed-off-by: Alexei Starovoitov <ast@fb.com>
  • Loading branch information...
4ast committed Jan 4, 2016
1 parent b642df6 commit d5bd1d31d86d4003705e69f87466aa7e10f9c5b9
Showing with 24 additions and 3 deletions.
  1. +23 −2 src/frontend/mosh-server.cc
  2. +1 −1 src/frontend/stmclient.cc
@@ -647,8 +647,29 @@ static void serve( int host_fd, Network::UserStream &terminal, ServerConnection
/* apply userstream to terminal */
for ( size_t i = 0; i < us.size(); i++ ) {
const Parser::Action *action = us.get_action( i );
assert(typeid( *action ) == typeid( Parser::UserByte ));
terminal_to_host += ((Parser::UserByte *)action)->c;
if ( typeid( *action ) == typeid( Parser::Resize ) ) {
/* elide consecutive Resize actions */
if ( i < us.size() - 1 &&
typeid( us.get_action( i + 1 ) ) == typeid( Parser::Resize ) ) {
continue;
}
/* tell child process of resize */
const Parser::Resize *res = static_cast<const Parser::Resize *>( action );
struct winsize window_size;
if ( ioctl( host_fd, TIOCGWINSZ, &window_size ) < 0 ) {
perror( "ioctl TIOCGWINSZ" );
return;
}
window_size.ws_col = res->width;
window_size.ws_row = res->height;
if ( ioctl( host_fd, TIOCSWINSZ, &window_size ) < 0 ) {
perror( "ioctl TIOCSWINSZ" );
return;
}
} else {
assert(typeid( *action ) == typeid( Parser::UserByte ));
terminal_to_host += ((Parser::UserByte *)action)->c;
}
}
/* write any writeback octets back to the host */
@@ -452,7 +452,7 @@ bool STMClient::main( void )
}
}
if ( 0 && sel.signal( SIGWINCH ) ) {
if ( sel.signal( SIGWINCH ) ) {
/* resize */
if ( !process_resize() ) { return false; }
}

0 comments on commit d5bd1d3

Please sign in to comment.