[gtk-vnc] Clamp cursor hot-pixel to be within cursor region



commit 65e2d1cd25dc9a339d75b9ad723d28df51437aab
Author: Daniel P. Berrange <berrange redhat com>
Date:   Wed Feb 8 12:43:27 2017 +0000

    Clamp cursor hot-pixel to be within cursor region
    
    Some broken VNC servers send hot-pixel outside bounds of the
    cursor. We could disconnect and report an error, but it is
    more user friendly to just clamp the hot pixel coords
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775394
    
    Signed-off-by: Daniel P. Berrange <berrange redhat com>

 src/vncconnection.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 1c1636f..19dbfee 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -2997,7 +2997,7 @@ static void vnc_connection_rich_cursor_blt(VncConnection *conn, guint8 *pixbuf,
     priv->rich_cursor_blt(conn, pixbuf, image, mask, pitch, width, height);
 }
 
-static void vnc_connection_rich_cursor(VncConnection *conn, int x, int y, int width, int height)
+static void vnc_connection_rich_cursor(VncConnection *conn, guint16 x, guint16 y, guint16 width, guint16 
height)
 {
     VncConnectionPrivate *priv = conn->priv;
     struct signal_data sigdata;
@@ -3029,6 +3029,16 @@ static void vnc_connection_rich_cursor(VncConnection *conn, int x, int y, int wi
         g_free(image);
         g_free(mask);
 
+        /* Some broken VNC servers send hot-pixel outside
+         * bounds of the cursor. We could disconnect and
+         * report an error, but it is more user friendly
+         * to just clamp the hot pixel coords
+         */
+        if (x >= width)
+            x = width - 1;
+        if (y >= height)
+            y = height - 1;
+
         priv->cursor = vnc_cursor_new(pixbuf, x, y, width, height);
     }
 
@@ -3040,7 +3050,7 @@ static void vnc_connection_rich_cursor(VncConnection *conn, int x, int y, int wi
     vnc_connection_emit_main_context(conn, VNC_CURSOR_CHANGED, &sigdata);
 }
 
-static void vnc_connection_xcursor(VncConnection *conn, int x, int y, int width, int height)
+static void vnc_connection_xcursor(VncConnection *conn, guint16 x, guint16 y, guint16 width, guint16 height)
 {
     VncConnectionPrivate *priv = conn->priv;
     struct signal_data sigdata;
@@ -3084,6 +3094,16 @@ static void vnc_connection_xcursor(VncConnection *conn, int x, int y, int width,
         g_free(data);
         g_free(mask);
 
+        /* Some broken VNC servers send hot-pixel outside
+         * bounds of the cursor. We could disconnect and
+         * report an error, but it is more user friendly
+         * to just clamp the hot pixel coords
+         */
+        if (x >= width)
+            x = width - 1;
+        if (y >= height)
+            y = height - 1;
+
         priv->cursor = vnc_cursor_new(pixbuf, x, y, width, height);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]