]> source.dussan.org Git - tigervnc.git/commitdiff
Fixes some regressions introduced in r5056. Losing window focus caused key modifiers...
authorBrian Hinz <bphinz@users.sourceforge.net>
Wed, 6 Mar 2013 18:14:54 +0000 (18:14 +0000)
committerBrian Hinz <bphinz@users.sourceforge.net>
Wed, 6 Mar 2013 18:14:54 +0000 (18:14 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5058 3789f03b-4d11-0410-bbf8-ca57d06f2519

java/com/tigervnc/vncviewer/CConn.java
java/com/tigervnc/vncviewer/DesktopWindow.java
java/com/tigervnc/vncviewer/Viewport.java

index b8cbbfefc49f6444b495bf77fd0bff2438e83a58..fe79ce1970fdc8106dac913445dfe76cf78e3778 100644 (file)
@@ -1155,7 +1155,7 @@ public class CConn extends CConnection
   }
 
   public void writeKeyEvent(KeyEvent ev) {
-    int keysym = 0, keycode, key, location, fakeModifiers = 0;
+    int keysym = 0, keycode, key, location = 0;
 
     if (shuttingDown)
       return;
@@ -1167,7 +1167,7 @@ public class CConn extends CConnection
     location = ev.getKeyLocation();
 
     vlog.debug((ev.isActionKey() ? "action " : "") + "key " +
-               (down ? "PRESS" : "release") + " code " + keycode +
+               (down ? "press" : "release") + " code " + keycode +
                 " location " + location + " ASCII " + key);
 
     if (!ev.isActionKey()) {
@@ -1210,6 +1210,9 @@ public class CConn extends CConnection
         else
           keysym = Keysyms.Clear;  break;
       case KeyEvent.VK_CONTROL:
+        // Suppress CTRL+ALT when AltGr is pressed
+        if (ev.isAltGraphDown())
+          return;
         if (down)
           modifiers |= Event.CTRL_MASK;
         else
@@ -1219,6 +1222,9 @@ public class CConn extends CConnection
         else
           keysym = Keysyms.Control_L;  break;
       case KeyEvent.VK_ALT:
+        // Suppress CTRL+ALT when AltGr is pressed
+        if (ev.isAltGraphDown())
+          return;
         if (down)
           modifiers |= Event.ALT_MASK;
         else
@@ -1246,13 +1252,7 @@ public class CConn extends CConnection
         else
           keysym = Keysyms.Meta_L;  break;
       default:
-        if (ev.isControlDown() && ev.isAltDown()) {
-          // Handle AltGr key on international keyboards
-          if ((keycode >= 32 && keycode <= 126) ||
-              (keycode >= 160 && keycode <= 255))
-            key = keycode;
-            fakeModifiers |= Event.ALT_MASK | Event.CTRL_MASK;
-        } else if (ev.isControlDown()) {
+        if (ev.isControlDown()) {
           // For CTRL-<letter>, CTRL is sent separately, so just send <letter>.
           if ((key >= 1 && key <= 26 && !ev.isShiftDown()) ||
               // CTRL-{, CTRL-|, CTRL-} also map to ASCII 96-127
@@ -1360,28 +1360,7 @@ public class CConn extends CConnection
       }
     }
 
-    if (fakeModifiers != 0) {
-      if ((fakeModifiers & Event.CTRL_MASK) != 0) {
-        vlog.debug("Fake L Ctrl raised");
-        writeKeyEvent(Keysyms.Control_L, false);
-      }
-      if ((modifiers & Event.ALT_MASK) != 0) {
-        vlog.debug("Fake R Alt raised");
-        writeKeyEvent(Keysyms.Alt_R, false);
-      }
-    }
     writeKeyEvent(keysym, down);
-    if (fakeModifiers != 0) {
-      if ((fakeModifiers & Event.CTRL_MASK) != 0) {
-        vlog.debug("Fake L Ctrl pressed");
-        writeKeyEvent(Keysyms.Control_L, true);
-      }
-      if ((modifiers & Event.ALT_MASK) != 0) {
-        vlog.debug("Fake R Alt pressed");
-        writeKeyEvent(Keysyms.Alt_R, true);
-      }
-      fakeModifiers = 0;
-    }
   }
 
 
index 42a1cc9de01fb83bcfa850586f74c81531289331..5f9ee1a397afa8e173f57b03f7f1da5d6e45e5ff 100644 (file)
@@ -460,20 +460,23 @@ class DesktopWindow extends JPanel implements Runnable, MouseListener,
     int ctrlAltShiftMask = Event.SHIFT_MASK | Event.CTRL_MASK | Event.ALT_MASK;
     if ((e.getModifiers() & ctrlAltShiftMask) == ctrlAltShiftMask) {
       switch (e.getKeyCode()) {
+        case KeyEvent.VK_A:
+          cc.showAbout();
+          return;
         case KeyEvent.VK_F:
           cc.toggleFullScreen();
           return;
+        case KeyEvent.VK_H:
+          cc.refresh();
+          return;
         case KeyEvent.VK_I:
           cc.showInfo();
           return;
-        case KeyEvent.VK_N:
-          VncViewer.newViewer(cc.viewer);
-          return;
         case KeyEvent.VK_O:
           cc.options.showDialog(cc.viewport);
           return;
-        case KeyEvent.VK_R:
-          cc.refresh();
+        case KeyEvent.VK_W:
+          VncViewer.newViewer(cc.viewer);
           return;
         case KeyEvent.VK_LEFT:
         case KeyEvent.VK_RIGHT:
index 8f1b0e0ec0ab1298a356892a6d2ddf081fd1df60..465dee88a2c7f0eec22d1e30e3a99a49796e87ca 100644 (file)
@@ -52,6 +52,9 @@ public class Viewport extends JFrame
         if (isVisible())
           sp.getViewport().getView().requestFocusInWindow();
       }
+      public void windowLostFocus(WindowEvent e) {
+        cc.releaseModifiers();
+      }
     });
     addWindowListener(new WindowAdapter() {
       public void windowClosing(WindowEvent e) {