File xrdp-fate319683-allow-vnc-resizing.patch of Package xrdp.15889

Index: b/sesman/sesman.ini
===================================================================
--- a/sesman/sesman.ini	2019-10-12 17:45:30.594432280 +0800
+++ b/sesman/sesman.ini	2019-10-12 17:45:37.222491421 +0800
@@ -55,7 +55,7 @@ IdleTimeLimit=0
 
 ;; Policy - session allocation policy
 ; Type: enum [ "Default" | "UBD" | "UBI" | "UBC" | "UBDI" | "UBDC" ]
-; Default: Xrdp:<User,BitPerPixel> and Xvnc:<User,BitPerPixel,DisplaySize>
+; Default: Xrdp and Xvnc:<User,BitPerPixel>
 ; "UBD" session per <User,BitPerPixel,DisplaySize>
 ; "UBI" session per <User,BitPerPixel,IPAddr>
 ; "UBC" session per <User,BitPerPixel,Connection>
Index: b/sesman/session.c
===================================================================
--- a/sesman/session.c	2019-10-12 17:45:30.598432316 +0800
+++ b/sesman/session.c	2019-10-12 17:45:37.222491421 +0800
@@ -105,9 +105,6 @@ session_get_bydata(const char *name, int
     {
         case SCP_SESSION_TYPE_XVNC: /* 0 */
             type = SESMAN_SESSION_TYPE_XVNC; /* 2 */
-            /* Xvnc cannot resize */
-            policy = (enum SESMAN_CFG_SESS_POLICY)
-                     (policy | SESMAN_CFG_SESS_POLICY_D);
             break;
         case SCP_SESSION_TYPE_XRDP: /* 1 */
             type = SESMAN_SESSION_TYPE_XRDP; /* 1 */
Index: b/vnc/vnc.c
===================================================================
--- a/vnc/vnc.c	2019-10-12 17:45:30.598432316 +0800
+++ b/vnc/vnc.c	2019-10-12 17:49:39.956657294 +0800
@@ -385,7 +385,8 @@ lib_mod_event(struct vnc *v, int msg, lo
             /* FramebufferUpdateRequest */
             init_stream(s, 8192);
             out_uint8(s, 3);
-            out_uint8(s, 0);
+            out_uint8(s, v->incremental);
+            v->incremental = 1;
             x = (param1 >> 16) & 0xffff;
             out_uint16_be(s, x);
             y = param1 & 0xffff;
@@ -727,7 +728,24 @@ lib_framebuffer_update(struct vnc *v)
             {
                 v->mod_width = cx;
                 v->mod_height = cy;
-                error = v->server_reset(v, cx, cy, v->mod_bpp);
+            }
+            else if (encoding == 0xfffffecc) /* extended desktop resize */
+            {
+                init_stream(s, 8192);
+                error = trans_force_read_s(v->trans, s, 4);
+                if (error == 0)
+                {
+                    in_uint8(s, k); /* number of screens */
+                    in_uint8s(s, 3);
+                    error = trans_force_read_s(v->trans, s, k * 16);
+                    if (error == 0)
+                    {
+                        in_uint8s(s, k * 16); /* skip screen list */
+                        /* note new dimensions for later */
+                        v->server_width = cx;
+                        v->server_height = cy;
+                    }
+                }
             }
             else
             {
@@ -743,6 +761,15 @@ lib_framebuffer_update(struct vnc *v)
         error = v->server_end_update(v);
     }
 
+    if (v->mod_width != v->server_width || v->mod_height != v->server_height)
+    {
+        /* perform actual resize outside the update */
+        v->mod_width = v->server_width;
+        v->mod_height = v->server_height;
+        error = v->server_reset(v, v->mod_width, v->mod_height, v->mod_bpp);
+        v->incremental = 0;
+    }
+
     if (error == 0)
     {
         if (v->suppress_output == 0)
@@ -750,7 +777,8 @@ lib_framebuffer_update(struct vnc *v)
             /* FramebufferUpdateRequest */
             init_stream(s, 8192);
             out_uint8(s, 3);
-            out_uint8(s, 1);
+            out_uint8(s, v->incremental);
+            v->incremental = 1;
             out_uint16_be(s, 0);
             out_uint16_be(s, 0);
             out_uint16_be(s, v->mod_width);
@@ -1333,11 +1361,12 @@ lib_mod_connect(struct vnc *v)
         init_stream(s, 8192);
         out_uint8(s, 2);
         out_uint8(s, 0);
-        out_uint16_be(s, 4);
+        out_uint16_be(s, 5);
         out_uint32_be(s, 0); /* raw */
         out_uint32_be(s, 1); /* copy rect */
         out_uint32_be(s, 0xffffff11); /* cursor */
         out_uint32_be(s, 0xffffff21); /* desktop size */
+        out_uint32_be(s, 0xfffffecc); /* extended desktop resize */
         v->server_msg(v, "VNC sending encodings", 0);
         s_mark_end(s);
         error = trans_force_write_s(v->trans, s);
@@ -1530,7 +1559,8 @@ lib_mod_suppress_output(struct vnc* v, i
         make_stream(s);
         init_stream(s, 8192);
         out_uint8(s, 3);
-        out_uint8(s, 0);
+        out_uint8(s, v->incremental);
+        v->incremental = 1;
         out_uint16_be(s, 0);
         out_uint16_be(s, 0);
         out_uint16_be(s, v->mod_width);
Index: b/vnc/vnc.h
===================================================================
--- a/vnc/vnc.h	2019-10-12 17:45:30.598432316 +0800
+++ b/vnc/vnc.h	2019-10-12 17:45:37.222491421 +0800
@@ -116,6 +116,7 @@ struct vnc
   int clip_chanid;
   struct stream *clip_data_s;
   int delay_ms;
+  int incremental;
   struct trans *trans;
   int got_guid;
   tui8 guid[16];
openSUSE Build Service is sponsored by