summaryrefslogtreecommitdiffstats
path: root/unix/xserver
diff options
context:
space:
mode:
Diffstat (limited to 'unix/xserver')
-rw-r--r--unix/xserver/hw/vnc/Xvnc.man2
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc36
2 files changed, 36 insertions, 2 deletions
diff --git a/unix/xserver/hw/vnc/Xvnc.man b/unix/xserver/hw/vnc/Xvnc.man
index c85c396f..59ed4ac0 100644
--- a/unix/xserver/hw/vnc/Xvnc.man
+++ b/unix/xserver/hw/vnc/Xvnc.man
@@ -72,7 +72,7 @@ case-insensitive.
.TP
.B \-desktop \fIdesktop-name\fP
Each desktop has a name which may be displayed by the viewer. It defaults to
-"x11".
+"<user>@<hostname>".
.
.TP
.B \-rfbport \fIport\fP
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index 6c4612d1..bdf563a8 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -19,6 +19,9 @@
#include <stdio.h>
#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
#include <set>
#include <string>
@@ -73,10 +76,12 @@ struct CaseInsensitiveCompare {
typedef std::set<std::string, CaseInsensitiveCompare> ParamSet;
static ParamSet allowOverrideSet;
+static const char* defaultDesktopName();
+
rfb::IntParameter rfbport("rfbport", "TCP port to listen for RFB protocol",0);
rfb::StringParameter rfbunixpath("rfbunixpath", "Unix socket to listen for RFB protocol", "");
rfb::IntParameter rfbunixmode("rfbunixmode", "Unix socket access mode", 0600);
-rfb::StringParameter desktopName("desktop", "Name of VNC desktop","x11");
+rfb::StringParameter desktopName("desktop", "Name of VNC desktop", defaultDesktopName());
rfb::BoolParameter localhostOnly("localhost",
"Only allow connections from localhost",
false);
@@ -95,6 +100,35 @@ rfb::BoolParameter sendPrimary("SendPrimary",
"Send the PRIMARY as well as the CLIPBOARD selection",
true);
+static const char* defaultDesktopName()
+{
+ static char* name = NULL;
+
+ char hostname[HOST_NAME_MAX + 1];
+ struct passwd* pwent;
+
+ size_t len;
+
+ delete [] name;
+
+ if (gethostname(hostname, sizeof(hostname)) == -1)
+ return "";
+
+ pwent = getpwuid(getuid());
+ if (pwent == NULL)
+ return "";
+
+ len = snprintf(NULL, 0, "%s@%s", pwent->pw_name, hostname);
+ if (len < 0)
+ return "";
+
+ name = new char[len + 1];
+
+ snprintf(name, len + 1, "%s@%s", pwent->pw_name, hostname);
+
+ return name;
+}
+
static PixelFormat vncGetPixelFormat(int scrIdx)
{
int depth, bpp;