diff --git a/protocols/ssh/include/client.h b/protocols/ssh/include/client.h index a0fc5198..08437d03 100644 --- a/protocols/ssh/include/client.h +++ b/protocols/ssh/include/client.h @@ -115,6 +115,11 @@ typedef struct ssh_guac_client_data { */ int mod_ctrl; + /** + * Whether the shift key is currently being held down. + */ + int mod_shift; + /** * The current mouse button state. */ diff --git a/protocols/ssh/src/client.c b/protocols/ssh/src/client.c index b23dbdc5..4a0e6457 100644 --- a/protocols/ssh/src/client.c +++ b/protocols/ssh/src/client.c @@ -111,8 +111,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Init client data */ client->data = client_data; - client_data->mod_alt = 0; - client_data->mod_ctrl = 0; + client_data->mod_alt = + client_data->mod_ctrl = + client_data->mod_shift = 0; client_data->clipboard_data = NULL; client_data->term_channel = NULL; diff --git a/protocols/ssh/src/guac_handlers.c b/protocols/ssh/src/guac_handlers.c index d57c7251..bbe741b8 100644 --- a/protocols/ssh/src/guac_handlers.c +++ b/protocols/ssh/src/guac_handlers.c @@ -154,15 +154,12 @@ int ssh_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { pthread_mutex_unlock(&(term->lock)); } - /* Paste contents of clipboard on right mouse button up */ - if ((released_mask & GUAC_CLIENT_MOUSE_RIGHT) - && client_data->clipboard_data != NULL) { - - int length = strlen(client_data->clipboard_data); - if (length) - return guac_terminal_send_data(term, - client_data->clipboard_data, length); - + /* Paste contents of clipboard on right or middle mouse button up */ + if ((released_mask & GUAC_CLIENT_MOUSE_RIGHT) || (released_mask & GUAC_CLIENT_MOUSE_MIDDLE)) { + if (client_data->clipboard_data != NULL) + return guac_terminal_send_string(term, client_data->clipboard_data); + else + return 0; } /* If text selected, change state based on left mouse mouse button */ @@ -246,10 +243,41 @@ int ssh_guac_client_key_handler(guac_client* client, int keysym, int pressed) { client_data->mod_ctrl = pressed; else if (keysym == 0xFFE9) client_data->mod_alt = pressed; + else if (keysym == 0xFFE1) + client_data->mod_shift = pressed; /* If key pressed */ else if (pressed) { + /* Ctrl+Shift+V shortcut for paste */ + if (keysym == 'V' && client_data->mod_ctrl) { + if (client_data->clipboard_data != NULL) + return guac_terminal_send_string(term, client_data->clipboard_data); + else + return 0; + } + + /* Shift+PgUp / Shift+PgDown shortcuts for scrolling */ + if (client_data->mod_shift) { + + /* Page up */ + if (keysym == 0xFF55) { + pthread_mutex_lock(&(term->lock)); + guac_terminal_scroll_display_up(term, term->term_height); + pthread_mutex_unlock(&(term->lock)); + return 0; + } + + /* Page down */ + if (keysym == 0xFF56) { + pthread_mutex_lock(&(term->lock)); + guac_terminal_scroll_display_down(term, term->term_height); + pthread_mutex_unlock(&(term->lock)); + return 0; + } + + } + /* Reset scroll */ if (term->scroll_offset != 0) { pthread_mutex_lock(&(term->lock));