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/01/16 18:41:55 UTC

[09/23] guacamole-client git commit: GUACAMOLE-352: Track in-progress composition, ignoring "input" events for a composition which is known to be incomplete.

GUACAMOLE-352: Track in-progress composition, ignoring "input" events for a composition which is known to be incomplete.

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

Branch: refs/heads/master
Commit: 646f9732f38c80cb631af4b421bca7ef4051960f
Parents: fd47d1d
Author: Michael Jumper <mj...@apache.org>
Authored: Sun Dec 17 21:51:19 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Jan 16 09:50:54 2018 -0800

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


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/646f9732/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 4c4b1ba..1df14e2 100644
--- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
+++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
@@ -1232,6 +1232,15 @@ Guacamole.Keyboard = function(element) {
     };
 
     /**
+     * The in-progress composition, if any, such as the intermediate result of
+     * pressing a series of dead keys.
+     *
+     * @private
+     * @type {String}
+     */
+    var inProgressComposition = '';
+
+    /**
      * Handles the given "input" event, typing the data within the input text.
      * If the event is complete (text is provided), handling of "compositionend"
      * events is suspended, as such events may conflict with input events.
@@ -1245,6 +1254,11 @@ Guacamole.Keyboard = function(element) {
         // Only intercept if handler set
         if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
 
+        // Ignore input events which represent the in-progress composition,
+        // as reported by composition events
+        if (e.data === inProgressComposition)
+            return;
+
         // Type all content written
         if (e.data && isComposed(e.data)) {
             element.removeEventListener("compositionend", handleComposition, false);
@@ -1280,6 +1294,14 @@ Guacamole.Keyboard = function(element) {
     element.addEventListener("input", handleInput, false);
     element.addEventListener("compositionend", handleComposition, false);
 
+    element.addEventListener("compositionstart", function resetComposition() {
+        inProgressComposition = '';
+    }, false);
+
+    element.addEventListener("compositionupdate", function updateComposition(e) {
+        inProgressComposition = e.data;
+    }, false);
+
 };
 
 /**