Override implicit focus transfer when "F10" key is pressed
Java L&F has pre-defined hook that transfers the focus to the
menu of the RootPane. Since the viewer doesn't have a menu
this just causes a loss of focus and subsequent unexpected
behavior of keyboard and mouse.
diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java
index 72d6160..a588f0f 100644
--- a/java/com/tigervnc/vncviewer/Viewport.java
+++ b/java/com/tigervnc/vncviewer/Viewport.java
@@ -102,6 +102,16 @@
releaseDownKeys();
}
});
+ Action action = new AbstractAction() {
+ public void actionPerformed(ActionEvent e) { }
+ };
+ KeyStroke f10 = KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0);
+ getInputMap(JComponent.WHEN_FOCUSED).put(f10, "requestFocus");
+ getActionMap().put("requestFocus", new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ requestFocusInWindow();
+ }
+ });
setFocusTraversalKeysEnabled(false);
setFocusable(true);