AutoSelect if default only if not using PreferredEncoding or FullColor.
CustomCompressLevel is default if CompressLevel is specified.
This gives backwards compatibility with the old vncviewer, but at the
same time making it possible to fully specify the internal state of
the viewer wrt AutoSelect, CustomCompressLevel and CompressLevel. For
example, it's now possible to start the client with CompressLevel=4
specified, but with CustomCompressLevel=0 (thus the option
grayed-out).
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@79 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/rfb/Configuration.cxx b/rfb/Configuration.cxx
index 048fb77..fc68210 100644
--- a/rfb/Configuration.cxx
+++ b/rfb/Configuration.cxx
@@ -67,6 +67,7 @@
strncasecmp(current->getName(), name, len) == 0)
{
bool b = current->setParam(val);
+ current->setHasBeenSet();
if (b && immutable)
current->setImmutable();
return b;
@@ -91,6 +92,7 @@
while (current) {
if (strcasecmp(current->getName(), config) == 0) {
bool b = current->setParam();
+ current->setHasBeenSet();
if (b && immutable)
current->setImmutable();
return b;
@@ -152,7 +154,7 @@
// -=- VoidParameter
VoidParameter::VoidParameter(const char* name_, const char* desc_)
- : immutable(false), name(name_), description(desc_) {
+ : immutable(false), _hasBeenSet(false), name(name_), description(desc_) {
_next = Configuration::head;
Configuration::head = this;
}
@@ -184,6 +186,16 @@
immutable = true;
}
+void
+VoidParameter::setHasBeenSet() {
+ _hasBeenSet = true;
+}
+
+bool
+VoidParameter::hasBeenSet() {
+ return _hasBeenSet;
+}
+
// -=- AliasParameter
AliasParameter::AliasParameter(const char* name_, const char* desc_,
diff --git a/rfb/Configuration.h b/rfb/Configuration.h
index 1b37ac9..20aec99 100644
--- a/rfb/Configuration.h
+++ b/rfb/Configuration.h
@@ -78,10 +78,13 @@
virtual bool isBool() const;
virtual void setImmutable();
+ virtual void setHasBeenSet();
+ bool hasBeenSet();
VoidParameter* _next;
protected:
bool immutable;
+ bool _hasBeenSet;
const char* name;
const char* description;
};
diff --git a/vncviewer/CViewOptions.cxx b/vncviewer/CViewOptions.cxx
index f19b096..1f55129 100644
--- a/vncviewer/CViewOptions.cxx
+++ b/vncviewer/CViewOptions.cxx
@@ -49,10 +49,12 @@
"(Press F8 to access the viewer menu)",
false);
static StringParameter preferredEncoding("PreferredEncoding",
- "Preferred graphical encoding to use - overridden by AutoSelect if set. "
- "(ZRLE, Hextile or Raw)", "ZRLE");
-
-static BoolParameter autoSelect("AutoSelect", "Auto select pixel format and encoding", true);
+ "Preferred encoding to use (Tight, ZRLE, Hextile or"
+ " Raw)", "Tight");
+static BoolParameter autoSelect("AutoSelect",
+ "Auto select pixel format and encoding. "
+ "Default if PreferredEncoding and FullColor are not specified.",
+ true);
static BoolParameter sharedConnection("Shared",
"Allow existing connections to the server to continue."
"(Default is to disconnect all other clients)",
@@ -86,8 +88,8 @@
static StringParameter menuKey("MenuKey", "The key which brings up the popup menu", "F8");
static BoolParameter customCompressLevel("CustomCompressLevel",
- "Use custom compression level",
- false);
+ "Use custom compression level. "
+ "Default if CompressLevel is specified.", false);
static IntParameter compressLevel("CompressLevel",
"Use specified compression level"
@@ -116,6 +118,17 @@
CharArray encodingName(::preferredEncoding.getData());
preferredEncoding = encodingNum(encodingName.buf);
setMenuKey(CharArray(::menuKey.getData()).buf);
+
+ if (!::autoSelect.hasBeenSet()) {
+ // Default to AutoSelect=0 if -PreferredEncoding or -FullColor is used
+ autoSelect = (!::preferredEncoding.hasBeenSet()
+ && !::fullColour.hasBeenSet()
+ && !::fullColourAlias.hasBeenSet());
+ }
+ if (!::customCompressLevel.hasBeenSet()) {
+ // Default to CustomCompressLevel=1 if CompressLevel is used.
+ customCompressLevel = ::compressLevel.hasBeenSet();
+ }
}
diff --git a/vncviewer_unix/CConn.cxx b/vncviewer_unix/CConn.cxx
index ec2f014..eb5e203 100644
--- a/vncviewer_unix/CConn.cxx
+++ b/vncviewer_unix/CConn.cxx
@@ -70,7 +70,6 @@
int encNum = encodingNum(encStr.buf);
if (encNum != -1) {
currentEncoding = encNum;
- autoSelect = false;
}
cp.supportsDesktopResize = true;
cp.supportsLocalCursor = useLocalCursor;
diff --git a/vncviewer_unix/vncviewer.cxx b/vncviewer_unix/vncviewer.cxx
index 29679b8..433ef83 100644
--- a/vncviewer_unix/vncviewer.cxx
+++ b/vncviewer_unix/vncviewer.cxx
@@ -57,7 +57,9 @@
"Show the dot cursor when the server sends an "
"invisible cursor", true);
BoolParameter autoSelect("AutoSelect",
- "Auto select pixel format and encoding", true);
+ "Auto select pixel format and encoding. "
+ "Default if PreferredEncoding and FullColor are not specified.",
+ true);
BoolParameter fullColour("FullColor",
"Use full color", true);
AliasParameter fullColourAlias("FullColour", "Alias for FullColor", &fullColour);
@@ -67,8 +69,8 @@
"2 = Medium (256 colors)", 2);
AliasParameter lowColourLevelAlias("LowColourLevel", "Alias for LowColorLevel", &lowColourLevel);
StringParameter preferredEncoding("PreferredEncoding",
- "Preferred encoding to use (ZRLE, hextile or"
- " raw) - implies AutoSelect=0", "");
+ "Preferred encoding to use (Tight, ZRLE, Hextile or"
+ " Raw)", "Tight");
BoolParameter fullScreen("FullScreen", "Full screen mode", false);
BoolParameter viewOnly("ViewOnly",
"Don't send any mouse or keyboard events to the server",
@@ -93,8 +95,8 @@
StringParameter displayname("display", "The X display", "");
BoolParameter customCompressLevel("CustomCompressLevel",
- "Use custom compression level",
- false);
+ "Use custom compression level. "
+ "Default if CompressLevel is specified.", false);
IntParameter compressLevel("CompressLevel",
"Use specified compression level"
@@ -212,6 +214,17 @@
vncServerName = argv[i];
}
+ if (!::autoSelect.hasBeenSet()) {
+ // Default to AutoSelect=0 if -PreferredEncoding or -FullColor is used
+ ::autoSelect.setParam(!::preferredEncoding.hasBeenSet()
+ && !::fullColour.hasBeenSet()
+ && !::fullColourAlias.hasBeenSet());
+ }
+ if (!::customCompressLevel.hasBeenSet()) {
+ // Default to CustomCompressLevel=1 if CompressLevel is used.
+ ::customCompressLevel.setParam(::compressLevel.hasBeenSet());
+ }
+
try {
TcpSocket::initTcpSockets();