Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUACAMOLE-192: Double and triple click function #406

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
110 changes: 106 additions & 4 deletions src/protocols/ssh/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

#include "common/cursor.h"
#include "common/display.h"
#include "common/recording.h"
#include "ssh.h"
#include "terminal/terminal.h"
#include "terminal/terminal-priv.h"

#include <guacamole/client.h>
#include <guacamole/recording.h>
Expand All @@ -37,17 +39,117 @@ int guac_ssh_user_mouse_handler(guac_user* user, int x, int y, int mask) {
guac_ssh_client* ssh_client = (guac_ssh_client*) client->data;
guac_terminal* term = ssh_client->term;

/* Get mouse information */
term->select_row = y / term->display->char_height - term->scroll_offset;
term->select_col = x / term->display->char_width;
term->select_head = term->select_col;
term->select_tail = term->select_col;
int released_mask = term->mouse_mask & ~mask;
int pressed_mask = ~term->mouse_mask & mask;

/* Skip if terminal not yet ready */
if (term == NULL)
return 0;

/* Report mouse position within recording */
if (ssh_client->recording != NULL)
guac_recording_report_mouse(ssh_client->recording, x, y, mask);
guac_common_recording_report_mouse(ssh_client->recording, x, y, mask);

/* Clear the selection effect if not on selecting*/
if (term->mouse_state == 0 && (pressed_mask & GUAC_CLIENT_MOUSE_LEFT)) {

/* Clear selection effect */
guac_terminal_draw_blank(term);

/* Send mouse event */
guac_terminal_send_mouse(term, user, x, y, mask);
return 0;
}

/* Start time recoding when mouse first pressed */
else if (term->mouse_state == 0 && (released_mask & GUAC_CLIENT_MOUSE_LEFT)) {

/* Start timer */
term->start_1 = guac_timestamp_current();
term->mouse_state = 1;

/* Send mouse event */
guac_terminal_send_mouse(term, user, x, y, mask);
return 0;
}

/* Second click events */
else if (term->mouse_state == 1 && (pressed_mask & GUAC_CLIENT_MOUSE_LEFT)) {

term->end_1 = guac_timestamp_current();
guac_timestamp interval_1 = term->end_1 - term->start_1;

/* Time interval determination */
if (interval_1 < 300){
guac_terminal_double_click(term);
term->start_2 = guac_timestamp_current();
}
else
term->mouse_state = 0;

/* Send mouse event */
guac_terminal_send_mouse(term, user, x, y, mask);
return 0;
}

/* After second events */
else if (term->mouse_state == 1 && (released_mask & GUAC_CLIENT_MOUSE_LEFT)) {
term->end_2 = guac_timestamp_current();
guac_timestamp interval_2 = term->end_2 - term->start_2;

/* Time interval determination */
if (interval_2 < 300){
term->start_3 = guac_timestamp_current();
term->mouse_state = 2;
}
else
term->mouse_state = 0;

/* Send mouse event */
guac_terminal_send_mouse(term, user, x, y, mask);
return 0;
}

/* Third click events */
else if (term->mouse_state == 2 && (pressed_mask & GUAC_CLIENT_MOUSE_LEFT)) {
term->end_3 = guac_timestamp_current();
guac_timestamp interval_3 = term->end_3 - term->start_3;

/* Time interval determination */
if (interval_3 < 300){
guac_terminal_triple_click(term);
}
else {
guac_terminal_draw_blank(term);
term->mouse_state = 0;
}

/* Send mouse event */
guac_terminal_send_mouse(term, user, x, y, mask);
return 0;
}

/* Other conditions */
else if (term->mouse_state == 2 && (released_mask & GUAC_CLIENT_MOUSE_LEFT)) {
term->mouse_state = 0;

/* Send mouse event */
guac_terminal_send_mouse(term, user, x, y, mask);
return 0;
}

else{

/* Send mouse event */
guac_terminal_send_mouse(term, user, x, y, mask);
return 0;
}

/* Send mouse event */
guac_terminal_send_mouse(term, user, x, y, mask);
return 0;
}

int guac_ssh_user_key_handler(guac_user* user, int keysym, int pressed) {
Expand Down