]> source.dussan.org Git - tigervnc.git/commitdiff
Override default window manager key bindings better
authorBrian P. Hinz <bphinz@users.sf.net>
Wed, 15 Nov 2017 23:50:15 +0000 (18:50 -0500)
committerBrian P. Hinz <bphinz@users.sf.net>
Thu, 16 Nov 2017 00:02:53 +0000 (19:02 -0500)
java/com/tigervnc/vncviewer/Viewport.java

index a588f0f40c50cd8ea0143125d7dc6b0963422a4f..6fff9b4f0cb217818518c014c9dad5712c3aa87a 100644 (file)
@@ -102,16 +102,15 @@ class Viewport extends JPanel implements ActionListener {
         releaseDownKeys();
       }
     });
-    Action action = new AbstractAction() {
+    // Override default key bindings from L&F
+    getActionMap().put("null", 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();
-      }
     });
+    ArrayList<KeyStroke> keys = new ArrayList<KeyStroke>();
+    keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0, true));
+    keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_ALT, 0, true));
+    for (int i=0; i<keys.size(); i++)
+      getInputMap(JComponent.WHEN_FOCUSED).put(keys.get(i), "null");
 
     setFocusTraversalKeysEnabled(false);
     setFocusable(true);