diff --git a/guacamole/src/main/webapp/index.xhtml b/guacamole/src/main/webapp/index.xhtml
index a25afdcee..02c8ffd3a 100644
--- a/guacamole/src/main/webapp/index.xhtml
+++ b/guacamole/src/main/webapp/index.xhtml
@@ -91,55 +91,6 @@
- Clipboard
-
-
- Text copied/cut within Guacamole will appear here. Changes to the text will affect the remote clipboard, and will be pastable within the remote desktop. Use the textbox below as an interface between the client and server clipboards.
-
-
-
-
- Settings
-
-
diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js
index 9cca23a73..43a56ec30 100644
--- a/guacamole/src/main/webapp/scripts/client-ui.js
+++ b/guacamole/src/main/webapp/scripts/client-ui.js
@@ -223,6 +223,7 @@ GuacUI.Client = {
"menu" : document.getElementById("menu"),
"menu_title" : document.getElementById("menu-title"),
"display" : document.getElementById("display"),
+ "clipboard" : document.getElementById("clipboard"),
"notification_area" : document.getElementById("notificationArea"),
/* Expected Input Rectangle */
@@ -240,7 +241,7 @@ GuacUI.Client = {
"attachedClient" : null,
"touch" : null,
- "clipboard_integration_enabled" : undefined,
+ "clipboard_integration_enabled" : undefined
};
@@ -805,14 +806,17 @@ GuacUI.Client.updateTitle = function () {
};
/**
- * Sets whether the menu is currently visible.
+ * Sets whether the menu is currently visible. Keyboard is disabled while the
+ * menu is shown.
*
* @param {Boolean} [shown] Whether the menu should be shown. If omitted, this
* function will cause the menu to be shown by default.
*/
GuacUI.Client.showMenu = function(shown) {
- if (shown === false)
+ if (shown === false) {
GuacUI.Client.menu.className = "closed";
+ GuacUI.Client.commitClipboard();
+ }
else {
GuacUI.Client.menu.scrollLeft = 0;
GuacUI.Client.menu.scrollTop = 0;
@@ -961,6 +965,18 @@ GuacUI.Client.getSizeString = function(bytes) {
};
+/**
+ * Commits the current contents of the clipboard textarea to the remote
+ * clipboard and the local Guacamole clipboard shared across connections.
+ */
+GuacUI.Client.commitClipboard = function() {
+
+ // Set value if changed
+ var new_value = GuacUI.Client.clipboard.value;
+ GuacamoleSessionStorage.setItem("clipboard", new_value);
+
+};
+
/**
* Attaches a Guacamole.Client to the client UI, such that Guacamole events
* affect the UI, and local events affect the Guacamole.Client. If a client
@@ -1191,47 +1207,58 @@ GuacUI.Client.attach = function(guac) {
var keyboard = new Guacamole.Keyboard(document);
var show_keyboard_gesture_possible = true;
+ window.kb = keyboard;
+
+ function __send_key(pressed, keysym) {
+
+ // Do not send key if menu shown
+ if (GuacUI.Client.isMenuShown())
+ return true;
+
+ GuacUI.Client.attachedClient.sendKeyEvent(pressed, keysym);
+ return false;
+
+ }
+
keyboard.onkeydown = function (keysym) {
// Only handle key events if client is attached
var guac = GuacUI.Client.attachedClient;
- if (!guac) return;
+ if (!guac) return true;
// Handle Ctrl-shortcuts specifically
if (keyboard.modifiers.ctrl && !keyboard.modifiers.alt && !keyboard.modifiers.shift) {
// Allow event through if Ctrl+C or Ctrl+X
if (keyboard.pressed[0x63] || keyboard.pressed[0x78]) {
- guac.sendKeyEvent(1, keysym);
+ __send_key(1, keysym);
return true;
}
// If Ctrl+V, wait until after paste event (next event loop)
if (keyboard.pressed[0x76]) {
window.setTimeout(function after_paste() {
- guac.sendKeyEvent(1, keysym);
+ __send_key(1, keysym);
}, 10);
return true;
}
}
- // Just send key for all other cases
- guac.sendKeyEvent(1, keysym);
-
// If key is NOT one of the expected keys, gesture not possible
if (keysym !== 0xFFE3 && keysym !== 0xFFE9 && keysym !== 0xFFE1)
show_keyboard_gesture_possible = false;
+ // Send key event
+ return __send_key(1, keysym);
+
};
keyboard.onkeyup = function (keysym) {
// Only handle key events if client is attached
var guac = GuacUI.Client.attachedClient;
- if (!guac) return;
-
- guac.sendKeyEvent(0, keysym);
+ if (!guac) return true;
// If lifting up on shift, toggle menu visibility if rest of gesture
// conditions satisfied
@@ -1250,6 +1277,9 @@ GuacUI.Client.attach = function(guac) {
if (reset_gesture)
show_keyboard_gesture_possible = true;
+ // Send key event
+ return __send_key(0, keysym);
+
};
/**
@@ -1338,10 +1368,10 @@ GuacUI.Client.attach = function(guac) {
};
GuacamoleSessionStorage.addChangeListener(function(name, value) {
- if (name === "clipboard" && GuacUI.Client.attachedClient)
+ if (name === "clipboard" && GuacUI.Client.attachedClient) {
+ GuacUI.Client.clipboard.value = value;
GuacUI.Client.attachedClient.setClipboard(value);
- else if (name === "auto-fit")
- GuacUI.Client.updateDisplayScale();
+ }
});
/**
@@ -1573,6 +1603,21 @@ GuacUI.Client.attach = function(guac) {
}
};
+ /*
+ * Initialize clipboard with current data
+ */
+
+ GuacUI.Client.clipboard.value = GuacamoleSessionStorage.getItem("clipboard", "");
+
+ /*
+ * Update clipboard contents when changed
+ */
+
+ window.onblur =
+ GuacUI.Client.clipboard.onchange = function() {
+ GuacUI.Client.commitClipboard();
+ };
+
// Prevent default on all touch events
document.addEventListener("touchstart", function(e) {
e.preventDefault();
diff --git a/guacamole/src/main/webapp/scripts/root-ui.js b/guacamole/src/main/webapp/scripts/root-ui.js
index 87f3948fa..4de3d357a 100644
--- a/guacamole/src/main/webapp/scripts/root-ui.js
+++ b/guacamole/src/main/webapp/scripts/root-ui.js
@@ -40,7 +40,6 @@ var GuacamoleRootUI = {
"fields": {
"username" : document.getElementById("username"),
"password" : document.getElementById("password"),
- "clipboard" : document.getElementById("clipboard")
},
"buttons": {
@@ -49,11 +48,6 @@ var GuacamoleRootUI = {
"manage" : document.getElementById("manage")
},
- "settings": {
- "auto_fit" : document.getElementById("auto-fit"),
- "disable_sound" : document.getElementById("disable-sound")
- },
-
"views": {
"login" : document.getElementById("login-ui"),
"connections" : document.getElementById("connection-list-ui")
@@ -355,81 +349,6 @@ GuacamoleHistory.onchange = function(id, old_entry, new_entry) {
*/
window.name = "";
-/*
- * Update session state when auto-fit checkbox is changed
- */
-
-GuacamoleRootUI.settings.auto_fit.onchange =
-GuacamoleRootUI.settings.auto_fit.onclick = function() {
-
- GuacamoleSessionStorage.setItem(
- "auto-fit", GuacamoleRootUI.settings.auto_fit.checked);
-
-};
-
-/*
- * Update session state when disable-sound checkbox is changed
- */
-
-GuacamoleRootUI.settings.disable_sound.onchange =
-GuacamoleRootUI.settings.disable_sound.onclick = function() {
-
- GuacamoleSessionStorage.setItem(
- "disable-sound", GuacamoleRootUI.settings.disable_sound.checked);
-
-};
-
-/*
- * Update clipboard contents when changed
- */
-
-window.onblur =
-GuacamoleRootUI.fields.clipboard.onchange = function() {
-
- // Set value if changed
- var new_value = GuacamoleRootUI.fields.clipboard.value;
- GuacamoleSessionStorage.setItem("clipboard", new_value);
-
-};
-
-/*
- * Update element states when session state changes
- */
-
-
-GuacamoleSessionStorage.addChangeListener(function(name, value) {
-
- // Clipboard
- if (name === "clipboard")
- GuacamoleRootUI.fields.clipboard.value = value;
-
- // Auto-fit display
- else if (name === "auto-fit")
- GuacamoleRootUI.fields.auto_fit.checked = value;
-
- // Disable Sound
- else if (name === "disable-sound")
- GuacamoleRootUI.fields.disable_sound.checked = value;
-
-});
-
-/*
- * Initialize clipboard with current data
- */
-
-GuacamoleRootUI.fields.clipboard.value = GuacamoleSessionStorage.getItem("clipboard", "");
-
-/*
- * Initialize auto-fit setting in UI
- */
-
-GuacamoleRootUI.settings.auto_fit.checked = GuacamoleSessionStorage.getItem("auto-fit", true);
-
-/*
- * Initialize disable-sound setting in UI
- */
-GuacamoleRootUI.settings.disable_sound.checked = GuacamoleSessionStorage.getItem("disable-sound", false);
-
/*
* Set handler for logout
*/