diff --git a/src/protocols/ssh/guac_handlers.c b/src/protocols/ssh/guac_handlers.c index e3a87621..e79ae7a6 100644 --- a/src/protocols/ssh/guac_handlers.c +++ b/src/protocols/ssh/guac_handlers.c @@ -393,6 +393,9 @@ int ssh_guac_client_size_handler(guac_client* client, int width, int height) { /* Resize terminal */ guac_terminal_resize(terminal, columns, rows); + /* Update cursor */ + guac_terminal_commit_cursor(terminal); + /* Update SSH pty size if connected */ if (guac_client_data->term_channel != NULL) channel_change_pty_size(guac_client_data->term_channel, diff --git a/src/protocols/ssh/terminal.c b/src/protocols/ssh/terminal.c index b983931a..3a73a6fd 100644 --- a/src/protocols/ssh/terminal.c +++ b/src/protocols/ssh/terminal.c @@ -769,6 +769,12 @@ void guac_terminal_resize(guac_terminal* term, int width, int height) { } + /* Keep cursor on screen */ + if (term->cursor_row < 0) term->cursor_row = 0; + if (term->cursor_row >= height) term->cursor_row = height-1; + if (term->cursor_col < 0) term->cursor_col = 0; + if (term->cursor_col >= width) term->cursor_col = width-1; + /* Commit new dimensions */ term->term_width = width; term->term_height = height;