From 8fb4efa3ff48f590a3dcabd547db3fcbad45b658 Mon Sep 17 00:00:00 2001 From: Brian Hinz Date: Wed, 6 Mar 2013 18:14:54 +0000 Subject: Fixes some regressions introduced in r5056. Losing window focus caused key modifiers to be left in an incorrect state. Special handling of AltGr key was being applied in cases where CTRL_L+ALT_L keys were depressed which also caused the modifiers to be left in an incorrect state. Corrected mapping of CTRL+ALT+SHIFT hotkeys to match F8 menu. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5058 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- java/com/tigervnc/vncviewer/CConn.java | 39 ++++++++-------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) (limited to 'java/com/tigervnc/vncviewer/CConn.java') diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java index b8cbbfef..fe79ce19 100644 --- a/java/com/tigervnc/vncviewer/CConn.java +++ b/java/com/tigervnc/vncviewer/CConn.java @@ -1155,7 +1155,7 @@ public class CConn extends CConnection } public void writeKeyEvent(KeyEvent ev) { - int keysym = 0, keycode, key, location, fakeModifiers = 0; + int keysym = 0, keycode, key, location = 0; if (shuttingDown) return; @@ -1167,7 +1167,7 @@ public class CConn extends CConnection location = ev.getKeyLocation(); vlog.debug((ev.isActionKey() ? "action " : "") + "key " + - (down ? "PRESS" : "release") + " code " + keycode + + (down ? "press" : "release") + " code " + keycode + " location " + location + " ASCII " + key); if (!ev.isActionKey()) { @@ -1210,6 +1210,9 @@ public class CConn extends CConnection else keysym = Keysyms.Clear; break; case KeyEvent.VK_CONTROL: + // Suppress CTRL+ALT when AltGr is pressed + if (ev.isAltGraphDown()) + return; if (down) modifiers |= Event.CTRL_MASK; else @@ -1219,6 +1222,9 @@ public class CConn extends CConnection else keysym = Keysyms.Control_L; break; case KeyEvent.VK_ALT: + // Suppress CTRL+ALT when AltGr is pressed + if (ev.isAltGraphDown()) + return; if (down) modifiers |= Event.ALT_MASK; else @@ -1246,13 +1252,7 @@ public class CConn extends CConnection else keysym = Keysyms.Meta_L; break; default: - if (ev.isControlDown() && ev.isAltDown()) { - // Handle AltGr key on international keyboards - if ((keycode >= 32 && keycode <= 126) || - (keycode >= 160 && keycode <= 255)) - key = keycode; - fakeModifiers |= Event.ALT_MASK | Event.CTRL_MASK; - } else if (ev.isControlDown()) { + if (ev.isControlDown()) { // For CTRL-, CTRL is sent separately, so just send . if ((key >= 1 && key <= 26 && !ev.isShiftDown()) || // CTRL-{, CTRL-|, CTRL-} also map to ASCII 96-127 @@ -1360,28 +1360,7 @@ public class CConn extends CConnection } } - if (fakeModifiers != 0) { - if ((fakeModifiers & Event.CTRL_MASK) != 0) { - vlog.debug("Fake L Ctrl raised"); - writeKeyEvent(Keysyms.Control_L, false); - } - if ((modifiers & Event.ALT_MASK) != 0) { - vlog.debug("Fake R Alt raised"); - writeKeyEvent(Keysyms.Alt_R, false); - } - } writeKeyEvent(keysym, down); - if (fakeModifiers != 0) { - if ((fakeModifiers & Event.CTRL_MASK) != 0) { - vlog.debug("Fake L Ctrl pressed"); - writeKeyEvent(Keysyms.Control_L, true); - } - if ((modifiers & Event.ALT_MASK) != 0) { - vlog.debug("Fake R Alt pressed"); - writeKeyEvent(Keysyms.Alt_R, true); - } - fakeModifiers = 0; - } } -- cgit v1.2.3