You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/10/03 17:34:43 UTC

[1/6] guacamole-client git commit: GUACAMOLE-232: Take best guess of key being pressed/released into account before assuming modifier states need to be resynced.

Repository: guacamole-client
Updated Branches:
  refs/heads/staging/1.0.0 828313541 -> 728cfb1d8


GUACAMOLE-232: Take best guess of key being pressed/released into account before assuming modifier states need to be resynced.


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

Branch: refs/heads/staging/1.0.0
Commit: 035813ff0b8938b5fa999b017781a0548e7b710d
Parents: 8283135
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Oct 2 22:18:17 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Oct 2 22:18:17 2018 -0700

----------------------------------------------------------------------
 .../src/main/webapp/modules/Keyboard.js         | 59 +++++++++++++++-----
 1 file changed, 44 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/035813ff/guacamole-common-js/src/main/webapp/modules/Keyboard.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
index 022b216..f970651 100644
--- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
+++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
@@ -918,20 +918,45 @@ Guacamole.Keyboard = function Keyboard(element) {
      *
      * @param {Number[]} keysyms
      *     The keysyms which represent the key being updated.
+     *
+     * @param {KeyEvent} keyEvent
+     *     Guacamole's current best interpretation of the key event being
+     *     processed.
      */
-    var updateModifierState = function updateModifierState(remoteState, localState, keysyms) {
+    var updateModifierState = function updateModifierState(remoteState,
+        localState, keysyms, keyEvent) {
+
+        var i;
+
+        // Do not trust changes in modifier state for events directly involving
+        // that modifier: (1) the flag may erroneously be cleared despite
+        // another version of the same key still being held and (2) the change
+        // in flag may be due to the current event being processed, thus
+        // updating things here is at best redundant and at worst incorrect
+        if (keysyms.indexOf(keyEvent.keysym) !== -1)
+            return;
 
         // Release all related keys if modifier is implicitly released
         if (remoteState && localState === false) {
-            for (var i = 0; i < keysyms.length; i++) {
+            for (i = 0; i < keysyms.length; i++) {
                 guac_keyboard.release(keysyms[i]);
             }
         }
 
         // Press if modifier is implicitly pressed
-        else if (!remoteState && localState)
+        else if (!remoteState && localState) {
+
+            // Verify that modifier flag isn't set due to another version of
+            // the same key being held down
+            for (i = 0; i < keysyms.length; i++) {
+                if (guac_keyboard.pressed[keysyms[i]])
+                    return;
+            }
+
             guac_keyboard.press(keysyms[0]);
 
+        }
+
     };
 
     /**
@@ -942,8 +967,12 @@ Guacamole.Keyboard = function Keyboard(element) {
      * @private
      * @param {KeyboardEvent} e
      *     The keyboard event containing the flags to update.
+     *
+     * @param {KeyEvent} keyEvent
+     *     Guacamole's current best interpretation of the key event being
+     *     processed.
      */
-    var syncModifierStates = function syncModifierStates(e) {
+    var syncModifierStates = function syncModifierStates(e, keyEvent) {
 
         // Get state
         var state = Guacamole.Keyboard.ModifierState.fromKeyboardEvent(e);
@@ -953,31 +982,31 @@ Guacamole.Keyboard = function Keyboard(element) {
             0xFFE9, // Left alt
             0xFFEA, // Right alt
             0xFE03  // AltGr
-        ]);
+        ], keyEvent);
 
         // Resync state of shift
         updateModifierState(guac_keyboard.modifiers.shift, state.shift, [
             0xFFE1, // Left shift
             0xFFE2  // Right shift
-        ]);
+        ], keyEvent);
 
         // Resync state of ctrl
         updateModifierState(guac_keyboard.modifiers.ctrl, state.ctrl, [
             0xFFE3, // Left ctrl
             0xFFE4  // Right ctrl
-        ]);
+        ], keyEvent);
 
         // Resync state of meta
         updateModifierState(guac_keyboard.modifiers.meta, state.meta, [
             0xFFE7, // Left meta
             0xFFE8  // Right meta
-        ]);
+        ], keyEvent);
 
         // Resync state of hyper
         updateModifierState(guac_keyboard.modifiers.hyper, state.hyper, [
             0xFFEB, // Left hyper
             0xFFEC  // Right hyper
-        ]);
+        ], keyEvent);
 
         // Update state
         guac_keyboard.modifiers = state;
@@ -1222,7 +1251,8 @@ Guacamole.Keyboard = function Keyboard(element) {
             else if (e.which) keyCode = e.which;
 
             // Fix modifier states
-            syncModifierStates(e);
+            var keydownEvent = new KeydownEvent(keyCode, e.keyIdentifier, e.key, getEventLocation(e));
+            syncModifierStates(e, keydownEvent);
 
             // Ignore (but do not prevent) the "composition" keycode sent by some
             // browsers when an IME is in use (see: http://lists.w3.org/Archives/Public/www-dom/2010JulSep/att-0182/keyCode-spec.html)
@@ -1230,7 +1260,6 @@ Guacamole.Keyboard = function Keyboard(element) {
                 return;
 
             // Log event
-            var keydownEvent = new KeydownEvent(keyCode, e.keyIdentifier, e.key, getEventLocation(e));
             eventLog.push(keydownEvent);
 
             // Interpret as many events as possible, prevent default if indicated
@@ -1253,10 +1282,10 @@ Guacamole.Keyboard = function Keyboard(element) {
             else if (e.which) charCode = e.which;
 
             // Fix modifier states
-            syncModifierStates(e);
+            var keypressEvent = new KeypressEvent(charCode);
+            syncModifierStates(e, keypressEvent);
 
             // Log event
-            var keypressEvent = new KeypressEvent(charCode);
             eventLog.push(keypressEvent);
 
             // Interpret as many events as possible, prevent default if indicated
@@ -1281,10 +1310,10 @@ Guacamole.Keyboard = function Keyboard(element) {
             else if (e.which) keyCode = e.which;
 
             // Fix modifier states
-            syncModifierStates(e);
+            var keyupEvent = new KeyupEvent(keyCode, e.keyIdentifier, e.key, getEventLocation(e));
+            syncModifierStates(e, keyupEvent);
 
             // Log event, call for interpretation
-            var keyupEvent = new KeyupEvent(keyCode, e.keyIdentifier, e.key, getEventLocation(e));
             eventLog.push(keyupEvent);
             interpret_events();
 


[4/6] guacamole-client git commit: GUACAMOLE-232: Track whether keys were pressed implicitly. Automatically release all keys if only implicitly pressed keys remain.

Posted by vn...@apache.org.
GUACAMOLE-232: Track whether keys were pressed implicitly. Automatically release all keys if only implicitly pressed keys remain.


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

Branch: refs/heads/staging/1.0.0
Commit: 3246458a023f685693054303708bcaa13a5cdfbb
Parents: 6f0787f
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Oct 2 22:42:58 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Oct 2 22:42:58 2018 -0700

----------------------------------------------------------------------
 .../src/main/webapp/modules/Keyboard.js         | 48 +++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/3246458a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
index a4ebe36..ea7edf4 100644
--- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
+++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
@@ -616,6 +616,19 @@ Guacamole.Keyboard = function Keyboard(element) {
     this.pressed = {};
 
     /**
+     * The state of every key, indexed by keysym, for strictly those keys whose
+     * status has been indirectly determined thorugh observation of other key
+     * events. If a particular key is implicitly pressed, the value of
+     * implicitlyPressed for that keysym will be true. If a key
+     * is not currently implicitly pressed (the key is not pressed OR the state
+     * of the key is explicitly known), it will not be defined.
+     *
+     * @private
+     * @tyle {Object.<Number, Boolean>}
+     */
+    var implicitlyPressed = {};
+
+    /**
      * The last result of calling the onkeydown handler for each key, indexed
      * by keysym. This is used to prevent/allow default actions for key events,
      * even when the onkeydown handler cannot be called again because the key
@@ -851,6 +864,7 @@ Guacamole.Keyboard = function Keyboard(element) {
             
             // Mark key as released
             delete guac_keyboard.pressed[keysym];
+            delete implicitlyPressed[keysym];
 
             // Stop repeat
             window.clearTimeout(key_repeat_timeout);
@@ -953,7 +967,13 @@ Guacamole.Keyboard = function Keyboard(element) {
                     return;
             }
 
-            guac_keyboard.press(keysyms[0]);
+            // Press key and mark as implicitly pressed (if not already
+            // explicitly pressed)
+            var keysym = keysyms[0];
+            if (!guac_keyboard.pressed(keysym)) {
+                implicitlyPressed[keysym] = true;
+                guac_keyboard.press(keysym);
+            }
 
         }
 
@@ -1014,6 +1034,27 @@ Guacamole.Keyboard = function Keyboard(element) {
     };
 
     /**
+     * Returns whether all currently pressed keys were implicitly pressed. A
+     * key is implicitly pressed if its status was inferred indirectly from
+     * inspection of other key events.
+     *
+     * @private
+     * @returns {Boolean}
+     *     true of all currently pressed keys were implicitly pressed, false
+     *     otherwise.
+     */
+    var isStateImplicit = function isStateImplicit() {
+
+        for (var keysym in guac_keyboard.pressed) {
+            if (!implicitlyPressed[keysym])
+                return true;
+        }
+
+        return false;
+
+    };
+
+    /**
      * Reads through the event log, removing events from the head of the log
      * when the corresponding true key presses are known (or as known as they
      * can be).
@@ -1036,6 +1077,11 @@ Guacamole.Keyboard = function Keyboard(element) {
             handled_event = interpret_event();
         } while (handled_event !== null);
 
+        // Reset keyboard state if we cannot expect to receive any further
+        // keyup events
+        if (isStateImplicit())
+            guac_keyboard.reset();
+
         return last_event.defaultPrevented;
 
     }


[6/6] guacamole-client git commit: GUACAMOLE-232: Merge address regressions in handling of keyboard modifiers.

Posted by vn...@apache.org.
GUACAMOLE-232: Merge address regressions in handling of keyboard modifiers.


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

Branch: refs/heads/staging/1.0.0
Commit: 728cfb1d860f5b35fe58e29586d47f7d8b4d8113
Parents: 8283135 a57eaa6
Author: Nick Couchman <vn...@apache.org>
Authored: Wed Oct 3 13:34:03 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Wed Oct 3 13:34:03 2018 -0400

----------------------------------------------------------------------
 .../src/main/webapp/modules/Keyboard.js         | 116 ++++++++++++++++---
 1 file changed, 98 insertions(+), 18 deletions(-)
----------------------------------------------------------------------



[5/6] guacamole-client git commit: GUACAMOLE-232: Rely on recentKeysym for keyup only when the guessed key doesn't seem to actually be pressed.

Posted by vn...@apache.org.
GUACAMOLE-232: Rely on recentKeysym for keyup only when the guessed key doesn't seem to actually be pressed.

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

Branch: refs/heads/staging/1.0.0
Commit: a57eaa6b323411f7a216682d38f61f6b92d3b901
Parents: 3246458
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Oct 2 23:01:10 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Oct 2 23:06:04 2018 -0700

----------------------------------------------------------------------
 guacamole-common-js/src/main/webapp/modules/Keyboard.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/a57eaa6b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
index ea7edf4..1c44a64 100644
--- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
+++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
@@ -387,9 +387,13 @@ Guacamole.Keyboard = function Keyboard(element) {
 
         // If key is known from keyCode or DOM3 alone, use that
         this.keysym =  keysym_from_keycode(keyCode, location)
-                    || recentKeysym[keyCode]
                     || keysym_from_key_identifier(key, location); // keyCode is still more reliable for keyup when dead keys are in use
 
+        // Fall back to the most recently pressed keysym associated with the
+        // keyCode if the inferred key doesn't seem to actually be pressed
+        if (!guac_keyboard.pressed[this.keysym])
+            this.keysym = recentKeysym[keyCode] || this.keysym;
+
         // Keyup is as reliable as it will ever be
         this.reliable = true;
 


[2/6] guacamole-client git commit: GUACAMOLE-232: Fall back to using recent keysym only after failing to determine released key by keycode.

Posted by vn...@apache.org.
GUACAMOLE-232: Fall back to using recent keysym only after failing to determine released key by keycode.


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

Branch: refs/heads/staging/1.0.0
Commit: 8c096778bc0235b2059495715fee91c31b719c67
Parents: 035813f
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Oct 2 22:19:15 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Oct 2 22:19:15 2018 -0700

----------------------------------------------------------------------
 guacamole-common-js/src/main/webapp/modules/Keyboard.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/8c096778/guacamole-common-js/src/main/webapp/modules/Keyboard.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
index f970651..83e7944 100644
--- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
+++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
@@ -386,8 +386,8 @@ Guacamole.Keyboard = function Keyboard(element) {
         this.location = location;
 
         // If key is known from keyCode or DOM3 alone, use that
-        this.keysym =  recentKeysym[keyCode]
-                    || keysym_from_keycode(keyCode, location)
+        this.keysym =  keysym_from_keycode(keyCode, location)
+                    || recentKeysym[keyCode]
                     || keysym_from_key_identifier(key, location); // keyCode is still more reliable for keyup when dead keys are in use
 
         // Keyup is as reliable as it will ever be


[3/6] guacamole-client git commit: GUACAMOLE-232: Reset tracking of recent keysym after key is released.

Posted by vn...@apache.org.
GUACAMOLE-232: Reset tracking of recent keysym after key is released.


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

Branch: refs/heads/staging/1.0.0
Commit: 6f0787f0c13d187498ae0055c1963fe922832d19
Parents: 8c09677
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Oct 2 22:19:40 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Oct 2 22:19:40 2018 -0700

----------------------------------------------------------------------
 guacamole-common-js/src/main/webapp/modules/Keyboard.js | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/6f0787f0/guacamole-common-js/src/main/webapp/modules/Keyboard.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
index 83e7944..a4ebe36 100644
--- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
+++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
@@ -1149,6 +1149,7 @@ Guacamole.Keyboard = function Keyboard(element) {
             var keysym = first.keysym;
             if (keysym) {
                 guac_keyboard.release(keysym);
+                delete recentKeysym[first.keyCode];
                 first.defaultPrevented = true;
             }