diff --git a/src/guacenc/cursor.c b/src/guacenc/cursor.c index 4883ac10..d67e9461 100644 --- a/src/guacenc/cursor.c +++ b/src/guacenc/cursor.c @@ -26,8 +26,7 @@ guacenc_cursor* guacenc_cursor_alloc() { /* Allocate new cursor */ - guacenc_cursor* cursor = (guacenc_cursor*) calloc(1, - sizeof(guacenc_cursor)); + guacenc_cursor* cursor = (guacenc_cursor*) malloc(sizeof(guacenc_cursor)); if (cursor == NULL) return NULL; @@ -38,6 +37,9 @@ guacenc_cursor* guacenc_cursor_alloc() { return NULL; } + /* Do not initially render cursor, unless it moves */ + cursor->x = cursor->y = -1; + return cursor; } diff --git a/src/guacenc/cursor.h b/src/guacenc/cursor.h index 73dc3c99..89c8fca0 100644 --- a/src/guacenc/cursor.h +++ b/src/guacenc/cursor.h @@ -33,12 +33,16 @@ 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; /** - * 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; diff --git a/src/guacenc/display-flatten.c b/src/guacenc/display-flatten.c index e2fba829..4a86c0d5 100644 --- a/src/guacenc/display-flatten.c +++ b/src/guacenc/display-flatten.c @@ -93,6 +93,10 @@ static int guacenc_display_render_cursor(guacenc_display* display) { 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) */ guacenc_layer* def_layer = guacenc_display_get_layer(display, 0); assert(def_layer != NULL);