Adding a layer should not remove ALL contents of display (the on-screen keyboard...
authorMichael Jumper <zhangmaike@users.sourceforge.net>
Thu, 17 Feb 2011 10:05:36 +0000 (02:05 -0800)
committerMichael Jumper <zhangmaike@users.sourceforge.net>
Thu, 17 Feb 2011 10:05:36 +0000 (02:05 -0800)
src/main/resources/guacamole.js

index 4208eb4..d24f5a0 100644 (file)
@@ -476,18 +476,25 @@ function GuacamoleClient(display, tunnelURL) {
                 layer = new Layer(displayWidth, displayHeight);
                 layers[index] = layer;
 
-                // Remove all children
-                display.innerHTML = "";
-
-                // Add existing layers in order
+                // (Re)-add existing layers in order
                 for (var i=0; i<layers.length; i++) {
-                    if (layers[i])
+                    if (layers[i]) {
+
+                        // If already present, remove
+                        if (layers[i].parentNode === display)
+                            display.removeNode(layers[i]);
+
+                        // Add to end
                         display.appendChild(layers[i]);
+                    }
                 }
 
                 // Add cursor layer last
-                if (cursor != null)
+                if (cursor != null) {
+                    if (cursor.parentNode === display)
+                        display.removeNode(cursor);
                     display.appendChild(cursor);
+                }
 
             }
             else {