Skip to content

Commit

Permalink
add support for resize events
Browse files Browse the repository at this point in the history
Signed-off-by: Alexei Starovoitov <ast@fb.com>
  • Loading branch information
4ast committed Jan 4, 2016
1 parent b642df6 commit d5bd1d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions src/frontend/mosh-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/stmclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ bool STMClient::main( void )
}
}

if ( 0 && sel.signal( SIGWINCH ) ) {
if ( sel.signal( SIGWINCH ) ) {
/* resize */
if ( !process_resize() ) { return false; }
}
Expand Down

0 comments on commit d5bd1d3

Please sign in to comment.