aboutsummaryrefslogtreecommitdiffstats
path: root/java/com
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2015-07-09 22:48:32 -0400
committerBrian P. Hinz <bphinz@users.sf.net>2015-07-12 15:21:13 -0400
commit780f974ca2382144eb51bbc8f33a6ff0096ebfb7 (patch)
treefcab65fa719a4acc3ee0fca7aa68e73ee5a62e5c /java/com
parentcaabb15acd5dcb382ebd6282de3efade550dbcf2 (diff)
downloadtigervnc-780f974ca2382144eb51bbc8f33a6ff0096ebfb7.tar.gz
tigervnc-780f974ca2382144eb51bbc8f33a6ff0096ebfb7.zip
Add resize on connect menu controls to Java viewer
Adds controls for resize on connect to the options dialog. Fixes #104
Diffstat (limited to 'java/com')
-rw-r--r--java/com/tigervnc/vncviewer/CConn.java13
-rw-r--r--java/com/tigervnc/vncviewer/OptionsDialog.java54
2 files changed, 65 insertions, 2 deletions
diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java
index ec52f6e9..5ce1c2f7 100644
--- a/java/com/tigervnc/vncviewer/CConn.java
+++ b/java/com/tigervnc/vncviewer/CConn.java
@@ -1002,6 +1002,14 @@ public class CConn extends CConnection implements
if (desktop != null)
desktop.setScaledSize();
}
+ if (viewer.desktopSize.getValue() != null &&
+ viewer.desktopSize.getValue().split("x").length == 2) {
+ options.desktopSize.setSelected(true);
+ String desktopWidth = viewer.desktopSize.getValue().split("x")[0];
+ options.desktopWidth.setText(desktopWidth);
+ String desktopHeight = viewer.desktopSize.getValue().split("x")[1];
+ options.desktopHeight.setText(desktopHeight);
+ }
}
public void getOptions() {
@@ -1200,6 +1208,11 @@ public class CConn extends CConnection implements
Security.DisableSecType(Security.secTypeX509Ident);
}
}
+ if (options.desktopSize.isSelected()) {
+ String desktopSize =
+ options.desktopWidth.getText() + "x" + options.desktopHeight.getText();
+ viewer.desktopSize.setParam(desktopSize);
+ }
if (options.fullScreen.isSelected() ^ fullScreen)
toggleFullScreen();
}
diff --git a/java/com/tigervnc/vncviewer/OptionsDialog.java b/java/com/tigervnc/vncviewer/OptionsDialog.java
index facd4dbb..a47ec395 100644
--- a/java/com/tigervnc/vncviewer/OptionsDialog.java
+++ b/java/com/tigervnc/vncviewer/OptionsDialog.java
@@ -22,6 +22,8 @@ package com.tigervnc.vncviewer;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
+import java.text.Format;
+import java.text.NumberFormat;
import javax.swing.*;
import javax.swing.border.*;
@@ -32,6 +34,21 @@ class OptionsDialog extends Dialog implements
ItemListener
{
+ private class IntegerTextField extends JFormattedTextField {
+ public IntegerTextField(Format format) {
+ super(format);
+ }
+ @Override
+ protected void processFocusEvent(final FocusEvent e) {
+ if (e.isTemporary())
+ return;
+ if (e.getID() == FocusEvent.FOCUS_LOST)
+ if (getText() == null || getText().isEmpty())
+ setValue(null);
+ super.processFocusEvent(e);
+ }
+ }
+
// Constants
// Static variables
static LogWriter vlog = new LogWriter("OptionsDialog");
@@ -45,12 +62,13 @@ class OptionsDialog extends Dialog implements
JRadioButton zrle, hextile, tight, raw;
JRadioButton fullColour, mediumColour, lowColour, veryLowColour;
JCheckBox viewOnly, acceptClipboard, sendClipboard, acceptBell;
- JCheckBox fullScreen, shared, useLocalCursor;
+ JCheckBox desktopSize, fullScreen, shared, useLocalCursor;
JCheckBox secVeNCrypt, encNone, encTLS, encX509;
JCheckBox secNone, secVnc, secPlain, secIdent, sendLocalUsername;
JButton okButton, cancelButton;
JButton ca, crl;
JButton cfLoadButton, cfSaveAsButton, defSaveButton, defReloadButton, defClearButton;
+ JTextField desktopWidth, desktopHeight;
@SuppressWarnings({"rawtypes","unchecked"})
public OptionsDialog(CConn cc_) {
@@ -146,6 +164,23 @@ class OptionsDialog extends Dialog implements
// Screen tab
ScreenPanel=new JPanel(new GridBagLayout());
+ desktopSize = new JCheckBox("Resize remote session on connect");
+ desktopSize.addItemListener(this);
+ desktopSize.setEnabled(cc.viewer.desktopSize.getValue() != null);
+ NumberFormat format = NumberFormat.getIntegerInstance();
+ format.setMaximumIntegerDigits(5);
+ format.setMinimumIntegerDigits(0);
+ format.setGroupingUsed(false);
+ desktopWidth = new IntegerTextField(format);
+ desktopWidth.setColumns(4);
+ desktopWidth.setEnabled(desktopSize.isSelected());
+ desktopHeight = new IntegerTextField(format);
+ desktopHeight.setColumns(4);
+ desktopHeight.setEnabled(desktopSize.isSelected());
+ JPanel desktopSizePanel = new JPanel();
+ desktopSizePanel.add(desktopWidth);
+ desktopSizePanel.add(new JLabel("x"));
+ desktopSizePanel.add(desktopHeight);
fullScreen = new JCheckBox("Full-screen mode");
fullScreen.addItemListener(this);
fullScreen.setEnabled(!cc.viewer.embed.getValue());
@@ -167,7 +202,9 @@ class OptionsDialog extends Dialog implements
scalingFactor.setEditable(true);
scalingFactor.addItemListener(this);
scalingFactor.setEnabled(!cc.viewer.embed.getValue());
- addGBComponent(fullScreen,ScreenPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
+ addGBComponent(desktopSize,ScreenPanel, 0, 1, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
+ addGBComponent(desktopSizePanel,ScreenPanel, 0, 2, 2, 1, 2, 2, 1, 0, GridBagConstraints.REMAINDER, GridBagConstraints.LINE_START, new Insets(0,20,0,0));
+ addGBComponent(fullScreen,ScreenPanel, 0, 3, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,5));
addGBComponent(scalingFactorLabel,ScreenPanel, 0, 4, 1, GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,5));
addGBComponent(scalingFactor,ScreenPanel, 1, 4, 1, GridBagConstraints.REMAINDER, 2, 2, 25, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));
@@ -335,6 +372,9 @@ class OptionsDialog extends Dialog implements
UserPreferences.set("global", "SendClipboard", sendClipboard.isSelected());
String menuKeyStr = MenuKey.getMenuKeySymbols()[menuKey.getSelectedIndex()].name;
UserPreferences.set("global", "MenuKey", menuKeyStr);
+ String desktopSizeString =
+ desktopSize.isSelected() ? desktopWidth.getText() + "x" + desktopHeight.getText() : "";
+ UserPreferences.set("global", "DesktopSize", desktopSizeString);
UserPreferences.set("global", "FullScreen", fullScreen.isSelected());
UserPreferences.set("global", "Shared", shared.isSelected());
UserPreferences.set("global", "UseLocalCursor", useLocalCursor.isSelected());
@@ -406,6 +446,12 @@ class OptionsDialog extends Dialog implements
acceptClipboard.setSelected(UserPreferences.getBool("global", "AcceptClipboard"));
sendClipboard.setSelected(UserPreferences.getBool("global", "SendClipboard"));
menuKey.setSelectedItem(UserPreferences.get("global", "MenuKey"));
+ desktopSize.setSelected(UserPreferences.get("global", "DesktopSize") != null);
+ if (desktopSize.isSelected()) {
+ String desktopSizeString = UserPreferences.get("global", "DesktopSize");
+ desktopWidth.setText(desktopSizeString.split("x")[0]);
+ desktopHeight.setText(desktopSizeString.split("x")[1]);
+ }
fullScreen.setSelected(UserPreferences.getBool("global", "FullScreen"));
if (shared.isEnabled())
shared.setSelected(UserPreferences.getBool("global", "Shared"));
@@ -556,6 +602,10 @@ class OptionsDialog extends Dialog implements
if (s instanceof JCheckBox && (JCheckBox)s == customCompressLevel) {
compressLevel.setEnabled(customCompressLevel.isSelected());
}
+ if (s instanceof JCheckBox && (JCheckBox)s == desktopSize) {
+ desktopWidth.setEnabled(desktopSize.isSelected());
+ desktopHeight.setEnabled(desktopSize.isSelected());
+ }
if (s instanceof JCheckBox && (JCheckBox)s == noJpeg) {
qualityLevel.setEnabled(noJpeg.isSelected());
}