Initial screen resize support.
This commit is contained in:
parent
ca17560328
commit
8c81cae871
@ -45,6 +45,7 @@ int ssh_guac_client_handle_messages(guac_client* client);
|
||||
int ssh_guac_client_key_handler(guac_client* client, int keysym, int pressed);
|
||||
int ssh_guac_client_mouse_handler(guac_client* client, int x, int y, int mask);
|
||||
int ssh_guac_client_clipboard_handler(guac_client* client, char* data);
|
||||
int ssh_guac_client_size_handler(guac_client* client, int width, int height);
|
||||
int ssh_guac_client_free_handler(guac_client* client);
|
||||
|
||||
#endif
|
||||
|
@ -228,6 +228,7 @@ int ssh_guac_client_auth(guac_client* client, const char* password) {
|
||||
client->mouse_handler = ssh_guac_client_mouse_handler;
|
||||
client->key_handler = ssh_guac_client_key_handler;
|
||||
client->clipboard_handler = ssh_guac_client_clipboard_handler;
|
||||
client->size_handler = ssh_guac_client_size_handler;
|
||||
|
||||
|
||||
/* Success */
|
||||
|
@ -296,6 +296,36 @@ int ssh_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_client_size_handler(guac_client* client, int width, int height) {
|
||||
|
||||
/* Get terminal */
|
||||
ssh_guac_client_data* guac_client_data = (ssh_guac_client_data*) client->data;
|
||||
guac_terminal* terminal = guac_client_data->term;
|
||||
|
||||
/* Calculate dimensions */
|
||||
int rows = height / terminal->display->char_height;
|
||||
int columns = width / terminal->display->char_width;
|
||||
|
||||
pthread_mutex_lock(&(terminal->lock));
|
||||
|
||||
/* If size has changed */
|
||||
if (columns != terminal->term_width || rows != terminal->term_height) {
|
||||
|
||||
/* Resize terminal */
|
||||
guac_terminal_resize(terminal, columns, rows);
|
||||
channel_change_pty_size(guac_client_data->term_channel,
|
||||
terminal->term_width, terminal->term_height);
|
||||
|
||||
/* Reset scroll region */
|
||||
terminal->scroll_end = rows - 1;
|
||||
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&(terminal->lock));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ssh_guac_client_free_handler(guac_client* client) {
|
||||
|
||||
ssh_guac_client_data* guac_client_data = (ssh_guac_client_data*) client->data;
|
||||
|
@ -417,3 +417,15 @@ void guac_terminal_set_columns(guac_terminal* terminal, int row,
|
||||
|
||||
}
|
||||
|
||||
void guac_terminal_resize(guac_terminal* term, int width, int height) {
|
||||
|
||||
/* Resize display */
|
||||
guac_terminal_display_flush(term->display);
|
||||
guac_terminal_display_resize(term->display, width, height);
|
||||
|
||||
/* Commit new dimensions */
|
||||
term->term_width = width;
|
||||
term->term_height = height;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user