X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fxcb_util.c;h=4ae9097e883c33a546bf765a2c13193c4fb85af4;hb=eaa71eac02c6a862ab23e8afcce12d9f38590338;hp=f5c9431d21744464ddcbfb10892c248c90cfdde9;hpb=9b79ae49f709707e99b8487b01f9d3f102754bd3;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_util.c b/src/xcb_util.c index f5c9431..4ae9097 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -130,7 +130,9 @@ static int _xcb_open_abstract(char *protocol, const char *file); static int _xcb_open(char *host, char *protocol, const int display) { +#ifdef HAVE_ABSTRACT_SOCKETS int fd; +#endif static const char base[] = "/tmp/.X11-unix/X"; char file[sizeof(base) + 20]; @@ -315,19 +317,22 @@ xcb_connection_t *xcb_connect(const char *displayname, int *screenp) char *protocol; xcb_connection_t *c; xcb_auth_info_t auth; + + int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp); -#ifdef __APPLE__ +#ifdef HAVE_LAUNCHD + if(!displayname) + displayname = getenv("DISPLAY"); if(displayname && strlen(displayname)>11 && !strncmp(displayname, "/tmp/launch", 11)) - fd = _xcb_open_unix(protocol, displayname); - else { -#endif - if(!_xcb_parse_display(displayname, &host, &protocol, &display, screenp)) + fd = _xcb_open_unix(NULL, displayname); + else +#endif + if(!parsed) return (xcb_connection_t *) &error_connection; - fd = _xcb_open(host, protocol, display); + else + fd = _xcb_open(host, protocol, display); free(host); -#ifdef __APPLE__ - } -#endif + if(fd == -1) return (xcb_connection_t *) &error_connection; @@ -348,18 +353,21 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname, char *host; char *protocol; -#ifdef __APPLE__ + 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(protocol, displayname); - else { -#endif - if(!_xcb_parse_display(displayname, &host, &protocol, &display, screenp)) + fd = _xcb_open_unix(NULL, displayname); + else +#endif + if(!parsed) return (xcb_connection_t *) &error_connection; - fd = _xcb_open(host, protocol, display); + else + fd = _xcb_open(host, protocol, display); free(host); -#ifdef __APPLE__ - } -#endif + if(fd == -1) return (xcb_connection_t *) &error_connection;