Reworked launchd support to work better with _xcb_parse_display
Fixes: http://xquartz.macosforge.org/trac/ticket/390 Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
parent
b0525e2423
commit
89b3485dad
|
@ -28,6 +28,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/syslimits.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
|
@ -67,7 +68,14 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol,
|
||||||
name = getenv("DISPLAY");
|
name = getenv("DISPLAY");
|
||||||
if(!name)
|
if(!name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_LAUNCHD
|
||||||
|
if(strncmp(name, "/tmp/launch", 11) == 0)
|
||||||
|
slash = NULL;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
slash = strrchr(name, '/');
|
slash = strrchr(name, '/');
|
||||||
|
|
||||||
if (slash) {
|
if (slash) {
|
||||||
len = slash - name;
|
len = slash - name;
|
||||||
if (protocol) {
|
if (protocol) {
|
||||||
|
@ -135,12 +143,19 @@ static int _xcb_open(char *host, char *protocol, const int display)
|
||||||
#ifdef HAVE_ABSTRACT_SOCKETS
|
#ifdef HAVE_ABSTRACT_SOCKETS
|
||||||
int fd;
|
int fd;
|
||||||
#endif
|
#endif
|
||||||
static const char base[] = "/tmp/.X11-unix/X";
|
static const char unix_base[] = "/tmp/.X11-unix/X";
|
||||||
char file[sizeof(base) + 20];
|
const char *base = unix_base;
|
||||||
|
char file[PATH_MAX + 1];
|
||||||
int filelen;
|
int filelen;
|
||||||
|
|
||||||
if(*host)
|
if(*host)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_LAUNCHD
|
||||||
|
if(strncmp(host, "/tmp/launch", 11) == 0) {
|
||||||
|
base = host;
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DNETCONN
|
#ifdef DNETCONN
|
||||||
/* DECnet displays have two colons, so _xcb_parse_display will have
|
/* DECnet displays have two colons, so _xcb_parse_display will have
|
||||||
left one at the end. However, an IPv6 address can end with *two*
|
left one at the end. However, an IPv6 address can end with *two*
|
||||||
|
@ -161,10 +176,18 @@ static int _xcb_open(char *host, char *protocol, const int display)
|
||||||
unsigned short port = X_TCP_PORT + display;
|
unsigned short port = X_TCP_PORT + display;
|
||||||
return _xcb_open_tcp(host, protocol, port);
|
return _xcb_open_tcp(host, protocol, port);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LAUNCHD
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* display specifies Unix socket */
|
/* display specifies Unix socket */
|
||||||
filelen = snprintf(file, sizeof(file), "%s%d", base, display);
|
#ifdef HAVE_LAUNCHD
|
||||||
|
if(base == host)
|
||||||
|
filelen = snprintf(file, sizeof(file), "%s:%d", base, display);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
filelen = snprintf(file, sizeof(file), "%s%d", base, display);
|
||||||
if(filelen < 0)
|
if(filelen < 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* snprintf may truncate the file */
|
/* snprintf may truncate the file */
|
||||||
|
@ -354,13 +377,6 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
|
||||||
|
|
||||||
int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp);
|
int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp);
|
||||||
|
|
||||||
#ifdef HAVE_LAUNCHD
|
|
||||||
if(!displayname)
|
|
||||||
displayname = getenv("DISPLAY");
|
|
||||||
if(displayname && strlen(displayname)>11 && !strncmp(displayname, "/tmp/launch", 11))
|
|
||||||
fd = _xcb_open_unix(NULL, displayname);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if(!parsed)
|
if(!parsed)
|
||||||
return (xcb_connection_t *) &error_connection;
|
return (xcb_connection_t *) &error_connection;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue