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 2018/01/15 00:55:36 UTC

[02/10] guacamole-client git commit: GUACAMOLE-113: Capture Ctrl-Alt-End keypress in order to do something useful with it.

GUACAMOLE-113: Capture Ctrl-Alt-End keypress in order to do something useful with it.


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

Branch: refs/heads/master
Commit: 6a747d116f84fe55a4b1c6c4496b74879e54bde6
Parents: d73a0ec
Author: Nick Couchman <vn...@apache.org>
Authored: Thu Mar 23 11:56:27 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Wed Jan 3 11:36:14 2018 -0500

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


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/6a747d11/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 88cfaa0..86f6c1a 100644
--- a/guacamole/src/main/webapp/app/client/controllers/clientController.js
+++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js
@@ -72,7 +72,9 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
         ALT_KEYS    = {0xFFE9 : true, 0xFFEA : true, 0xFE03 : true,
                        0xFFE7 : true, 0xFFE8 : true},
         CTRL_KEYS   = {0xFFE3 : true, 0xFFE4 : true},
+        END_KEYS    = {0xFF57 : true, 0xFFB1 : true},
         MENU_KEYS   = angular.extend({}, SHIFT_KEYS, ALT_KEYS, CTRL_KEYS);
+        CAD_KEYS    = angular.extend({}, ALT_KEYS, CTRL_KEYS, END_KEYS);
 
     /**
      * All client error codes handled and passed off for translation. Any error
@@ -288,6 +290,16 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
         return true;
     }
 
+    function checkCADHotkeyActive() {
+        for(var keysym in keysCurrentlyPressed) {
+            if(!CAD_KEYS[keysym]) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
     // Hide menu when the user swipes from the right
     $scope.menuDrag = function menuDrag(inProgress, startX, startY, currentX, currentY, deltaX, deltaY) {
 
@@ -495,12 +507,12 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
         // Record key as pressed
         keysCurrentlyPressed[keysym] = true;   
         
+        var currentKeysPressedKeys = Object.keys(keysCurrentlyPressed);
         /* 
          * If only menu keys are pressed, and we have one keysym from each group,
          * and one of the keys is being released, show the menu. 
          */
         if(checkMenuModeActive()) {
-            var currentKeysPressedKeys = Object.keys(keysCurrentlyPressed);
             
             // Check that there is a key pressed for each of the required key classes
             if(!_.isEmpty(_.pick(SHIFT_KEYS, currentKeysPressedKeys)) &&
@@ -522,6 +534,26 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
             }
         }
 
+        if(checkCADHotkeyActive()) {
+
+            // Check that there is a key pressed for each of the required key classes
+            if(!_.isEmpty(_.pick(ALT_KEYS, currentKeysPressedKeys)) &&
+               !_.isEmpty(_.pick(CTRL_KEYS, currentKeysPressedKeys)) &&
+               !_.isEmpty(_.pick(END_KEYS, currentKeysPressedKeys))
+            ) {
+
+               // Don't send this key event through to the client
+               event.preventDefault();
+
+               // Log the event
+               console.log('We should trigger Ctrl-Alt-Delete here.');
+
+               // Reset the keys pressed
+               keysCurrentlyPressed = {};
+               keyboard.reset();
+            }
+        }
+
     });
 
     // Update pressed keys as they are released, synchronizing the clipboard