diff options
author | DRC <dcommander@users.sourceforge.net> | 2009-04-15 06:47:23 +0000 |
---|---|---|
committer | DRC <dcommander@users.sourceforge.net> | 2009-04-15 06:47:23 +0000 |
commit | 36546c1e5f5139c710b41dc172ed7bfb294a4cff (patch) | |
tree | f06d426df437061a700fb5912e815780933f23a1 /unix/vncserver | |
parent | cf6dfc469f449b4337beedf9e76902dbe3655afb (diff) | |
download | tigervnc-36546c1e5f5139c710b41dc172ed7bfb294a4cff.tar.gz tigervnc-36546c1e5f5139c710b41dc172ed7bfb294a4cff.zip |
Change font path logic such that XFS is used if it is available and running, otherwise Xvnc is started with no -fp argument. If this fails, then Xvnc is restarted using the automatically-generated font path.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3779 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'unix/vncserver')
-rwxr-xr-x | unix/vncserver | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/unix/vncserver b/unix/vncserver index 07c3bec5..1578a5e0 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -81,6 +81,14 @@ $defaultXStartup chop($host = `uname -n`); +if (CheckXFS(1)) { + $fontPath = "unix/:7100"; +} else { + if (CheckXFS(0)) { + $fontPath = "inet/:7100"; # Some Solaris systems require this + } +} + @fontpaths = ('/usr/share/X11/fonts', '/usr/share/fonts', '/usr/share/fonts/X11/'); if (! -l "/usr/lib/X11") {push(@fontpaths, '/usr/lib/X11/fonts');} if (! -l "/usr/X11") {push(@fontpaths, '/usr/X11/lib/X11/fonts');} @@ -97,19 +105,17 @@ foreach $_fpath (@fontpaths) { foreach $_ftype (@fonttypes) { if (-f "$_fpath/$_ftype/fonts.dir") { if (! -l "$_fpath/$_ftype") { - $fontPath .= "$_fpath/$_ftype,"; + $defFontPath .= "$_fpath/$_ftype,"; } } } } -if ($fontPath) { - if (substr($fontPath, -1, 1) == ',') { - chop $fontPath; +if ($defFontPath) { + if (substr($defFontPath, -1, 1) == ',') { + chop $defFontPath; } } -$defFontPath = "unix/:7100"; - # Check command line options &ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1, @@ -135,6 +141,7 @@ if ($opt{'-pixelformat'}) { } if ($opt{'-fp'}) { $fontPath = $opt{'-fp'}; + $fpArgSpecified = 1; } &CheckGeometryAndDepth(); @@ -231,10 +238,17 @@ system("$cmd & echo \$! >$pidFile"); sleep(3); unless (kill 0, `cat $pidFile`) { - warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the vncserver\n"; - warn "script was not able to figure out an appropriate X11 font path for this system\n"; - warn "or because the font path you specified with the -fp argument was not valid.\n"; - warn "Attempting to restart Xvnc using the X Font Server (xfs) ...\n"; + if ($fpArgSpecified) { + warn "\nWARNING: The first attempt to start Xvnc failed, probably because the font\n"; + warn "path you specified using the -fp argument is incorrect. Attempting to\n"; + warn "determine an appropriate font path for this system and restart Xvnc using\n"; + warn "that font path ...\n"; + } else { + warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the X Font\n"; + warn "Server is not running and this system does not use a font catalog. Attempting\n"; + warn "to determine an appropriate font path for this system and restart Xvnc using\n"; + warn "that font path ...\n"; + } $cmd =~ s@-fp [^ ]+@@; $cmd .= " -fp $defFontPath" if ($defFontPath); system("$cmd & echo \$! >$pidFile"); @@ -384,6 +398,32 @@ sub CheckDisplayNumber # +# CheckXFS checks if the X Font Server is running on the default port (7100) +# + +sub CheckXFS +{ + if (@_ == 1) { + socket(S, $AF_UNIX, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n"; + eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))'; + if (!bind(S, pack('S a108', $AF_UNIX, 7100))) { + close(S); + return 0; + } + } else { + socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n"; + eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))'; + if (!bind(S, pack('S n a4 x8', $AF_INET, 7100))) { + close(S); + return 0; + } + } + close(S); + return 1; +} + + +# # GetXDisplayDefaults uses xdpyinfo to find out the geometry, depth and pixel # format of the current X display being used. If successful, it sets the # options as appropriate so that the X VNC server will use the same settings @@ -674,16 +714,20 @@ sub SanityCheck if (($os eq "SunOS") && ($osrev !~ /^4/)) { $AF_INET = 2; $SOCK_STREAM = 2; + $AF_UNIX = 1; } else { $AF_INET = 2; $SOCK_STREAM = 1; + $AF_UNIX = 1; } } else { $AF_INET = &AF_INET; $SOCK_STREAM = &SOCK_STREAM; + $AF_UNIX = &AF_UNIX; } } else { $AF_INET = &AF_INET; $SOCK_STREAM = &SOCK_STREAM; + $AF_UNIX = &AF_UNIX; } } |