GUACAMOLE-1302: Add VNC support for forcing lossless compression.
diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c
index 691e708..a476b2c 100644
--- a/src/protocols/vnc/settings.c
+++ b/src/protocols/vnc/settings.c
@@ -91,6 +91,8 @@
     "wol-broadcast-addr",
     "wol-udp-port",
     "wol-wait-time",
+
+    "force-lossless",
     NULL
 };
 
@@ -373,6 +375,12 @@
      */
     IDX_WOL_WAIT_TIME,
 
+    /**
+     * "true" if all graphical updates for this connection should use lossless
+     * compresion only, "false" or blank otherwise.
+     */
+    IDX_FORCE_LOSSLESS,
+
     VNC_ARGS_COUNT
 };
 
@@ -432,6 +440,11 @@
         guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
                 IDX_COLOR_DEPTH, 0);
 
+    /* Lossless compression */
+    settings->lossless =
+        guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
+                IDX_FORCE_LOSSLESS, false);
+
 #ifdef ENABLE_VNC_REPEATER
     /* Set repeater parameters if specified */
     settings->dest_host =
diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h
index 6d1c657..76139bd 100644
--- a/src/protocols/vnc/settings.h
+++ b/src/protocols/vnc/settings.h
@@ -77,6 +77,12 @@
      */
     bool read_only;
 
+    /**
+     * Whether all graphical updates for this connection should use lossless
+     * compression only.
+     */
+    bool lossless;
+
 #ifdef ENABLE_VNC_REPEATER
     /**
      * The VNC host to connect to, if using a repeater.
diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c
index ade8278..4dcf861 100644
--- a/src/protocols/vnc/vnc.c
+++ b/src/protocols/vnc/vnc.c
@@ -435,6 +435,10 @@
     vnc_client->display = guac_common_display_alloc(client,
             rfb_client->width, rfb_client->height);
 
+    /* Use lossless compression only if requested (otherwise, use default
+     * heuristics) */
+    guac_common_display_set_lossless(vnc_client->display, settings->lossless);
+
     /* If not read-only, set an appropriate cursor */
     if (settings->read_only == 0) {
         if (settings->remote_cursor)