diff options
author | binary-manu <47382117+binary-manu@users.noreply.github.com> | 2021-06-07 21:55:13 +0200 |
---|---|---|
committer | binary-manu <47382117+binary-manu@users.noreply.github.com> | 2021-06-07 21:58:15 +0200 |
commit | 35452edc5a9a682d6169a96fb1aff2eaf066d55f (patch) | |
tree | 47eaf975103af8d8c0d2c27dbe4dc06b04bf12c1 | |
parent | 17af3651d4b6aab67c283896863ea216ace62c47 (diff) | |
download | tigervnc-35452edc5a9a682d6169a96fb1aff2eaf066d55f.tar.gz tigervnc-35452edc5a9a682d6169a96fb1aff2eaf066d55f.zip |
Handle AltGr + accented letter key combo on Windows
-rw-r--r-- | java/com/tigervnc/vncviewer/Viewport.java | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java index 16ba7d72..43316034 100644 --- a/java/com/tigervnc/vncviewer/Viewport.java +++ b/java/com/tigervnc/vncviewer/Viewport.java @@ -524,23 +524,32 @@ class Viewport extends JPanel implements ActionListener { // that off. But AltGr shows up as Ctrl_L+Alt_R in Windows, so // construct a new KeyEvent that uses a proper AltGraph for the // symbol lookup. - if (VncViewer.os.startsWith("windows")) { - if (downKeySym.containsValue(XK_Control_L) && - downKeySym.containsValue(XK_Alt_R)) { - int mask = ev.getModifiers(); - mask &= ~CTRL_MASK; - mask &= ~ALT_MASK; - mask |= ALT_GRAPH_MASK; - AWTKeyStroke ks = - AWTKeyStroke.getAWTKeyStroke(KeyMap.get_keycode_fallback_extended(ev), mask); - ev = new KeyEvent((JComponent)ev.getSource(), ev.getID(), - ev.getWhen(), mask, KeyMap.get_keycode_fallback_extended(ev), - ks.getKeyChar(), ev.getKeyLocation()); - } + int keySym; + if (VncViewer.os.startsWith("windows") && + downKeySym.containsValue(XK_Control_L) && + downKeySym.containsValue(XK_Alt_R)) { + int mask = ev.getModifiers(); + mask &= ~CTRL_MASK; + mask &= ~ALT_MASK; + mask |= ALT_GRAPH_MASK; + AWTKeyStroke ks = + AWTKeyStroke.getAWTKeyStroke(KeyMap.get_keycode_fallback_extended(ev), mask); + // The mask manipulations above break key combinations involving AltGr + // and a key with an accented letter on some keyboard layouts (i.e. IT). + // So the code should first try the modified event, but if it returns no + // symbol, the original event should be used. + final KeyEvent winev = new KeyEvent((JComponent)ev.getSource(), ev.getID(), + ev.getWhen(), mask, KeyMap.get_keycode_fallback_extended(ev), + ks.getKeyChar(), ev.getKeyLocation()); + keySym = KeyMap.vkey_to_keysym(winev); + if (keySym == KeyMap.NoSymbol) + keySym = KeyMap.vkey_to_keysym(ev); + else + ev = winev; + } else { + keySym = KeyMap.vkey_to_keysym(ev); } - int keySym = KeyMap.vkey_to_keysym(ev); - if (keySym == KeyMap.NoSymbol) vlog.error("No symbol for virtual key 0x%016x", keyCode); |