- fixed the stupid XAUTHORITY issue in spacenavd

- random whitespace fixes in libspnav


git-svn-id: svn+ssh://svn.code.sf.net/p/spacenav/code/trunk/spacenavd@107 ef983eb1-d774-4af8-acfd-baaf7b16a646
pull/1/head v0.5
John Tsiombikas 2010-07-27 04:46:14 +00:00
rodzic 1a25e7c7b2
commit 8c7d1eb0e2
1 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -21,7 +21,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef USE_X11
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#include <alloca.h>
#include <unistd.h>
#include <pwd.h>
#include "proto_x11.h"
#include "client.h"
#include "spnavd.h"
@ -71,8 +75,18 @@ int init_x11(void)
putenv("DISPLAY=:0.0");
}
/* ... also there won't be an XAUTHORITY env var, so set one up */
if(!getenv("XAUTHORITY")) {
struct passwd *p = getpwuid(getuid());
char *home = p->pw_dir ? p->pw_dir : "/tmp";
char *buf = alloca(strlen("XAUTHORITY=") + strlen(home) + strlen("/.Xauthority") + 1);
sprintf(buf, "XAUTHORITY=%s/.Xauthority", home);
putenv(buf);
}
if(verbose) {
printf("trying to open X11 display \"%s\"\n", getenv("DISPLAY"));
printf(" XAUTHORITY=%s\n", getenv("XAUTHORITY"));
}
if(!(dpy = XOpenDisplay(0))) {