diff options
author | Ray Strode <rstrode@redhat.com> | 2014-04-17 14:21:55 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2014-04-17 15:08:14 -0400 |
commit | ca093dca194e88df619bb4397b4ea979686da537 (patch) | |
tree | c87a5d96bd7486c9ae97e8a79139c6fa5a65eb02 /src | |
parent | 29e419c5840a1eeda3336a0802686ee723dcaab3 (diff) |
This commit changes xcb's display parsing/opening functions
to allow a direct socket path without a display number.
This will be useful for supporting systemd activation, so the
display number doesn't have to be known ahead of time.
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); |