summaryrefslogtreecommitdiffstats
path: root/java/com
diff options
context:
space:
mode:
authorBrian Hinz <bphinz@users.sourceforge.net>2014-01-02 20:35:52 +0000
committerBrian Hinz <bphinz@users.sourceforge.net>2014-01-02 20:35:52 +0000
commit3ddb148338c4d48ad8b40d044657169712669b6a (patch)
treeffbd14181040c5e9d4f1a310ef79629d14867729 /java/com
parent430d8cf098aef3d1223a51cfd7d52ca2552b52df (diff)
downloadtigervnc-3ddb148338c4d48ad8b40d044657169712669b6a.tar.gz
tigervnc-3ddb148338c4d48ad8b40d044657169712669b6a.zip
Release all downKeys when the focus is lost, otherwise the state of the keyboard will be inconsistent when the focus is regained. Also, the direction of the key release was incorrect in r5147.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5150 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/com')
-rw-r--r--java/com/tigervnc/vncviewer/CConn.java27
-rw-r--r--java/com/tigervnc/vncviewer/DesktopWindow.java2
-rw-r--r--java/com/tigervnc/vncviewer/Viewport.java2
3 files changed, 7 insertions, 24 deletions
diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java
index e48e93b2..b876751c 100644
--- a/java/com/tigervnc/vncviewer/CConn.java
+++ b/java/com/tigervnc/vncviewer/CConn.java
@@ -310,7 +310,7 @@ public class CConn extends CConnection implements
desktop.requestFocus();
}
public void focusLost(FocusEvent e) {
- releaseModifiers();
+ releaseDownKeys();
}
});
viewer.validate();
@@ -1367,27 +1367,10 @@ public class CConn extends CConnection implements
}
- synchronized void releaseModifiers() {
- if (downKeySym.containsValue(Keysyms.Shift_L))
- writeKeyEvent(Keysyms.Shift_L, true);
- if (downKeySym.containsValue(Keysyms.Shift_R))
- writeKeyEvent(Keysyms.Shift_R, true);
- if (downKeySym.containsValue(Keysyms.Control_L))
- writeKeyEvent(Keysyms.Control_L, true);
- if (downKeySym.containsValue(Keysyms.Control_R))
- writeKeyEvent(Keysyms.Control_R, true);
- if (downKeySym.containsValue(Keysyms.Alt_L))
- writeKeyEvent(Keysyms.Alt_L, true);
- if (downKeySym.containsValue(Keysyms.Alt_R))
- writeKeyEvent(Keysyms.Alt_R, true);
- if (downKeySym.containsValue(Keysyms.Meta_L))
- writeKeyEvent(Keysyms.Meta_L, true);
- if (downKeySym.containsValue(Keysyms.Meta_R))
- writeKeyEvent(Keysyms.Meta_R, true);
- if (downKeySym.containsValue(Keysyms.Super_L))
- writeKeyEvent(Keysyms.Super_L, true);
- if (downKeySym.containsValue(Keysyms.Super_R))
- writeKeyEvent(Keysyms.Super_R, true);
+ synchronized void releaseDownKeys() {
+ for (Map.Entry<Integer, Integer> entry : downKeySym.entrySet())
+ writeKeyEvent(entry.getValue(), false);
+ downKeySym.clear();
}
// this is a special ActionListener passed in by the
diff --git a/java/com/tigervnc/vncviewer/DesktopWindow.java b/java/com/tigervnc/vncviewer/DesktopWindow.java
index 4749eb2a..4175746f 100644
--- a/java/com/tigervnc/vncviewer/DesktopWindow.java
+++ b/java/com/tigervnc/vncviewer/DesktopWindow.java
@@ -86,7 +86,7 @@ class DesktopWindow extends JPanel implements Runnable, MouseListener,
checkClipboard();
}
public void focusLost(FocusEvent e) {
- cc.releaseModifiers();
+ cc.releaseDownKeys();
}
});
setFocusTraversalKeysEnabled(false);
diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java
index 19c51c94..a6ce3554 100644
--- a/java/com/tigervnc/vncviewer/Viewport.java
+++ b/java/com/tigervnc/vncviewer/Viewport.java
@@ -58,7 +58,7 @@ public class Viewport extends JFrame
sp.getViewport().getView().requestFocusInWindow();
}
public void windowLostFocus(WindowEvent e) {
- cc.releaseModifiers();
+ cc.releaseDownKeys();
}
});
addWindowListener(new WindowAdapter() {