GUAC-1164: Add setting for specifying the resize method, if any.

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/8d141184
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/8d141184
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/8d141184

Branch: refs/heads/master
Commit: 8d14118469107153dc0d4e19e0544fcf64a72261
Parents: 67a0a1f
Author: Michael Jumper <[email protected]>
Authored: Wed Mar 16 10:23:21 2016 -0700
Committer: Michael Jumper <[email protected]>
Committed: Wed Mar 16 14:44:16 2016 -0700

----------------------------------------------------------------------
 src/protocols/rdp/rdp.c          | 33 ++++++++++++++-------------
 src/protocols/rdp/rdp_disp.c     | 42 +++++++++++++++++------------------
 src/protocols/rdp/rdp_settings.c | 32 ++++++++++++++++++++++++++
 src/protocols/rdp/rdp_settings.h | 31 ++++++++++++++++++++++++++
 4 files changed, 102 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/8d141184/src/protocols/rdp/rdp.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c
index a19e55b..ab5734f 100644
--- a/src/protocols/rdp/rdp.c
+++ b/src/protocols/rdp/rdp.c
@@ -170,27 +170,30 @@ static int __guac_receive_channel_data(freerdp* rdp_inst, 
int channelId,
 static void guac_rdp_channel_connected(rdpContext* context,
         ChannelConnectedEventArgs* e) {
 
-#ifdef HAVE_RDPSETTINGS_SUPPORTDISPLAYCONTROL
-    /* Store reference to the display update plugin once it's connected */
-    if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) {
+    guac_client* client = ((rdp_freerdp_context*) context)->client;
+    guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
+    guac_rdp_settings* settings = rdp_client->settings;
 
-        DispClientContext* disp = (DispClientContext*) e->pInterface;
+    if (settings->resize_method == GUAC_RESIZE_DISPLAY_UPDATE) {
+#ifdef HAVE_RDPSETTINGS_SUPPORTDISPLAYCONTROL
+        /* Store reference to the display update plugin once it's connected */
+        if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) {
 
-        guac_client* client = ((rdp_freerdp_context*) context)->client;
-        guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
+            DispClientContext* disp = (DispClientContext*) e->pInterface;
 
-        /* Init module with current display size */
-        guac_rdp_disp_set_size(rdp_client->disp, rdp_client->settings,
-                context->instance, guac_rdp_get_width(context->instance),
-                guac_rdp_get_height(context->instance));
+            /* Init module with current display size */
+            guac_rdp_disp_set_size(rdp_client->disp, rdp_client->settings,
+                    context->instance, guac_rdp_get_width(context->instance),
+                    guac_rdp_get_height(context->instance));
 
-        /* Store connected channel */
-        guac_rdp_disp_connect(rdp_client->disp, disp);
-        guac_client_log(client, GUAC_LOG_DEBUG,
-                "Display update channel connected.");
+            /* Store connected channel */
+            guac_rdp_disp_connect(rdp_client->disp, disp);
+            guac_client_log(client, GUAC_LOG_DEBUG,
+                    "Display update channel connected.");
 
-    }
+        }
 #endif
+    }
 
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/8d141184/src/protocols/rdp/rdp_disp.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp_disp.c b/src/protocols/rdp/rdp_disp.c
index c7ea64a..973c301 100644
--- a/src/protocols/rdp/rdp_disp.c
+++ b/src/protocols/rdp/rdp_disp.c
@@ -169,37 +169,37 @@ void guac_rdp_disp_update_size(guac_rdp_disp* disp,
 
     disp->last_request = now;
 
-    if (1) {
+    if (settings->resize_method == GUAC_RESIZE_RECONNECT) {
+
         /* Update settings with new dimensions */
         settings->width = width;
         settings->height = height;
 
         /* Signal reconnect */
         disp->reconnect_needed = 1;
-#ifdef HAVE_FREERDP_DISPLAY_UPDATE_SUPPORT
-        disp->disp = NULL;
-#endif
-        return;
+
     }
 
+    else if (settings->resize_method == GUAC_RESIZE_DISPLAY_UPDATE) {
 #ifdef HAVE_FREERDP_DISPLAY_UPDATE_SUPPORT
-    DISPLAY_CONTROL_MONITOR_LAYOUT monitors[1] = {{
-        .Flags  = 0x1, /* DISPLAYCONTROL_MONITOR_PRIMARY */
-        .Left = 0,
-        .Top = 0,
-        .Width  = width,
-        .Height = height,
-        .PhysicalWidth = 0,
-        .PhysicalHeight = 0,
-        .Orientation = 0,
-        .DesktopScaleFactor = 0,
-        .DeviceScaleFactor = 0
-    }};
-
-    /* Send display update notification if display channel is connected */
-    if (disp->disp != NULL)
-        disp->disp->SendMonitorLayout(disp->disp, 1, monitors);
+        DISPLAY_CONTROL_MONITOR_LAYOUT monitors[1] = {{
+            .Flags  = 0x1, /* DISPLAYCONTROL_MONITOR_PRIMARY */
+            .Left = 0,
+            .Top = 0,
+            .Width  = width,
+            .Height = height,
+            .PhysicalWidth = 0,
+            .PhysicalHeight = 0,
+            .Orientation = 0,
+            .DesktopScaleFactor = 0,
+            .DeviceScaleFactor = 0
+        }};
+
+        /* Send display update notification if display channel is connected */
+        if (disp->disp != NULL)
+            disp->disp->SendMonitorLayout(disp->disp, 1, monitors);
 #endif
+    }
 
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/8d141184/src/protocols/rdp/rdp_settings.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c
index 0e90f4d..7cedb7c 100644
--- a/src/protocols/rdp/rdp_settings.c
+++ b/src/protocols/rdp/rdp_settings.c
@@ -92,6 +92,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
     "recording-path",
     "recording-name",
     "create-recording-path",
+    "resize-method",
 
     NULL
 };
@@ -360,6 +361,12 @@ enum RDP_ARGS_IDX {
     IDX_RECORDING_NAME,
     IDX_CREATE_RECORDING_PATH,
 
+    /**
+     * The method to use to apply screen size changes requested by the user.
+     * Valid values are blank, "display-update", and "reconnect".
+     */
+    IDX_RESIZE_METHOD,
+
     RDP_ARGS_COUNT
 };
 
@@ -696,6 +703,31 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
         guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,
                 IDX_CREATE_RECORDING_PATH, 0);
 
+    /* No resize method */
+    if (strcmp(argv[IDX_RESIZE_METHOD], "") == 0) {
+        guac_user_log(user, GUAC_LOG_INFO, "Resize method: none");
+        settings->resize_method = GUAC_RESIZE_NONE;
+    }
+
+    /* Resize method: "reconnect" */
+    else if (strcmp(argv[IDX_RESIZE_METHOD], "reconnect") == 0) {
+        guac_user_log(user, GUAC_LOG_INFO, "Resize method: reconnect");
+        settings->resize_method = GUAC_RESIZE_RECONNECT;
+    }
+
+    /* Resize method: "display-update" */
+    else if (strcmp(argv[IDX_RESIZE_METHOD], "display-update") == 0) {
+        guac_user_log(user, GUAC_LOG_INFO, "Resize method: display-update");
+        settings->resize_method = GUAC_RESIZE_DISPLAY_UPDATE;
+    }
+
+    /* Default to no resize method if invalid */
+    else {
+        guac_user_log(user, GUAC_LOG_INFO, "Resize method \"%s\" invalid. ",
+                "Defaulting to no resize method.", argv[IDX_RESIZE_METHOD]);
+        settings->resize_method = GUAC_RESIZE_NONE;
+    }
+
     /* Success */
     return settings;
 

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/8d141184/src/protocols/rdp/rdp_settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h
index f4c979a..80c15b9 100644
--- a/src/protocols/rdp/rdp_settings.h
+++ b/src/protocols/rdp/rdp_settings.h
@@ -89,6 +89,32 @@ typedef enum guac_rdp_security {
 } guac_rdp_security;
 
 /**
+ * All supported combinations screen resize methods.
+ */
+typedef enum guac_rdp_resize_method {
+
+    /**
+     * Dynamic resizing of the display will not be attempted.
+     */
+    GUAC_RESIZE_NONE,
+
+    /**
+     * Dynamic resizing will be attempted through sending requests along the
+     * Display Update channel. This will only work with recent versions of
+     * Windows and relatively-recent versions of FreeRDP.
+     */
+    GUAC_RESIZE_DISPLAY_UPDATE,
+
+    /**
+     * Guacamole will automatically disconnect and reconnect to the RDP server
+     * whenever the screen size changes, requesting the new size during
+     * reconnect.
+     */
+    GUAC_RESIZE_RECONNECT
+
+} guac_rdp_resize_method;
+
+/**
  * All settings supported by the Guacamole RDP client.
  */
 typedef struct guac_rdp_settings {
@@ -350,6 +376,11 @@ typedef struct guac_rdp_settings {
      */
     int create_recording_path;
 
+    /**
+     * The method to apply when the user's display changes size.
+     */
+    guac_rdp_resize_method resize_method;
+
 } guac_rdp_settings;
 
 /**

Reply via email to