Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Mouse event rate limit #878

Closed
wants to merge 4 commits into from

3 participants

@wavesoft

Hello guys,

recently I had the need to limit the mouse movement event rate because I was using a not-so-powerful machine (namely the all-famous Raspberry Pi). The problem was that in high resolutions, when too many mouse events were piled up, I had to wait for all the bitmap updates to arrive and it took forever. (Using the -mouse-motion was not an option).

The patch I am submitting will add the /mouse-rate: command-line parameter, with rate defaulting to 25. Mouse movement events that are not within that rate will be dropped.

With about 15 events/second I managed to get a pretty decent responsiveness of panning camera / rotating objects on high resolutions (1680x1050 full-screen) on my Pi, using CAD software.

I hope you find it helpful ;)

@bmiklautz bmiklautz was assigned
@freerdp-bot
Collaborator

Can one of the members verify this patch?

@freerdp-bot
Collaborator

Can one of the members verify this patch?

@bmiklautz
Owner

This is in fact very helpful - less mouse events means less graphic updates and therefor less load and traffic.

@wavesoft even if it's long standing thanks.

I'll close this pull, rebase and update it that it can be merged on the current master.

@bmiklautz bmiklautz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 5, 2013
  1. @wavesoft
  2. @wavesoft
  3. @wavesoft
Commits on Jan 26, 2013
  1. Merge remote branch 'upstream/master'

    userD480 authored
This page is out of date. Refresh to see the latest.
View
17 client/X11/xf_event.c
@@ -116,6 +116,8 @@ static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app)
rdpInput* input;
int x, y;
Window childWindow;
+ struct timeval tv;
+ suseconds_t ts;
input = xfi->instance->input;
x = event->xmotion.x;
@@ -139,7 +141,20 @@ static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app)
RootWindowOfScreen(xfi->screen),
x, y, &x, &y, &childWindow);
}
-
+
+ /* Limit event rate */
+ gettimeofday(&tv,NULL);
+ ts = tv.tv_usec;
+ if (ts < xfi->us_last_mouse_event)
+ ts += 1000000;
+ if ( ts < (xfi->us_last_mouse_event + xfi->us_mouse_event_delay ))
+ {
+ return TRUE;
+ } else
+ {
+ xfi->us_last_mouse_event = tv.tv_usec;
+ }
+
input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);
if (xfi->fullscreen)
View
2  client/X11/xfreerdp.c
@@ -308,6 +308,8 @@ void xf_create_window(xfInfo* xfi)
xfi->attribs.colormap = xfi->colormap;
xfi->attribs.bit_gravity = NorthWestGravity;
xfi->attribs.win_gravity = NorthWestGravity;
+
+ xfi->us_mouse_event_delay = 1000000 / xfi->instance->settings->MouseEventRate;
if (xfi->instance->settings->WindowTitle != NULL)
{
View
4 client/X11/xfreerdp.h
@@ -31,6 +31,7 @@
#include <freerdp/gdi/region.h>
#include <freerdp/rail/rail.h>
#include <freerdp/cache/cache.h>
+#include <sys/time.h>
typedef struct xf_info xfInfo;
@@ -142,6 +143,9 @@ struct xf_info
void* nsc_context;
void* xv_context;
void* clipboard_context;
+
+ unsigned int us_mouse_event_delay;
+ suseconds_t us_last_mouse_event;
Atom _NET_WM_ICON;
Atom _MOTIF_WM_HINTS;
View
5 client/common/cmdline.c
@@ -103,6 +103,7 @@ COMMAND_LINE_ARGUMENT_A args[] =
{ "encryption", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "encryption (hack!)" },
{ "grab-keyboard", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "grab keyboard" },
{ "mouse-motion", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "mouse-motion" },
+ { "mouse-rate", COMMAND_LINE_VALUE_REQUIRED, "<number>", NULL, NULL, -1, NULL, "Mouse events rate (evets/sec)" },
{ "parent-window", COMMAND_LINE_VALUE_REQUIRED, "<window id>", NULL, NULL, -1, NULL, "Parent window id" },
{ "bitmap-cache", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "bitmap cache" },
{ "offscreen-cache", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "offscreen bitmap cache" },
@@ -1264,6 +1265,10 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
{
settings->MouseMotion = arg->Value ? TRUE : FALSE;
}
+ CommandLineSwitchCase(arg, "mouse-rate")
+ {
+ settings->MouseEventRate = atoi(arg->Value);
+ }
CommandLineSwitchCase(arg, "parent-window")
{
settings->ParentWindowId = strtol(arg->Value, NULL, 0);
View
4 include/freerdp/settings.h
@@ -967,6 +967,10 @@ struct rdp_settings
/* Extensions */
ALIGN64 int num_extensions; /* */
ALIGN64 struct rdp_ext_set extensions[16]; /* */
+
+ /* Optimizations */
+ ALIGN64 UINT32 MouseEventRate;
+
};
typedef struct rdp_settings rdpSettings;
View
1  libfreerdp/core/settings.c
@@ -385,6 +385,7 @@ rdpSettings* freerdp_settings_new(void* instance)
gethostname(settings->ClientHostname, 31);
settings->ClientHostname[31] = 0;
settings->MouseMotion = TRUE;
+ settings->MouseEventRate = 25;
settings->ClientAutoReconnectCookie = (ARC_CS_PRIVATE_PACKET*) malloc(sizeof(ARC_CS_PRIVATE_PACKET));
settings->ServerAutoReconnectCookie = (ARC_SC_PRIVATE_PACKET*) malloc(sizeof(ARC_SC_PRIVATE_PACKET));
Something went wrong with that request. Please try again.