Add keyboard shortcuts for paste and scrolling. Allow middle click for paste.
This commit is contained in:
parent
417642eb8e
commit
d583dbb990
@ -115,6 +115,11 @@ typedef struct ssh_guac_client_data {
|
|||||||
*/
|
*/
|
||||||
int mod_ctrl;
|
int mod_ctrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the shift key is currently being held down.
|
||||||
|
*/
|
||||||
|
int mod_shift;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current mouse button state.
|
* The current mouse button state.
|
||||||
*/
|
*/
|
||||||
|
@ -111,8 +111,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
|
|
||||||
/* Init client data */
|
/* Init client data */
|
||||||
client->data = client_data;
|
client->data = client_data;
|
||||||
client_data->mod_alt = 0;
|
client_data->mod_alt =
|
||||||
client_data->mod_ctrl = 0;
|
client_data->mod_ctrl =
|
||||||
|
client_data->mod_shift = 0;
|
||||||
client_data->clipboard_data = NULL;
|
client_data->clipboard_data = NULL;
|
||||||
client_data->term_channel = NULL;
|
client_data->term_channel = NULL;
|
||||||
|
|
||||||
|
@ -154,15 +154,12 @@ int ssh_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) {
|
|||||||
pthread_mutex_unlock(&(term->lock));
|
pthread_mutex_unlock(&(term->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Paste contents of clipboard on right mouse button up */
|
/* Paste contents of clipboard on right or middle mouse button up */
|
||||||
if ((released_mask & GUAC_CLIENT_MOUSE_RIGHT)
|
if ((released_mask & GUAC_CLIENT_MOUSE_RIGHT) || (released_mask & GUAC_CLIENT_MOUSE_MIDDLE)) {
|
||||||
&& client_data->clipboard_data != NULL) {
|
if (client_data->clipboard_data != NULL)
|
||||||
|
return guac_terminal_send_string(term, client_data->clipboard_data);
|
||||||
int length = strlen(client_data->clipboard_data);
|
else
|
||||||
if (length)
|
return 0;
|
||||||
return guac_terminal_send_data(term,
|
|
||||||
client_data->clipboard_data, length);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If text selected, change state based on left mouse mouse button */
|
/* 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;
|
client_data->mod_ctrl = pressed;
|
||||||
else if (keysym == 0xFFE9)
|
else if (keysym == 0xFFE9)
|
||||||
client_data->mod_alt = pressed;
|
client_data->mod_alt = pressed;
|
||||||
|
else if (keysym == 0xFFE1)
|
||||||
|
client_data->mod_shift = pressed;
|
||||||
|
|
||||||
/* If key pressed */
|
/* If key pressed */
|
||||||
else if (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 */
|
/* Reset scroll */
|
||||||
if (term->scroll_offset != 0) {
|
if (term->scroll_offset != 0) {
|
||||||
pthread_mutex_lock(&(term->lock));
|
pthread_mutex_lock(&(term->lock));
|
||||||
|
Loading…
Reference in New Issue
Block a user