From de4db7335399d11497ed77dcab550c361b8677d3 Mon Sep 17 00:00:00 2001 From: "Brian P. Hinz" Date: Tue, 16 Jan 2018 23:35:25 -0500 Subject: [PATCH] Restore menukey function to java viewer Menukey was broken by recent refactoring of OptionsDialog --- java/com/tigervnc/vncviewer/MenuKey.java | 4 ++-- java/com/tigervnc/vncviewer/OptionsDialog.java | 2 -- java/com/tigervnc/vncviewer/Viewport.java | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/java/com/tigervnc/vncviewer/MenuKey.java b/java/com/tigervnc/vncviewer/MenuKey.java index 3fd63456..5248b000 100644 --- a/java/com/tigervnc/vncviewer/MenuKey.java +++ b/java/com/tigervnc/vncviewer/MenuKey.java @@ -79,7 +79,7 @@ public class MenuKey if (VncViewer.os.startsWith("mac os x")) return sym.name.replace("_", " "); else - return KeyEvent.getKeyText(sym.keycode); + return KeyEvent.getKeyText(sym.javacode); } public static String getMenuKeyValueStr() { @@ -106,7 +106,7 @@ public class MenuKey } static int getMenuKeyCode() { - int menuKeyCode = VK_F8; + int menuKeyCode = 0x42; @SuppressWarnings({"static"}) String menuKeyStr = diff --git a/java/com/tigervnc/vncviewer/OptionsDialog.java b/java/com/tigervnc/vncviewer/OptionsDialog.java index 186c1fca..d02380cc 100644 --- a/java/com/tigervnc/vncviewer/OptionsDialog.java +++ b/java/com/tigervnc/vncviewer/OptionsDialog.java @@ -979,11 +979,9 @@ class OptionsDialog extends Dialog { sendClipboardCheckbox = new JCheckBox("Send clipboard to server"); JLabel menuKeyLabel = new JLabel("Menu key"); String[] menuKeys = new String[MenuKey.getMenuKeySymbolCount()]; - //String[] menuKeys = new String[MenuKey.getMenuKeySymbolCount()+1]; //menuKeys[0] = "None"; for (int i = 0; i < MenuKey.getMenuKeySymbolCount(); i++) menuKeys[i] = MenuKey.getKeyText(MenuKey.getMenuKeySymbols()[i]); - //menuKeys[i+1] = MenuKey.getKeyText(MenuKey.getMenuKeySymbols()[i]); menuKeyChoice = new JComboBox(menuKeys); inputPanel.add(viewOnlyCheckbox, diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java index 6fff9b4f..1ce411c5 100644 --- a/java/com/tigervnc/vncviewer/Viewport.java +++ b/java/com/tigervnc/vncviewer/Viewport.java @@ -616,6 +616,12 @@ class Viewport extends JPanel implements ActionListener { this, ID.ALT, menuAltKey ? EnumSet.of(MENU.TOGGLE, MENU.VALUE) : EnumSet.of(MENU.TOGGLE)); + if (menuKeySym != 0) { + String sendMenuKey = String.format("Send %s", menuKey.getValueStr()); + menu_add(contextMenu, sendMenuKey, menuKeyJava, + this, ID.MENUKEY, EnumSet.noneOf(MENU.class)); + } + menu_add(contextMenu, "Send Ctrl-Alt-Del", KeyEvent.VK_D, this, ID.CTRLALTDEL, EnumSet.of(MENU.DIVIDER)); -- 2.39.5