GUACAMOLE-313: Do not render cursor unless mouse has actually moved.

This commit is contained in:
Michael Jumper 2017-11-27 19:32:59 -08:00
parent cafcd90f9f
commit e2455d6f26
3 changed files with 14 additions and 4 deletions

View File

@ -26,8 +26,7 @@
guacenc_cursor* guacenc_cursor_alloc() { guacenc_cursor* guacenc_cursor_alloc() {
/* Allocate new cursor */ /* Allocate new cursor */
guacenc_cursor* cursor = (guacenc_cursor*) calloc(1, guacenc_cursor* cursor = (guacenc_cursor*) malloc(sizeof(guacenc_cursor));
sizeof(guacenc_cursor));
if (cursor == NULL) if (cursor == NULL)
return NULL; return NULL;
@ -38,6 +37,9 @@ guacenc_cursor* guacenc_cursor_alloc() {
return NULL; return NULL;
} }
/* Do not initially render cursor, unless it moves */
cursor->x = cursor->y = -1;
return cursor; return cursor;
} }

View File

@ -33,12 +33,16 @@
typedef struct guacenc_cursor { typedef struct guacenc_cursor {
/** /**
* The current X coordinate of the mouse cursor, in pixels. * The current X coordinate of the mouse cursor, in pixels. Valid values
* are non-negative. Negative values indicate that the cursor should not
* be rendered.
*/ */
int x; int x;
/** /**
* The current Y coordinate of the mouse cursor, in pixels. * The current Y coordinate of the mouse cursor, in pixels. Valid values
* are non-negative. Negative values indicate that the cursor should not
* be rendered.
*/ */
int y; int y;

View File

@ -93,6 +93,10 @@ static int guacenc_display_render_cursor(guacenc_display* display) {
guacenc_cursor* cursor = display->cursor; guacenc_cursor* cursor = display->cursor;
/* Do not render cursor if coordinates are negative */
if (cursor->x < 0 || cursor->y < 0)
return 0;
/* Retrieve default layer (guaranteed to not be NULL) */ /* Retrieve default layer (guaranteed to not be NULL) */
guacenc_layer* def_layer = guacenc_display_get_layer(display, 0); guacenc_layer* def_layer = guacenc_display_get_layer(display, 0);
assert(def_layer != NULL); assert(def_layer != NULL);