Set size in keyboard layout, migrate to new on-screen keyboard API, update keyboard style.

This commit is contained in:
Michael Jumper
2012-01-19 15:33:59 -08:00
parent 532bbbd107
commit 05318c490a
3 changed files with 63 additions and 75 deletions

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<keyboard lang="en_US" layout="qwerty"> <keyboard lang="en_US" layout="qwerty" size="21">
<row> <row>
<key> <key>
<cap keysym="0xFF1B">Esc</cap> <cap keysym="0xFF1B">Esc</cap>

View File

@@ -119,16 +119,26 @@ var GuacamoleUI = {
}; };
// Show/Hide keyboard // Show/Hide keyboard
var keyboardResizeInterval = null;
GuacamoleUI.buttons.showKeyboard.onclick = function() { GuacamoleUI.buttons.showKeyboard.onclick = function() {
var displayed = GuacamoleUI.containers.keyboard.style.display; var displayed = GuacamoleUI.containers.keyboard.style.display;
if (displayed != "block") { if (displayed != "block") {
GuacamoleUI.containers.keyboard.style.display = "block"; GuacamoleUI.containers.keyboard.style.display = "block";
GuacamoleUI.buttons.showKeyboard.textContent = "Hide Keyboard"; GuacamoleUI.buttons.showKeyboard.textContent = "Hide Keyboard";
// Automatically update size
window.onresize = updateKeyboardSize;
keyboardResizeInterval = window.setInterval(updateKeyboardSize, 30);
updateKeyboardSize();
} }
else { else {
GuacamoleUI.containers.keyboard.style.display = "none"; GuacamoleUI.containers.keyboard.style.display = "none";
GuacamoleUI.buttons.showKeyboard.textContent = "Show Keyboard"; GuacamoleUI.buttons.showKeyboard.textContent = "Show Keyboard";
window.onresize = null;
window.clearInterval(keyboardResizeInterval);
} }
}; };
@@ -225,7 +235,17 @@ var GuacamoleUI = {
// On-screen keyboard // On-screen keyboard
GuacamoleUI.keyboard = new Guacamole.OnScreenKeyboard("layouts/en-us-qwerty.xml"); GuacamoleUI.keyboard = new Guacamole.OnScreenKeyboard("layouts/en-us-qwerty.xml");
GuacamoleUI.containers.keyboard.appendChild(GuacamoleUI.keyboard); GuacamoleUI.containers.keyboard.appendChild(GuacamoleUI.keyboard.getElement());
// Function for automatically updating keyboard size
var lastKeyboardWidth;
function updateKeyboardSize() {
var currentSize = GuacamoleUI.keyboard.getElement().offsetWidth;
if (lastKeyboardWidth != currentSize) {
GuacamoleUI.keyboard.resize(currentSize);
lastKeyboardWidth = currentSize;
}
};
})(); })();
@@ -379,17 +399,13 @@ GuacamoleUI.attach = function(guac) {
GuacamoleUI.clipboard.value = data; GuacamoleUI.clipboard.value = data;
}; };
GuacamoleUI.keyboard.setKeyPressedHandler( GuacamoleUI.keyboard.onkeypress = function(keysym) {
function(keysym) { guac.sendKeyEvent(1, keysym);
guac.sendKeyEvent(1, keysym); };
}
);
GuacamoleUI.keyboard.setKeyReleasedHandler( GuacamoleUI.keyboard.onkeyrelease = function(keysym) {
function(keysym) { guac.sendKeyEvent(0, keysym);
guac.sendKeyEvent(0, keysym); };
}
);
// Send Ctrl-Alt-Delete // Send Ctrl-Alt-Delete
GuacamoleUI.buttons.ctrlAltDelete.onclick = function() { GuacamoleUI.buttons.ctrlAltDelete.onclick = function() {

View File

@@ -17,107 +17,79 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
div#keyboardContainer { #keyboardContainer {
position: fixed;
left: 0px;
bottom: 0px;
text-align: center; text-align: center;
position: fixed;
left: 0;
bottom: 0;
width: 100%; width: 100%;
margin: 0;
padding: 0.5em;
border-top: 1px solid black;
background: #222;
opacity: 0.85;
display: none; display: none;
z-index: 1; z-index: 1;
} }
div.keyboard { .guacamole-keyboard {
font-size: 10pt;
white-space: pre;
border: 1px solid black;
-moz-border-radius: 0.5em;
-webkit-border-radius: 0.5em;
-khtml-border-radius: 0.5em;
border-radius: 0.5em;
background: #222;
cursor: default;
opacity: 0.85;
padding: 0.25em;
margin: 0.25em;
display: inline-block; display: inline-block;
text-align: left; width: 100%;
}
div.key {
margin: 0; margin: 0;
padding: 0; padding: 0;
cursor: default;
width: 5ex; text-align: left;
height: 5ex; vertical-align: middle;
display: inline-block;
text-align: center;
} }
div.cap { .guacamole-keyboard .guacamole-keyboard-key {
display: inline-block;
}
.guacamole-keyboard .guacamole-keyboard-cap {
background: #444;
border: 1px solid #888; border: 1px solid #888;
-moz-border-radius: 0.25em; -moz-border-radius: 0.25em;
-webkit-border-radius: 0.25em; -webkit-border-radius: 0.25em;
-khtml-border-radius: 0.25em; -khtml-border-radius: 0.25em;
border-radius: 0.25em; border-radius: 0.25em;
background: #444;
margin: 0;
padding: 0;
color: white; color: white;
font-family: sans-serif;
font-size: 50%;
text-shadow: 0 0.1em 0.1em black; text-shadow: 0 0.1em 0.1em black;
text-align: center;
width: 4.5ex;
height: 4.5ex;
line-height: 4.5ex;
white-space: pre; white-space: pre;
display: inline-block;
text-align: center;
} }
div.key:hover div.cap { .guacamole-keyboard .guacamole-keyboard-key:hover .guacamole-keyboard-cap {
background: #666; background: #666;
border-color: #666; border-color: #666;
cursor: pointer; cursor: pointer;
} }
div.key.pressed div.cap { .guacamole-keyboard .guacamole-keyboard-key.pressed:hover .guacamole-keyboard-cap {
background: #822; background: #822;
border-color: #D44; border-color: #D44;
} }
div.key.sticky.active div.cap { .guacamole-keyboard .guacamole-keyboard-key.active:hover .guacamole-keyboard-cap {
background: #882; background: #882;
border-color: #DD4; border-color: #DD4;
} }
div.gap { .guacamole-keyboard .guacamole-keyboard-column {
margin: 0; display: inline-block;
padding: 0; text-align: center;
}
width: 5ex;
height: 5ex;
.guacamole-keyboard .guacamole-keyboard-gap {
display: inline-block; display: inline-block;
} }
div.row {
vertical-align: top;
}
div.col {
display: inline-block;
vertical-align: top;
}