summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-12-08 21:00:11 -0800
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-12-10 15:05:34 -0800
commit99b2cbf061a9d074e66e6220dc08f8b4624ea6bb (patch)
treecb3aba3fafa5f65e48bce9a9f4f808bbc3413699
parente45877e05eb650ba0d6920133d084edf936f6580 (diff)
XQuartz: unsetenv(DISPLAY) if we're not org.x.X11
Also some prefix related fixes. (cherry picked from commit fd459e96581a883e30323c840b71004aa0747169)
-rw-r--r--configure.ac9
-rw-r--r--hw/xquartz/Makefile.am3
-rw-r--r--hw/xquartz/X11Application.m2
-rw-r--r--hw/xquartz/bundle/Info.plist.cpp (renamed from hw/xquartz/bundle/Info.plist)6
-rw-r--r--hw/xquartz/bundle/Makefile.am15
-rw-r--r--hw/xquartz/bundle/cpprules.in37
-rw-r--r--hw/xquartz/mach-startup/bundle-main.c58
7 files changed, 101 insertions, 29 deletions
diff --git a/configure.ac b/configure.ac
index 486dad869..efe347f8a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,2 +65,3 @@ AC_SYS_LARGEFILE
XORG_PROG_RAWCPP
+AC_PATH_PROG(SED,sed)
@@ -487,2 +488,10 @@ AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir
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)]),
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index d1eb283e4..e5e2e9e37 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -9,3 +9,4 @@ AM_CPPFLAGS = \
-DXFree86Server \
- -I$(top_srcdir)/miext/rootless
+ -I$(top_srcdir)/miext/rootless \
+ -DX11LIBDIR=\"$(libdir)\"
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 21013d90d..371b6d69d 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -56,3 +56,3 @@ extern BOOL xpbproxy_init (void);
-#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
+#define DEFAULTS_FILE X11LIBDIR"/X11/xserver/Xquartz.plist"
diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist.cpp
index f4a928738..16434f268 100644
--- a/hw/xquartz/bundle/Info.plist
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -9,3 +9,3 @@
<key>CFBundleGetInfoString</key>
- <string>X11</string>
+ <string>APPLE_APPLICATION_NAME</string>
<key>CFBundleIconFile</key>
@@ -13,3 +13,3 @@
<key>CFBundleIdentifier</key>
- <string>org.x.X11</string>
+ <string>APPLE_APPLICATION_ID</string>
<key>CFBundleInfoDictionaryVersion</key>
@@ -17,3 +17,3 @@
<key>CFBundleName</key>
- <string>X11</string>
+ <string>APPLE_APPLICATION_NAME</string>
<key>CFBundlePackageType</key>
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 7b76f846b..e765d6e41 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -1,3 +1,14 @@
+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)
@@ -8,3 +19,3 @@ EXTRA_DIST = \
mk_bundke.sh \
- Info.plist \
+ Info.plist.cpp \
PkgInfo \
diff --git a/hw/xquartz/bundle/cpprules.in b/hw/xquartz/bundle/cpprules.in
new file mode 100644
index 000000000..f32eafc06
--- /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 0e4ed3411..8b6d45849 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -61,4 +61,4 @@ 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"
@@ -422,5 +422,5 @@ 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 */
@@ -428,9 +428,39 @@ static void setup_env() {
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 */
@@ -457,18 +487,2 @@ int main(int argc, char **argv, char **envp) {
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);
- }
- }
- }