From df770ae4ea09505d3eb72181b9dff9169926f0bb Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 27 Nov 2017 13:03:21 -0800 Subject: [PATCH] GUACAMOLE-313: Add support for including mouse location within session recordings. --- src/common/common/recording.h | 15 +++++++++++++++ src/common/recording.c | 9 +++++++++ src/protocols/rdp/input.c | 5 +++++ src/protocols/ssh/input.c | 5 +++++ src/protocols/telnet/input.c | 5 +++++ src/protocols/vnc/input.c | 5 +++++ 6 files changed, 44 insertions(+) diff --git a/src/common/common/recording.h b/src/common/common/recording.h index 0305a83c..e03e7881 100644 --- a/src/common/common/recording.h +++ b/src/common/common/recording.h @@ -101,5 +101,20 @@ guac_common_recording* guac_common_recording_create(guac_client* client, */ void guac_common_recording_free(guac_common_recording* recording); +/** + * Reports the current mouse position within the recording. + * + * @param recording + * The guac_common_recording associated with the mouse that has moved. + * + * @param x + * The new X coordinate of the mouse cursor, in pixels. + * + * @param y + * The new Y coordinate of the mouse cursor, in pixels. + */ +void guac_common_recording_report_mouse(guac_common_recording* recording, + int x, int y); + #endif diff --git a/src/common/recording.c b/src/common/recording.c index 274ac6de..4f334d5f 100644 --- a/src/common/recording.c +++ b/src/common/recording.c @@ -20,6 +20,7 @@ #include "common/recording.h" #include +#include #include #ifdef __MINGW32__ @@ -177,3 +178,11 @@ void guac_common_recording_free(guac_common_recording* recording) { free(recording); } +void guac_common_recording_report_mouse(guac_common_recording* recording, + int x, int y) { + + /* Report mouse location */ + guac_protocol_send_mouse(recording->socket, x, y); + +} + diff --git a/src/protocols/rdp/input.c b/src/protocols/rdp/input.c index 9e220496..7cb3da8f 100644 --- a/src/protocols/rdp/input.c +++ b/src/protocols/rdp/input.c @@ -20,6 +20,7 @@ #include "config.h" #include "client.h" +#include "common/recording.h" #include "input.h" #include "keyboard.h" #include "rdp.h" @@ -49,6 +50,10 @@ int guac_rdp_user_mouse_handler(guac_user* user, int x, int y, int mask) { /* Store current mouse location */ guac_common_cursor_move(rdp_client->display->cursor, user, x, y); + /* Report mouse position within recording */ + if (rdp_client->recording != NULL) + guac_common_recording_report_mouse(rdp_client->recording, x, y); + /* If button mask unchanged, just send move event */ if (mask == rdp_client->mouse_button_mask) rdp_inst->input->MouseEvent(rdp_inst->input, PTR_FLAGS_MOVE, x, y); diff --git a/src/protocols/ssh/input.c b/src/protocols/ssh/input.c index 95e01881..b4d0cf5c 100644 --- a/src/protocols/ssh/input.c +++ b/src/protocols/ssh/input.c @@ -21,6 +21,7 @@ #include "common/cursor.h" #include "common/display.h" +#include "common/recording.h" #include "ssh.h" #include "terminal/terminal.h" @@ -40,6 +41,10 @@ int guac_ssh_user_mouse_handler(guac_user* user, int x, int y, int mask) { if (term == NULL) return 0; + /* Report mouse position within recording */ + if (ssh_client->recording != NULL) + guac_common_recording_report_mouse(ssh_client->recording, x, y); + /* Send mouse event */ guac_terminal_send_mouse(term, user, x, y, mask); return 0; diff --git a/src/protocols/telnet/input.c b/src/protocols/telnet/input.c index be50360c..a6742e42 100644 --- a/src/protocols/telnet/input.c +++ b/src/protocols/telnet/input.c @@ -18,6 +18,7 @@ */ #include "config.h" +#include "common/recording.h" #include "input.h" #include "terminal/terminal.h" #include "telnet.h" @@ -42,6 +43,10 @@ int guac_telnet_user_mouse_handler(guac_user* user, int x, int y, int mask) { if (term == NULL) return 0; + /* Report mouse position within recording */ + if (telnet_client->recording != NULL) + guac_common_recording_report_mouse(telnet_client->recording, x, y); + /* Send mouse if not searching for password or username */ if (settings->password_regex == NULL && settings->username_regex == NULL) guac_terminal_send_mouse(term, user, x, y, mask); diff --git a/src/protocols/vnc/input.c b/src/protocols/vnc/input.c index 86f4ca76..ab88c43a 100644 --- a/src/protocols/vnc/input.c +++ b/src/protocols/vnc/input.c @@ -21,6 +21,7 @@ #include "common/cursor.h" #include "common/display.h" +#include "common/recording.h" #include "vnc.h" #include @@ -35,6 +36,10 @@ int guac_vnc_user_mouse_handler(guac_user* user, int x, int y, int mask) { /* Store current mouse location */ guac_common_cursor_move(vnc_client->display->cursor, user, x, y); + /* Report mouse position within recording */ + if (vnc_client->recording != NULL) + guac_common_recording_report_mouse(vnc_client->recording, x, y); + /* Send VNC event only if finished connecting */ if (rfb_client != NULL) SendPointerEvent(rfb_client, x, y, mask);