From ee1cd17b1866193c3a39749698226e7a27f86342 Mon Sep 17 00:00:00 2001 From: zodiac Date: Tue, 30 Jun 2009 17:14:35 +0000 Subject: [PATCH] Additional fixes for dealing with keyboard layouts that need AltGr as a second level chooser. git-svn-id: https://shellinabox.googlecode.com/svn/trunk@133 0da03de8-d603-11dd-86c2-0f8696b7b6f9 --- config.h | 2 +- configure | 2 +- configure.ac | 2 +- demo/vt100.js | 22 ++++++++++++++++++++-- shellinabox/shell_in_a_box.js | 2 +- shellinabox/vt100.js | 22 ++++++++++++++++++++-- shellinabox/vt100.jspp | 20 +++++++++++++++++++- 7 files changed, 63 insertions(+), 9 deletions(-) diff --git a/config.h b/config.h index dfc4329..035fcc6 100644 --- a/config.h +++ b/config.h @@ -132,7 +132,7 @@ #define STDC_HEADERS 1 /* Most recent revision number in the version control system */ -#define VCS_REVISION "132" +#define VCS_REVISION "133" /* Version number of package */ #define VERSION "2.8" diff --git a/configure b/configure index c314390..62bf430 100755 --- a/configure +++ b/configure @@ -2037,7 +2037,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -VCS_REVISION=132 +VCS_REVISION=133 cat >>confdefs.h <<_ACEOF diff --git a/configure.ac b/configure.ac index 68e6c7e..cc42ad4 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.57) dnl This is the one location where the authoritative version number is stored AC_INIT(shellinabox, 2.8, markus@shellinabox.com) -VCS_REVISION=132 +VCS_REVISION=133 AC_SUBST(VCS_REVISION) AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}", [Most recent revision number in the version control system]) diff --git a/demo/vt100.js b/demo/vt100.js index b8b7653..603d1ae 100644 --- a/demo/vt100.js +++ b/demo/vt100.js @@ -1500,7 +1500,7 @@ VT100.prototype.toggleBell = function() { }; VT100.prototype.about = function() { - alert("VT100 Terminal Emulator " + "2.8 (revision 132)" + + alert("VT100 Terminal Emulator " + "2.8 (revision 133)" + "\nCopyright 2008-2009 by Markus Gutschke\n" + "For more information check http://shellinabox.com"); }; @@ -1840,6 +1840,20 @@ VT100.prototype.checkComposedKeys = function(event) { }; VT100.prototype.fixEvent = function(event) { + // Some browsers report AltGR as a combination of ALT and CTRL. As AltGr + // is used as a second-level selector, clear the modifier bits before + // handling the event. + if (event.ctrlKey && event.altKey) { + var fake = [ ]; + fake.charCode = event.charCode; + fake.keyCode = event.keyCode; + fake.ctrlKey = false; + fake.shiftKey = event.shiftKey; + fake.altKey = false; + fake.metaKey = event.metaKey; + return fake; + } + // Some browsers fail to translate keys, if both shift and alt/meta is // pressed at the same time. We try to translate those cases, but that // only works for US keyboard layouts. @@ -1939,7 +1953,11 @@ VT100.prototype.keyDown = function(event) { // In fact, we see them, but we cannot stop IE from seeing them, too. if ((event.charCode || event.keyCode) && ((alphNumKey && (event.ctrlKey || event.altKey || event.metaKey) && - !event.shiftKey) || + !event.shiftKey && + // Some browsers signal AltGR as both CTRL and ALT. Do not try to + // interpret this sequence ourselves, as some keyboard layouts use + // it for second-level layouts. + !(event.ctrlKey && event.altKey)) || this.catchModifiersEarly && normalKey && !alphNumKey && (event.ctrlKey || event.altKey || event.metaKey) || !normalKey)) { diff --git a/shellinabox/shell_in_a_box.js b/shellinabox/shell_in_a_box.js index 4268e78..a248167 100644 --- a/shellinabox/shell_in_a_box.js +++ b/shellinabox/shell_in_a_box.js @@ -355,7 +355,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) { }; ShellInABox.prototype.about = function() { - alert("Shell In A Box version " + "2.8 (revision 132)" + + alert("Shell In A Box version " + "2.8 (revision 133)" + "\nCopyright 2008-2009 by Markus Gutschke\n" + "For more information check http://shellinabox.com" + (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ? diff --git a/shellinabox/vt100.js b/shellinabox/vt100.js index b8b7653..603d1ae 100644 --- a/shellinabox/vt100.js +++ b/shellinabox/vt100.js @@ -1500,7 +1500,7 @@ VT100.prototype.toggleBell = function() { }; VT100.prototype.about = function() { - alert("VT100 Terminal Emulator " + "2.8 (revision 132)" + + alert("VT100 Terminal Emulator " + "2.8 (revision 133)" + "\nCopyright 2008-2009 by Markus Gutschke\n" + "For more information check http://shellinabox.com"); }; @@ -1840,6 +1840,20 @@ VT100.prototype.checkComposedKeys = function(event) { }; VT100.prototype.fixEvent = function(event) { + // Some browsers report AltGR as a combination of ALT and CTRL. As AltGr + // is used as a second-level selector, clear the modifier bits before + // handling the event. + if (event.ctrlKey && event.altKey) { + var fake = [ ]; + fake.charCode = event.charCode; + fake.keyCode = event.keyCode; + fake.ctrlKey = false; + fake.shiftKey = event.shiftKey; + fake.altKey = false; + fake.metaKey = event.metaKey; + return fake; + } + // Some browsers fail to translate keys, if both shift and alt/meta is // pressed at the same time. We try to translate those cases, but that // only works for US keyboard layouts. @@ -1939,7 +1953,11 @@ VT100.prototype.keyDown = function(event) { // In fact, we see them, but we cannot stop IE from seeing them, too. if ((event.charCode || event.keyCode) && ((alphNumKey && (event.ctrlKey || event.altKey || event.metaKey) && - !event.shiftKey) || + !event.shiftKey && + // Some browsers signal AltGR as both CTRL and ALT. Do not try to + // interpret this sequence ourselves, as some keyboard layouts use + // it for second-level layouts. + !(event.ctrlKey && event.altKey)) || this.catchModifiersEarly && normalKey && !alphNumKey && (event.ctrlKey || event.altKey || event.metaKey) || !normalKey)) { diff --git a/shellinabox/vt100.jspp b/shellinabox/vt100.jspp index 7c59a03..cf02eca 100644 --- a/shellinabox/vt100.jspp +++ b/shellinabox/vt100.jspp @@ -1840,6 +1840,20 @@ VT100.prototype.checkComposedKeys = function(event) { }; VT100.prototype.fixEvent = function(event) { + // Some browsers report AltGR as a combination of ALT and CTRL. As AltGr + // is used as a second-level selector, clear the modifier bits before + // handling the event. + if (event.ctrlKey && event.altKey) { + var fake = [ ]; + fake.charCode = event.charCode; + fake.keyCode = event.keyCode; + fake.ctrlKey = false; + fake.shiftKey = event.shiftKey; + fake.altKey = false; + fake.metaKey = event.metaKey; + return fake; + } + // Some browsers fail to translate keys, if both shift and alt/meta is // pressed at the same time. We try to translate those cases, but that // only works for US keyboard layouts. @@ -1939,7 +1953,11 @@ VT100.prototype.keyDown = function(event) { // In fact, we see them, but we cannot stop IE from seeing them, too. if ((event.charCode || event.keyCode) && ((alphNumKey && (event.ctrlKey || event.altKey || event.metaKey) && - !event.shiftKey) || + !event.shiftKey && + // Some browsers signal AltGR as both CTRL and ALT. Do not try to + // interpret this sequence ourselves, as some keyboard layouts use + // it for second-level layouts. + !(event.ctrlKey && event.altKey)) || this.catchModifiersEarly && normalKey && !alphNumKey && (event.ctrlKey || event.altKey || event.metaKey) || !normalKey)) {