From: binary-manu <47382117+binary-manu@users.noreply.github.com> Date: Mon, 7 Jun 2021 19:55:13 +0000 (+0200) Subject: Handle AltGr + accented letter key combo on Windows X-Git-Tag: v1.11.90~5^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=35452edc5a9a682d6169a96fb1aff2eaf066d55f;p=tigervnc.git Handle AltGr + accented letter key combo on Windows --- 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);