You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2016/03/20 03:22:03 UTC

[23/50] incubator-guacamole-client git commit: GUAC-1480: Sync local clipboard with received clipboard data if it appears to be due to an in-progress keyboard shortcut.

GUAC-1480: Sync local clipboard with received clipboard data if it appears to be due to an in-progress keyboard shortcut.

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

Branch: refs/heads/master
Commit: a36bc3d9c32e59ccc8f77bf6b3dcbb1f23ed1978
Parents: 5c4b787
Author: Michael Jumper <mi...@guac-dev.org>
Authored: Tue Feb 9 21:59:46 2016 -0800
Committer: Michael Jumper <mi...@guac-dev.org>
Committed: Tue Feb 9 21:59:46 2016 -0800

----------------------------------------------------------------------
 .../app/client/controllers/clientController.js  | 44 +++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/a36bc3d9/guacamole/src/main/webapp/app/client/controllers/clientController.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/client/controllers/clientController.js b/guacamole/src/main/webapp/app/client/controllers/clientController.js
index 2e7fe0d..164d161 100644
--- a/guacamole/src/main/webapp/app/client/controllers/clientController.js
+++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js
@@ -238,8 +238,25 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
      */
     $scope.client = guacClientManager.getManagedClient($routeParams.id, $routeParams.params);
 
+    /**
+     * Map of all currently pressed keys by keysym. If a particular key is
+     * currently pressed, the value stored under that key's keysym within this
+     * map will be true. All keys not currently pressed will not have entries
+     * within this map.
+     *
+     * @type Object.<Number, Boolean>
+     */
     var keysCurrentlyPressed = {};
 
+    /**
+     * Map of all currently pressed keys (by keysym) to the clipboard contents
+     * received from the remote desktop while those keys were pressed. All keys
+     * not currently pressed will not have entries within this map.
+     *
+     * @type Object.<Number, String>
+     */
+    var clipboardDataFromKey = {};
+
     /*
      * Check to see if all currently pressed keys are in the set of menu keys.
      */  
@@ -379,7 +396,19 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
 
     });
 
+    // Watch clipboard for new data, associating it with any pressed keys
+    $scope.$watch('client.clipboardData', function clipboardChanged(data) {
+
+        // Associate new clipboard data with any currently-pressed key
+        for (var keysym in keysCurrentlyPressed)
+            clipboardDataFromKey[keysym] = data;
+
+    });
+
+    // Track pressed keys, opening the Guacamole menu after Ctrl+Alt+Shift
     $scope.$on('guacKeydown', function keydownListener(event, keysym, keyboard) {
+
+        // Record key as pressed
         keysCurrentlyPressed[keysym] = true;   
         
         /* 
@@ -408,11 +437,24 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
                 });
             }
         }
+
     });
 
-    // Listen for broadcasted keyup events and fire the appropriate listeners
+    // Update pressed keys as they are released, synchronizing the clipboard
+    // with any data that appears to have come from those key presses
     $scope.$on('guacKeyup', function keyupListener(event, keysym, keyboard) {
+
+        // Sync local clipboard with any clipboard data received while this
+        // key was pressed (if any)
+        var clipboardData = clipboardDataFromKey[keysym];
+        if (clipboardData) {
+            clipboardService.setLocalClipboard(clipboardData);
+            delete clipboardDataFromKey[keysym];
+        }
+
+        // Mark key as released
         delete keysCurrentlyPressed[keysym];
+
     });
 
     // Update page title when client name is received