xserver: Branch 'xorg-server-1.5-apple' - 6 commits
Jeremy Huddleston
jeremyhu at kemper.freedesktop.org
Wed Dec 10 15:08:49 PST 2008
configure.ac | 9 ++
hw/xquartz/Makefile.am | 3
hw/xquartz/X11Application.m | 2
hw/xquartz/X11Controller.m | 122 ++++++++++++++++++----------------
hw/xquartz/bundle/Info.plist | 39 ----------
hw/xquartz/bundle/Info.plist.cpp | 39 ++++++++++
hw/xquartz/bundle/Makefile.am | 16 +++-
hw/xquartz/bundle/X11.sh | 3
hw/xquartz/bundle/cpprules.in | 37 ++++++++++
hw/xquartz/bundle/mk_bundke.sh | 3
hw/xquartz/mach-startup/bundle-main.c | 111 +++++++++++++++++++++---------
hw/xquartz/xpr/xprScreen.c | 4 -
12 files changed, 254 insertions(+), 134 deletions(-)
New commits:
commit f8c10acd092f32de3f1be496add1585e7bf458c9
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Wed Dec 10 01:56:01 2008 -0800
XQuartz: Fix path to executable
(cherry picked from commit 7e9d3698e070a0c63dd2556651373c3aca58e2fe)
diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
index 5e00a82..2f953d1 100755
--- a/hw/xquartz/bundle/X11.sh
+++ b/hw/xquartz/bundle/X11.sh
@@ -1,3 +1,3 @@
#!/bin/bash --login
-./X11 "${@}"
+"$(dirname $0)"/X11 "${@}"
commit f0014240edff6757943b3475b72b7a92915c2b43
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Wed Dec 10 00:00:29 2008 -0800
XQuartz: fixed make dist
(cherry picked from commit 2d52367ab92429e58596d1a1ed3ef52a0a38a7aa)
diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index 16434f2..9713289 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
- <string>X11</string>
+ <string>X11.sh</string>
<key>CFBundleGetInfoString</key>
<string>APPLE_APPLICATION_NAME</string>
<key>CFBundleIconFile</key>
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index e765d6e..03fa1dd 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -17,6 +17,7 @@ resource_DATA = Xquartz.plist
EXTRA_DIST = \
mk_bundke.sh \
+ X11.sh \
Info.plist.cpp \
PkgInfo \
$(resource_DATA) \
commit 635cac44ab1c0384ecea7627a520486ff7f5b9ae
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Tue Dec 9 23:48:18 2008 -0800
XQuartz: Make debugging output for invalid depths a bit more detailed
(cherry picked from commit 609fb166b7062c76f0561df12ffe893811f6ac8f)
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 18406b8..b813727 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -279,7 +279,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
switch(depth) {
case -8: // broken
- FatalError("Unsupported color depth %d\n", darwinDesiredDepth);
+ FatalError("Unsupported color depth %d %d\n", darwinDesiredDepth, depth);
dfb->visuals = (1 << StaticGray) | (1 << GrayScale);
dfb->preferredCVC = GrayScale;
dfb->depth = 8;
@@ -320,7 +320,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
dfb->blueMask = 0x000000ff;
break;
default:
- FatalError("Unsupported color depth %d\n", darwinDesiredDepth);
+ FatalError("Unsupported color depth %d %d\n", darwinDesiredDepth, depth);
}
if (noPseudoramiXExtension)
commit 8774c7d1124bf4420502ab86d8b6630b06546ece
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Tue Dec 9 23:47:32 2008 -0800
XQuartz: Avoid using login /bin/sh blech. Just use a bash script to start the app, so it will inherit the right environment
(cherry picked from commit f4b7ad9cc6b0c99fc7ee8516c4bf858ece938148)
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 67a80d3..7222f46 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -314,65 +314,79 @@ BOOL xquartz_resetenv_display = NO;
- (void) launch_client:(NSString *)filename
{
- const char *command = [filename UTF8String];
- const char *argv[7];
- int child1, child2 = 0;
- int status;
-
- argv[0] = "/usr/bin/login";
- argv[1] = "-fp";
- argv[2] = getlogin();
- argv[3] = [X11App prefs_get_string:@PREFS_LOGIN_SHELL default:"/bin/sh"];
- argv[4] = "-c";
- argv[5] = command;
- argv[6] = NULL;
-
- /* Do the fork-twice trick to avoid having to reap zombies */
+ const char *command = [filename UTF8String];
+ int child1, child2 = 0;
+ int status;
+ char newcommand[1024];
+ char *newargv[1024];
+ char buf[128];
+ size_t newargc;
+ char *s;
- child1 = fork();
+ if(strlen(command) > 1023) {
+ fprintf(stderr, "Error: command is too long: %s\n", command);
+ return;
+ }
+
+ strlcpy(newcommand, command, 1024);
- switch (child1) {
- case -1: /* error */
- break;
+ for(newargc=0, s=newcommand; *s; newargc++) {
+ for(; *s && *s == ' '; s++);
+ if(!*s)
+ break;
+
+ newargv[newargc] = s;
+ for(; *s && *s != ' '; s++);
+
+ if(*s) {
+ *s='\0';
+ s++;
+ }
+ }
+ newargv[newargc] = NULL;
+
+ s = getenv("DISPLAY");
+ if (xquartz_resetenv_display || s == NULL || s[0] == 0) {
+ snprintf(buf, sizeof(buf), ":%s", display);
+ setenv("DISPLAY", buf, TRUE);
+ }
+
+ /* Do the fork-twice trick to avoid having to reap zombies */
+ child1 = fork();
+ switch (child1) {
+ case -1: /* error */
+ break;
- case 0: /* child1 */
- child2 = fork();
+ case 0: /* child1 */
+ child2 = fork();
- switch (child2) {
- int max_files, i;
- char buf[1024], *temp;
-
- case -1: /* error */
- _exit(1);
-
- case 0: /* child2 */
- /* close all open files except for standard streams */
- max_files = sysconf(_SC_OPEN_MAX);
- for (i = 3; i < max_files; i++) close(i);
-
- /* ensure stdin is on /dev/null */
- close(0);
- open("/dev/null", O_RDONLY);
-
- /* Setup environment */
- temp = getenv("DISPLAY");
- if (xquartz_resetenv_display || temp == NULL || temp[0] == 0) {
- snprintf(buf, sizeof(buf), ":%s", display);
- setenv("DISPLAY", buf, TRUE);
- }
-
- execvp(argv[0], (char **const) argv);
-
- _exit(2);
-
- default: /* parent (child1) */
- _exit(0);
- }
- break;
+ switch (child2) {
+ int max_files, i;
+
+ case -1: /* error */
+ _exit(1);
+
+ case 0: /* child2 */
+ /* close all open files except for standard streams */
+ max_files = sysconf(_SC_OPEN_MAX);
+ for(i = 3; i < max_files; i++)
+ close(i);
+
+ /* ensure stdin is on /dev/null */
+ close(0);
+ open("/dev/null", O_RDONLY);
+
+ execvp(newargv[0], (char **const) newargv);
+ _exit(2);
+
+ default: /* parent (child1) */
+ _exit(0);
+ }
+ break;
- default: /* parent */
- waitpid(child1, &status, 0);
- }
+ default: /* parent */
+ waitpid(child1, &status, 0);
+ }
}
- (void) app_selected:sender
diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
new file mode 100755
index 0000000..5e00a82
--- /dev/null
+++ b/hw/xquartz/bundle/X11.sh
@@ -0,0 +1,3 @@
+#!/bin/bash --login
+
+./X11 "${@}"
diff --git a/hw/xquartz/bundle/mk_bundke.sh b/hw/xquartz/bundle/mk_bundke.sh
index 0b2a144..5c5733a 100755
--- a/hw/xquartz/bundle/mk_bundke.sh
+++ b/hw/xquartz/bundle/mk_bundke.sh
@@ -20,6 +20,9 @@ install -m 644 Resources/X11.icns ${BUNDLE_ROOT}/Contents/Resources
install -m 644 Info.plist ${BUNDLE_ROOT}/Contents
install -m 644 PkgInfo ${BUNDLE_ROOT}/Contents
+mkdir -p ${BUNDLE_ROOT}/Contents/MacOS
+install -m 755 X11.sh ${BUNDLE_ROOT}/Contents/MacOS
+
if [[ $(id -u) == 0 ]] ; then
chown -R root:admin ${BUNDLE_ROOT}
fi
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 6b48c13..7677a9a 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -529,22 +529,39 @@ int main(int argc, char **argv, char **envp) {
return EXIT_SUCCESS;
}
-
-static int execute(const char *command) {
- const char *newargv[7];
- const char **s;
- newargv[0] = "/usr/bin/login";
- newargv[1] = "-fp";
- newargv[2] = getlogin();
- newargv[3] = command_from_prefs("login_shell", DEFAULT_SHELL);
- newargv[4] = "-c";
- newargv[5] = command;
- newargv[6] = NULL;
+static int execute(const char *command) {
+ char newcommand[1024];
+ char *newargv[1024];
+ size_t newargc;
+ char *s;
+ char **p;
+
+ if(strlen(command) > 1023) {
+ fprintf(stderr, "Error: command is too long: %s\n", command);
+ return 1;
+ }
+
+ strlcpy(newcommand, command, 1024);
+
+ for(newargc=0, s=newcommand; *s; newargc++) {
+ for(; *s && *s == ' '; s++);
+ if(!*s)
+ break;
+
+ newargv[newargc] = s;
+ for(; *s && *s != ' '; s++);
+
+ if(*s) {
+ *s='\0';
+ s++;
+ }
+ }
+ newargv[newargc] = NULL;
fprintf(stderr, "X11.app: Launching %s:\n", command);
- for(s=newargv; *s; s++) {
- fprintf(stderr, "\targv[%ld] = %s\n", (long int)(s - newargv), *s);
+ for(p=newargv; *p; p++) {
+ fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p);
}
execvp (newargv[0], (char * const *) newargv);
commit 271f04bdad30735840071c0b5ac3038d7e66ccc0
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Mon Dec 8 21:59:49 2008 -0800
XQuartz: unset DISPLAY if we didn't get a launchd socket handoff
(cherry picked from commit b959727f38733009c6381cc8ca06b5984257bdac)
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 8b6d458..6b48c13 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -278,8 +278,12 @@ static int create_socket(char *filename_out) {
return 0;
}
+static int launchd_socket_handed_off = 0;
+
kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) {
socket_handoff_t *handoff_data;
+
+ launchd_socket_handed_off = 1;
handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
if(!handoff_data) {
@@ -318,6 +322,12 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
char **_envp = alloca((envpCnt + 1) * sizeof(char *));
size_t i;
+ /* If we didn't get handed a launchd DISPLAY socket, we shoul
+ * unset DISPLAY or we can run into problems with pbproxy
+ */
+ if(!launchd_socket_handed_off)
+ unsetenv("DISPLAY");
+
if(!_argv || !_envp) {
return KERN_FAILURE;
}
commit 639b9cd2bdfafd6dfcdb648c1e33a8ba347830c3
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Mon Dec 8 21:00:11 2008 -0800
XQuartz: unsetenv(DISPLAY) if we're not org.x.X11
Also some prefix related fixes.
(cherry picked from commit fd459e96581a883e30323c840b71004aa0747169)
diff --git a/configure.ac b/configure.ac
index 7142428..e56de5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,7 @@ AC_PROG_LEX
AC_PROG_YACC
AC_SYS_LARGEFILE
XORG_PROG_RAWCPP
+AC_PATH_PROG(SED,sed)
dnl Check for dtrace program (needed to build Xserver dtrace probes)
dnl Also checks for <sys/sdt.h>, since some Linux distros have an
@@ -491,6 +492,14 @@ AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir
[ APPLE_APPLICATIONS_DIR="${withval}" ],
[ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
AC_SUBST([APPLE_APPLICATIONS_DIR])
+AC_ARG_WITH(apple-application-name,AS_HELP_STRING([--with-apple-application-name=NAME], [Name for the .app (default: X11)]),
+ [ APPLE_APPLICATION_NAME="${withval}" ],
+ [ APPLE_APPLICATION_NAME="X11" ])
+AC_SUBST([APPLE_APPLICATION_NAME])
+AC_ARG_WITH(apple-application-id,AS_HELP_STRING([--with-apple-application-id=VALUE], [CFBundleIdentification for the .app (default: org.x.X11)]),
+ [ APPLE_APPLICATION_ID="${withval}" ],
+ [ APPLE_APPLICATION_ID="org.x.X11" ])
+AC_SUBST([APPLE_APPLICATION_ID])
AC_ARG_ENABLE(builddocs, AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
[BUILDDOCS=$enableval],
[BUILDDOCS=no])
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index d1eb283..e5e2e9e 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -7,7 +7,8 @@ AM_CPPFLAGS = \
-DINXQUARTZ \
-DUSE_NEW_CLUT \
-DXFree86Server \
- -I$(top_srcdir)/miext/rootless
+ -I$(top_srcdir)/miext/rootless \
+ -DX11LIBDIR=\"$(libdir)\"
if GLX
GL_DIR = GL
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 18ab690..add5b01 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -54,7 +54,7 @@
// pbproxy/pbproxy.h
extern BOOL xpbproxy_init (void);
-#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
+#define DEFAULTS_FILE X11LIBDIR"/X11/xserver/Xquartz.plist"
#ifndef XSERVER_VERSION
#define XSERVER_VERSION "?"
diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist
deleted file mode 100644
index f4a9287..0000000
--- a/hw/xquartz/bundle/Info.plist
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>X11</string>
- <key>CFBundleGetInfoString</key>
- <string>X11</string>
- <key>CFBundleIconFile</key>
- <string>X11.icns</string>
- <key>CFBundleIdentifier</key>
- <string>org.x.X11</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>X11</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>2.3.2</string>
- <key>CFBundleVersion</key>
- <string>2.3.2</string>
- <key>CFBundleSignature</key>
- <string>x11a</string>
- <key>CSResourcesFileMapped</key>
- <true/>
- <key>NSHumanReadableCopyright</key>
- <string>Copyright © 2003-2008, Apple Inc.
-Copyright © 2003, XFree86 Project, Inc.
-Copyright © 2003-2008, X.org Foundation, Inc.
-</string>
- <key>NSMainNibFile</key>
- <string>main</string>
- <key>NSPrincipalClass</key>
- <string>X11Application</string>
-</dict>
-</plist>
diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
new file mode 100644
index 0000000..16434f2
--- /dev/null
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>X11</string>
+ <key>CFBundleGetInfoString</key>
+ <string>APPLE_APPLICATION_NAME</string>
+ <key>CFBundleIconFile</key>
+ <string>X11.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>APPLE_APPLICATION_ID</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>APPLE_APPLICATION_NAME</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>2.3.2</string>
+ <key>CFBundleVersion</key>
+ <string>2.3.2</string>
+ <key>CFBundleSignature</key>
+ <string>x11a</string>
+ <key>CSResourcesFileMapped</key>
+ <true/>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2003-2008, Apple Inc.
+Copyright © 2003, XFree86 Project, Inc.
+Copyright © 2003-2008, X.org Foundation, Inc.
+</string>
+ <key>NSMainNibFile</key>
+ <string>main</string>
+ <key>NSPrincipalClass</key>
+ <string>X11Application</string>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 7b76f84..e765d6e 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -1,12 +1,23 @@
+include cpprules.in
+
+CPP_FILES_FLAGS = \
+ -DAPPLE_APPLICATION_ID="$(APPLE_APPLICATION_ID)" \
+ -DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)"
+
install-data-hook:
- ./mk_bundke.sh $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/X11.app
+ ./mk_bundke.sh $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app
+
+noinst_PRE = Info.plist.cpp
+noinst_DATA = $(noinst_PRE:plist.cpp=plist)
+
+CLEANFILES = $(noinst_DATA)
resourcedir=$(libdir)/X11/xserver
resource_DATA = Xquartz.plist
EXTRA_DIST = \
mk_bundke.sh \
- Info.plist \
+ Info.plist.cpp \
PkgInfo \
$(resource_DATA) \
Resources/da.lproj/InfoPlist.strings \
diff --git a/hw/xquartz/bundle/cpprules.in b/hw/xquartz/bundle/cpprules.in
new file mode 100644
index 0000000..f32eafc
--- /dev/null
+++ b/hw/xquartz/bundle/cpprules.in
@@ -0,0 +1,37 @@
+# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
+# to cpp, because that trick does not work on all ANSI C preprocessors.
+# Delete line numbers from the cpp output (-P is not portable, I guess).
+# Allow XCOMM to be preceded by whitespace and provide a means of generating
+# output lines with trailing backslashes.
+# Allow XHASH to always be substituted, even in cases where XCOMM isn't.
+
+CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \
+ -e '/^\#line *[0-9][0-9]* *.*$$/d' \
+ -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \
+ -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
+ -e '/^[ ]*XHASH/s/XHASH/\#/' \
+ -e '/XSLASHGLOB/s/XSLASHGLOB/\/\*/' \
+ -e '/\@\@$$/s/\@\@$$/\\/'
+
+# Strings to replace in man pages
+XORGRELSTRING = @PACKAGE_STRING@
+ XORGMANNAME = X Version 11
+
+MANDEFS = \
+ -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \
+ -D__appmansuffix__=$(APP_MAN_SUFFIX) \
+ -D__filemansuffix__=$(FILE_MAN_SUFFIX) \
+ -D__libmansuffix__=$(LIB_MAN_SUFFIX) \
+ -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \
+ -D__XSERVERNAME__=Xorg -D__XCONFIGFILE__=xorg.conf \
+ -D__xinitdir__=$(XINITDIR) \
+ -D__bindir__=$(bindir) \
+ -DSHELL_CMD=$(SHELL_CMD) $(ARCHMANDEFS)
+
+SUFFIXES = .$(APP_MAN_SUFFIX) .man .cpp
+
+.cpp:
+ $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@
+
+.man.$(APP_MAN_SUFFIX):
+ $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 0e4ed34..8b6d458 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -59,8 +59,8 @@ extern int noPanoramiXExtension;
extern int xquartz_resetenv_display;
-#define DEFAULT_CLIENT "/usr/X11/bin/xterm"
-#define DEFAULT_STARTX "/usr/X11/bin/startx"
+#define DEFAULT_CLIENT X11BINDIR "/xterm"
+#define DEFAULT_STARTX X11BINDIR "/startx"
#define DEFAULT_SHELL "/bin/sh"
#ifndef BUILD_DATE
@@ -420,19 +420,49 @@ int startup_trigger(int argc, char **argv, char **envp) {
}
/** Setup the environment we want our child processes to inherit */
-static void setup_env() {
+static void ensure_path(const char *dir) {
char buf[1024], *temp;
-
+
/* Make sure /usr/X11/bin is in the $PATH */
temp = getenv("PATH");
if(temp == NULL || temp[0] == 0) {
- snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", X11BINDIR);
+ snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", dir);
setenv("PATH", buf, TRUE);
} else if(strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) {
- snprintf(buf, sizeof(buf), "%s:%s", temp, X11BINDIR);
+ snprintf(buf, sizeof(buf), "%s:%s", temp, dir);
setenv("PATH", buf, TRUE);
}
+}
+
+static void setup_env() {
+ char *temp;
+ const char *pds = NULL;
+
+ /* Pass on our prefs domain to startx and its inheritors (mainly for
+ * quartz-wm and the Xquartz stub's MachIPC)
+ */
+ CFBundleRef bundle = CFBundleGetMainBundle();
+ if(bundle) {
+ CFStringRef pd = CFBundleGetIdentifier(bundle);
+ if(pd) {
+ pds = CFStringGetCStringPtr(pd, 0);
+ if(pds) {
+ server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1));
+ strcpy(server_bootstrap_name, pds);
+ setenv("X11_PREFS_DOMAIN", pds, 1);
+ }
+ }
+ }
+ /* If we're not org.x.X11, we want to unset DISPLAY, so we don't
+ * use the launchd DISPLAY socket.
+ */
+ if(pds == NULL || strcmp(pds, "org.x.X11") != 0)
+ unsetenv("DISPLAY");
+
+ /* Make sure PATH is right */
+ ensure_path(X11BINDIR);
+
/* cd $HOME */
temp = getenv("HOME");
if(temp != NULL && temp[0] != '\0')
@@ -455,22 +485,6 @@ int main(int argc, char **argv, char **envp) {
/* Setup the initial crasherporter info */
strlcpy(__crashreporter_info__, __crashreporter_info__base, __crashreporter_info__len);
-
- /* Pass on our prefs domain to startx and its inheritors (mainly for
- * quartz-wm and the Xquartz stub's MachIPC)
- */
- CFBundleRef bundle = CFBundleGetMainBundle();
- if(bundle) {
- CFStringRef pd = CFBundleGetIdentifier(bundle);
- if(pd) {
- const char *pds = CFStringGetCStringPtr(pd, 0);
- if(pds) {
- server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1));
- strcpy(server_bootstrap_name, pds);
- setenv("X11_PREFS_DOMAIN", pds, 1);
- }
- }
- }
fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
for(i=0; i < argc; i++) {
More information about the xorg-commit
mailing list