diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/xcb_util.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/xcb_util.c b/src/xcb_util.c index f8d381d..9bdfa86 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -89,12 +89,10 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol, if(!name) return 0; -#ifdef HAVE_LAUNCHD - if(strncmp(name, "/tmp/launch", 11) == 0) + if(name[0] == '/') slash = NULL; else -#endif - slash = strrchr(name, '/'); + slash = strrchr(name, '/'); if (slash) { len = slash - name; @@ -111,8 +109,26 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol, *protocol = NULL; colon = strrchr(name, ':'); - if(!colon) - goto error_out; + if(!colon) { + if (name[0] != '/') + goto error_out; + + /* No colon and starts with /, assume it's a direct path to a unix domain socket */ + *host = strdup(name); + if (!*host) + goto error_out; + + if (protocol) + *protocol = NULL; + + if (displayp) + *displayp = -1; + + if(screenp) + *screenp = 0; + return 1; + } + len = colon - name; ++colon; display = strtoul(colon, &dot, 10); @@ -186,6 +202,12 @@ static int _xcb_open(const char *host, char *protocol, const int display) } #endif + if (host[0] == '/' && protocol == NULL && display == -1) { + base = host; + host = ""; + protocol = "unix"; + } + /* If protocol or host is "unix", fall through to Unix socket code below */ if ((!protocol || (strcmp("unix",protocol) != 0)) && (*host != '\0') && (strcmp("unix",host) != 0)) @@ -222,7 +244,10 @@ static int _xcb_open(const char *host, char *protocol, const int display) actual_filelen = snprintf(file, filelen, "%s:%d", base, display); else #endif + if (display != -1) actual_filelen = snprintf(file, filelen, "%s%d", base, display); + else + actual_filelen = snprintf(file, filelen, "%s", base); if(actual_filelen < 0) { free(file); |