Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormyheroyuki <myheroyuki@outlook.com>2023-09-04 15:00:48 +0300
committermyheroyuki <myheroyuki@outlook.com>2023-09-04 15:00:48 +0300
commit3a6cf424971820032faddb854baa9a9b5824ab79 (patch)
treee964b00b14c78a8301219fa8ba9c98ae89168690 /plugins
parentbbf37ec14cefad6609157614d7c24ced7f3fe9ed (diff)
[REM-2850] Add ability to automatically move mouse to keep RDP connections alive
Diffstat (limited to 'plugins')
-rw-r--r--plugins/rdp/rdp_event.c21
-rw-r--r--plugins/rdp/rdp_event.h1
-rw-r--r--plugins/rdp/rdp_plugin.c28
-rw-r--r--plugins/rdp/rdp_plugin.h2
4 files changed, 52 insertions, 0 deletions
diff --git a/plugins/rdp/rdp_event.c b/plugins/rdp/rdp_event.c
index 65fda59b7..95fdfc14d 100644
--- a/plugins/rdp/rdp_event.c
+++ b/plugins/rdp/rdp_event.c
@@ -558,11 +558,30 @@ static void remmina_rdp_event_reverse_translate_pos_reverse(RemminaProtocolWidge
}
}
+void remmina_rdp_mouse_jitter(RemminaProtocolWidget *gp){
+ TRACE_CALL(__func__);
+ RemminaPluginRdpEvent rdp_event = { 0 };
+ RemminaFile *remminafile;
+ rfContext *rfi = GET_PLUGIN_DATA(gp);
+
+ remminafile = remmina_plugin_service->protocol_plugin_get_file(gp);
+ if (remmina_plugin_service->file_get_int(remminafile, "viewonly", FALSE))
+ return;
+
+ rdp_event.type = REMMINA_RDP_EVENT_TYPE_MOUSE;
+ rdp_event.mouse_event.flags = PTR_FLAGS_MOVE;
+ rdp_event.mouse_event.extended = FALSE;
+ rdp_event.mouse_event.x = rfi->last_x;
+ rdp_event.mouse_event.y = rfi->last_y;
+ remmina_rdp_event_event_push(gp, &rdp_event);
+}
+
static gboolean remmina_rdp_event_on_motion(GtkWidget *widget, GdkEventMotion *event, RemminaProtocolWidget *gp)
{
TRACE_CALL(__func__);
RemminaPluginRdpEvent rdp_event = { 0 };
RemminaFile *remminafile;
+ rfContext *rfi = GET_PLUGIN_DATA(gp);
remminafile = remmina_plugin_service->protocol_plugin_get_file(gp);
if (remmina_plugin_service->file_get_int(remminafile, "viewonly", FALSE))
@@ -573,6 +592,8 @@ static gboolean remmina_rdp_event_on_motion(GtkWidget *widget, GdkEventMotion *e
rdp_event.mouse_event.extended = FALSE;
remmina_rdp_event_translate_pos(gp, event->x, event->y, &rdp_event.mouse_event.x, &rdp_event.mouse_event.y);
+ rfi->last_x = rdp_event.mouse_event.x;
+ rfi->last_y = rdp_event.mouse_event.y;
remmina_rdp_event_event_push(gp, &rdp_event);
return TRUE;
diff --git a/plugins/rdp/rdp_event.h b/plugins/rdp/rdp_event.h
index e1d885f1c..8a7f08a1a 100644
--- a/plugins/rdp/rdp_event.h
+++ b/plugins/rdp/rdp_event.h
@@ -53,5 +53,6 @@ int remmina_rdp_event_queue_ui_sync_retint(RemminaProtocolWidget *gp, RemminaPlu
void *remmina_rdp_event_queue_ui_sync_retptr(RemminaProtocolWidget *gp, RemminaPluginRdpUiObject *ui);
gboolean remmina_rdp_event_on_map(RemminaProtocolWidget *gp);
gboolean remmina_rdp_event_on_unmap(RemminaProtocolWidget *gp);
+void remmina_rdp_mouse_jitter(RemminaProtocolWidget *gp);
G_END_DECLS
diff --git a/plugins/rdp/rdp_plugin.c b/plugins/rdp/rdp_plugin.c
index 4d18132e9..d3fc9121e 100644
--- a/plugins/rdp/rdp_plugin.c
+++ b/plugins/rdp/rdp_plugin.c
@@ -112,6 +112,8 @@
RemminaPluginService *remmina_plugin_service = NULL;
static BOOL gfx_h264_available = FALSE;
+// keep track of last interaction time for keep alive
+static time_t last_time;
/* Compatibility: these functions have been introduced with https://github.com/FreeRDP/FreeRDP/commit/8c5d96784d
* and are missing on older FreeRDP, so we add them here.
@@ -227,6 +229,7 @@ static BOOL rf_process_event_queue(RemminaProtocolWidget *gp)
remminafile = remmina_plugin_service->protocol_plugin_get_file(gp);
while ((event = (RemminaPluginRdpEvent *)g_async_queue_try_pop(rfi->event_queue)) != NULL) {
+ time(&last_time); //update last user interaction time
switch (event->type) {
case REMMINA_RDP_EVENT_TYPE_SCANCODE:
flags = event->key_event.extended ? KBD_FLAGS_EXTENDED : 0;
@@ -993,8 +996,20 @@ static void remmina_rdp_main_loop(RemminaProtocolWidget *gp)
DWORD status;
gchar buf[100];
rfContext *rfi = GET_PLUGIN_DATA(gp);
+ RemminaFile *remminafile = remmina_plugin_service->protocol_plugin_get_file(gp);
+ time_t cur_time, time_diff;
+ int jitter_time = remmina_plugin_service->file_get_int(remminafile, "rdp_mouse_jitter", 0);
+ time(&last_time);
while (!freerdp_shall_disconnect(rfi->instance)) {
+ //move mouse if we've been idle and option is selected
+ time(&cur_time);
+ time_diff = cur_time - last_time;
+ if (jitter_time > 0 && time_diff > jitter_time){
+ last_time = cur_time;
+ remmina_rdp_mouse_jitter(gp);
+ }
+
HANDLE handles[64]={0};
DWORD nCount = freerdp_get_event_handles(rfi->instance->context, &handles[0], 64);
if (rfi->event_handle)
@@ -2734,6 +2749,17 @@ static gpointer security_list[] =
NULL
};
+/* Array of key/value pairs for mouse movement */
+static gpointer mouse_jitter_list[] =
+{
+ "No", N_("No"),
+ "60", N_("Every 1 min"),
+ "180", N_("Every 3 min"),
+ "300", N_("Every 5 min"),
+ "600", N_("Every 10 min"),
+ NULL
+};
+
static gpointer gwtransp_list[] =
{
"http", "HTTP",
@@ -2903,6 +2929,8 @@ static const RemminaProtocolSetting remmina_rdp_advanced_settings[] =
{ REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "vc", N_("Static virtual channel"), FALSE, NULL, N_("<channel>[,<options>]") },
{ REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "rdp2tcp", N_("TCP redirection"), FALSE, NULL, N_("/PATH/TO/rdp2tcp") },
{ REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "rdp_reconnect_attempts", N_("Reconnect attempts number"), FALSE, NULL, N_("The maximum number of reconnect attempts upon an RDP disconnect (default: 20)") },
+ { REMMINA_PROTOCOL_SETTING_TYPE_SELECT, "rdp_mouse_jitter", N_("Move mouse when connection is idle"), FALSE, mouse_jitter_list, NULL },
+
{ REMMINA_PROTOCOL_SETTING_TYPE_ASSISTANCE, "assistance_mode", N_("Attempt to connect in assistance mode"), TRUE, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_CHECK, "preferipv6", N_("Prefer IPv6 AAAA record over IPv4 A record"), TRUE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_CHECK, "shareprinter", N_("Share printers"), TRUE, NULL, NULL },
diff --git a/plugins/rdp/rdp_plugin.h b/plugins/rdp/rdp_plugin.h
index 19b0a609c..9dfa56d87 100644
--- a/plugins/rdp/rdp_plugin.h
+++ b/plugins/rdp/rdp_plugin.h
@@ -380,6 +380,8 @@ struct rf_context {
GAsyncQueue * event_queue;
gint event_pipe[2];
HANDLE event_handle;
+ UINT16 last_x;
+ UINT16 last_y;
rfClipboard clipboard;