[gtk-vnc] src: add minimal support for extended desktop resize



commit 27e73b8b0f6cbdd63b8ae89039eddd0809605729
Author: Daniel P. Berrangé <dan berrange com>
Date:   Tue Dec 8 16:42:32 2020 +0000

    src: add minimal support for extended desktop resize
    
    This processes extended desktop resize frame buffer updates in the
    same way as the traditional desktop resize updates.
    
    Signed-off-by: Daniel P. Berrangé <berrange redhat com>

 src/vncconnection.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/vncconnection.h |  1 +
 src/vncdisplay.c    |  1 +
 3 files changed, 67 insertions(+)
---
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 8feb32b..87cbf2e 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -112,6 +112,20 @@ typedef enum {
     VNC_CONNECTION_XVP_INIT = 1,
 } VncConnectionXVPCode;
 
+typedef enum {
+    VNC_CONNECTION_RESIZE_TRIGGER_SERVER = 0,
+    VNC_CONNECTION_RESIZE_TRIGGER_THIS_CLIENT = 1,
+    VNC_CONNECTION_RESIZE_TRIGGER_OTHER_CLIENT = 2,
+} VncConnectionResizeTrigger;
+
+typedef enum {
+    VNC_CONNECTION_RESIZE_STATUS_OK = 0,
+    VNC_CONNECTION_RESIZE_STATUS_ADMIN_PROHIBITED = 1,
+    VNC_CONNECTION_RESIZE_STATUS_OUT_OF_RESOURCES = 2,
+    VNC_CONNECTION_RESIZE_STATUS_INVALID_LAOUT = 3,
+    VNC_CONNECTION_RESIZE_STATUS_FORWARDED = 4,
+}  VncConnectionResizeStatus;
+
 typedef void vnc_connection_rich_cursor_blt_func(VncConnection *conn, guint8 *, guint8 *,
                                                  guint8 *, int, guint16, guint16);
 
@@ -2922,6 +2936,54 @@ static void vnc_connection_resize(VncConnection *conn)
     vnc_connection_emit_main_context(conn, VNC_DESKTOP_RESIZE, &sigdata);
 }
 
+static void vnc_connection_extended_resize(VncConnection *conn, int width, int height,
+                                           int trigger, int status)
+{
+    VncConnectionPrivate *priv = conn->priv;
+    struct signal_data sigdata;
+    guint8 nscreens, i;
+    guint8 pad[3];
+
+    VNC_DEBUG("Desktop extended resize w=%d h=%d trigger=%d status=%d", width, height, trigger, status);
+
+    if (vnc_connection_has_error(conn))
+        return;
+
+    nscreens = vnc_connection_read_u8(conn);
+    vnc_connection_read(conn, pad, sizeof(pad));
+    if (vnc_connection_has_error(conn))
+        return;
+
+    VNC_DEBUG("Reading info for %u screens", nscreens);
+
+    for (i = 0; i < nscreens; i++) {
+        guint32 id;
+        guint16 screenx, screeny, screenwidth, screenheight;
+        guint32 flags;
+
+        id = vnc_connection_read_u32(conn);
+        screenx = vnc_connection_read_u16(conn);
+        screeny = vnc_connection_read_u16(conn);
+        screenwidth = vnc_connection_read_u16(conn);
+        screenheight = vnc_connection_read_u16(conn);
+        flags = vnc_connection_read_u32(conn);
+
+        VNC_DEBUG("Screen id=%u xpos=%d ypos=%d width=%d height=%d flags=%x",
+                  id, screenx, screeny, screenwidth, screenheight, flags);
+    }
+
+    if (vnc_connection_has_error(conn))
+        return;
+
+    priv->width = width;
+    priv->height = height;
+
+    sigdata.params.size.width = width;
+    sigdata.params.size.height = height;
+
+    vnc_connection_emit_main_context(conn, VNC_DESKTOP_RESIZE, &sigdata);
+}
+
 static void vnc_connection_pixel_format(VncConnection *conn)
 {
     VncConnectionPrivate *priv = conn->priv;
@@ -3297,6 +3359,9 @@ static gboolean vnc_connection_framebuffer_update(VncConnection *conn, gint32 et
         priv->height = height;
         vnc_connection_resize(conn);
         break;
+    case VNC_CONNECTION_ENCODING_EXTENDED_DESKTOP_RESIZE:
+        vnc_connection_extended_resize(conn, width, height, x /* trigger */, y /* status */);
+        break;
     case VNC_CONNECTION_ENCODING_POINTER_CHANGE:
         vnc_connection_pointer_type_change(conn, x);
         vnc_connection_resend_framebuffer_update_request(conn);
diff --git a/src/vncconnection.h b/src/vncconnection.h
index 11b0118..02c121e 100644
--- a/src/vncconnection.h
+++ b/src/vncconnection.h
@@ -128,6 +128,7 @@ typedef enum {
     VNC_CONNECTION_ENCODING_LED_STATE = -261,
 
     VNC_CONNECTION_ENCODING_DESKTOP_NAME = -307,
+    VNC_CONNECTION_ENCODING_EXTENDED_DESKTOP_RESIZE = -308,
     VNC_CONNECTION_ENCODING_XVP = -309,
     VNC_CONNECTION_ENCODING_ALPHA_CURSOR = -314,
 } VncConnectionEncoding;
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index 2870fd0..d853d60 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -1686,6 +1686,7 @@ static void on_initialized(VncConnection *conn G_GNUC_UNUSED,
                             VNC_CONNECTION_ENCODING_XVP,
                             VNC_CONNECTION_ENCODING_EXT_KEY_EVENT,
                             VNC_CONNECTION_ENCODING_LED_STATE,
+                            VNC_CONNECTION_ENCODING_EXTENDED_DESKTOP_RESIZE,
                             VNC_CONNECTION_ENCODING_DESKTOP_RESIZE,
                             VNC_CONNECTION_ENCODING_DESKTOP_NAME,
                             VNC_CONNECTION_ENCODING_LAST_RECT,


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