diff --git a/configure.ac b/configure.ac index 1d470557..604d1bb0 100644 --- a/configure.ac +++ b/configure.ac @@ -144,6 +144,17 @@ AC_SUBST(WCHAR32) AM_CONDITIONAL(OS2, test x$os2 = xtrue) +AC_ARG_WITH(launchd, AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto]) +if test "x$LAUNCHD" = xauto; then + unset LAUNCHD + AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no]) +fi + +if test "x$LAUNCHD" = xyes ; then + AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available]) + AC_DEFINE(TRANS_REOPEN, 1, [launchd support available]) +fi + AC_ARG_ENABLE(xthreads, AC_HELP_STRING([--disable-xthreads], [Disable Xlib support for Multithreading]), diff --git a/src/ConnDis.c b/src/ConnDis.c index 2f0cd496..f4a4dc86 100644 --- a/src/ConnDis.c +++ b/src/ConnDis.c @@ -303,7 +303,11 @@ _X11TransConnectDisplay ( #if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN) if (!pprotocol) { +#ifdef HAVE_LAUNCHD + if (!phostname || phostname[0]=='/') { +#else if (!phostname) { +#endif #if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) pprotocol = copystring ("local", 5); #if defined(TCPCONN) @@ -449,6 +453,14 @@ _X11TransConnectDisplay ( *fullnamep = (char *) Xmalloc (len); if (!*fullnamep) goto bad; +#ifdef HAVE_LAUNCHD + if (phostname && strlen(phostname) > 11 && !strncmp(phostname, "/tmp/launch", 11)) + sprintf (*fullnamep, "%s%s%d", + (phostname ? phostname : ""), + (dnet ? "::" : ":"), + idisplay); + else +#endif sprintf (*fullnamep, "%s%s%d.%d", (phostname ? phostname : ""), (dnet ? "::" : ":"), diff --git a/src/xcb_disp.c b/src/xcb_disp.c index 1d8231a5..079c87ff 100644 --- a/src/xcb_disp.c +++ b/src/xcb_disp.c @@ -63,13 +63,22 @@ int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *scr if(!dpy->xcb) return 0; - if(!xcb_parse_display(display, &host, &n, screenp)) - return 0; +#ifdef HAVE_LAUNCHD + if(!display || !*display) display = getenv("DISPLAY"); + + if(display && strlen(display)>11 && !strncmp(display, "/tmp/launch", 11)) { + /* do nothing -- the magic happens inside of xcb_connect */ + } else +#endif + { + if(!xcb_parse_display(display, &host, &n, screenp)) + return 0; - len = strlen(host) + (1 + 20 + 1 + 20 + 1); - *fullnamep = Xmalloc(len); - snprintf(*fullnamep, len, "%s:%d.%d", host, n, *screenp); - free(host); + len = strlen(host) + (1 + 20 + 1 + 20 + 1); + *fullnamep = Xmalloc(len); + snprintf(*fullnamep, len, "%s:%d.%d", host, n, *screenp); + free(host); + } _XLockMutex(_Xglobal_lock); if(xauth.name && xauth.data)