summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2014-11-19 18:58:59 -0500
committerPierre Ossman <ossman@cendio.se>2014-11-20 11:22:16 +0100
commit1e6cb40a1d33e50a9d3c118689284c593e8fcbe7 (patch)
tree0e6047534822037f9b29f8b45258f9c4afe5d709
parent59c5a55c0f5c2411c645dc48af671cc1fdbb0c06 (diff)
downloadtigervnc-1e6cb40a1d33e50a9d3c118689284c593e8fcbe7.tar.gz
tigervnc-1e6cb40a1d33e50a9d3c118689284c593e8fcbe7.zip
More Java viewer clipboard handler fixes
* Override TransferHandler.exportToClipboard method to ensure that serverCutText updates get sent to the system clipboard. This wasn't always happening when relying on the super class' paste() method alone. * Removed some unnecessary setText() statements and one check for whether sending client cut text is enabled. (cherry picked from commit 4f95737b72a516f0ca2ffdd1d299b7469ea90962)
-rw-r--r--java/com/tigervnc/vncviewer/ClipboardDialog.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/java/com/tigervnc/vncviewer/ClipboardDialog.java b/java/com/tigervnc/vncviewer/ClipboardDialog.java
index fff7dc3e..e7aa7e96 100644
--- a/java/com/tigervnc/vncviewer/ClipboardDialog.java
+++ b/java/com/tigervnc/vncviewer/ClipboardDialog.java
@@ -37,6 +37,14 @@ class ClipboardDialog extends Dialog implements ActionListener {
// clipboard transfers to VncViewer.maxCutText.getValue() bytes.
private LogWriter vlog = new LogWriter("VncTransferHandler");
+ public void exportToClipboard(JComponent c, Clipboard clip, int a)
+ throws IllegalStateException {
+ if (!(c instanceof JTextComponent)) return;
+ StringSelection selection =
+ new StringSelection(((JTextComponent)c).getText());
+ clip.setContents(selection, null);
+ }
+
public boolean importData(JComponent c, Transferable t) {
if (canImport(c, t.getTransferDataFlavors())) {
try {
@@ -114,13 +122,11 @@ class ClipboardDialog extends Dialog implements ActionListener {
public void serverCutText(String str, int len) {
textArea.setText(str);
- textArea.selectAll();
textArea.copy();
}
public void clientCutText() {
int hc = textArea.getText().hashCode();
- textArea.setText("");
textArea.paste();
textArea.setCaretPosition(0);
String text = textArea.getText();
@@ -139,8 +145,7 @@ class ClipboardDialog extends Dialog implements ActionListener {
serverCutText(new String(""), 0);
} else if (s instanceof JButton && (JButton)s == sendButton) {
String text = textArea.getText();
- if (cc.viewer.sendClipboard.getValue())
- cc.writeClientCutText(text, text.length());
+ cc.writeClientCutText(text, text.length());
endDialog();
} else if (s instanceof JButton && (JButton)s == cancelButton) {
endDialog();