xserver: Branch 'xorg-server-1.5-apple' - 3 commits
Jeremy Huddleston
jeremyhu at kemper.freedesktop.org
Tue Nov 25 11:52:41 PST 2008
hw/xquartz/X11Controller.m | 4 +++-
hw/xquartz/mach-startup/bundle-main.c | 22 +++++++++++++++++-----
hw/xquartz/mach-startup/mach_startup_types.h | 1 -
hw/xquartz/mach-startup/stub.c | 13 +++++++++++--
hw/xquartz/pbproxy/main.m | 6 +++---
5 files changed, 34 insertions(+), 12 deletions(-)
New commits:
commit 7c73f70bd6ca64764170483ea4c82713fbeb2751
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Tue Nov 25 11:25:58 2008 -0800
XQuartz: Simplify the xquartz_resetenv_display path
(cherry picked from commit d2e0624dd30eb234bb25595ceedfa51d48ca1724)
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index ae9429c..233fd4f 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -321,16 +321,6 @@ BOOL xquartz_resetenv_display = NO;
int child1, child2 = 0;
int status;
- if(xquartz_resetenv_display) {
- char _display[32];
- size_t i;
- for(i=0; !display && i < 5; i++)
- sleep(1);
-
- snprintf(_display, sizeof(_display), ":%s", display);
- setenv("DISPLAY", _display, TRUE);
- }
-
argv[0] = "/usr/bin/login";
argv[1] = "-fp";
argv[2] = getlogin();
@@ -368,7 +358,7 @@ BOOL xquartz_resetenv_display = NO;
/* Setup environment */
temp = getenv("DISPLAY");
- if (temp == NULL || temp[0] == 0) {
+ if (xquartz_resetenv_display || temp == NULL || temp[0] == 0) {
snprintf(buf, sizeof(buf), ":%s", display);
setenv("DISPLAY", buf, TRUE);
}
commit bbc490cf68cb1e1e627bee49144cad54c5eb7858
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Tue Nov 25 01:30:03 2008 -0800
XQuartz: Force X11Controller to reset a broken DISPLAY envvar.
(cherry picked from commit f1a52b5b5ac31702497937efe3ac578be9a6c54f)
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 76fbb57..ae9429c 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -55,6 +55,8 @@
#include <sys/types.h>
#include <sys/wait.h>
+BOOL xquartz_resetenv_display = NO;
+
@implementation X11Controller
- (void) awakeFromNib
@@ -319,6 +321,16 @@
int child1, child2 = 0;
int status;
+ if(xquartz_resetenv_display) {
+ char _display[32];
+ size_t i;
+ for(i=0; !display && i < 5; i++)
+ sleep(1);
+
+ snprintf(_display, sizeof(_display), ":%s", display);
+ setenv("DISPLAY", _display, TRUE);
+ }
+
argv[0] = "/usr/bin/login";
argv[1] = "-fp";
argv[2] = getlogin();
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index c1138be..e58277a 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -57,6 +57,8 @@ void DarwinListenOnOpenFD(int fd);
extern int noPanoramiXExtension;
+extern int xquartz_resetenv_display;
+
#define DEFAULT_CLIENT "/usr/X11/bin/xterm"
#define DEFAULT_STARTX "/usr/X11/bin/startx"
#define DEFAULT_SHELL "/bin/sh"
@@ -408,6 +410,9 @@ int startup_trigger(int argc, char **argv, char **envp) {
if((s = getenv("DISPLAY"))) {
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
unsetenv("DISPLAY");
+
+ /* This tells X11Controller to not use the environment's DISPLAY and reset it based on the server's display */
+ xquartz_resetenv_display = 1;
} else {
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
}
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 17720ab..247ff74 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -76,9 +76,9 @@ BOOL xpbproxy_init (void) {
xpbproxy_dpy = XOpenDisplay(NULL);
if(!xpbproxy_dpy && display) {
- char *_display = alloca(sizeof(char) * (strlen(display) + 2));
- strcpy(_display+1, display);
- *_display=':';
+ char _display[32];
+ snprintf(_display, sizeof(_display), ":%s", display);
+ setenv("DISPLAY", _display, TRUE);
xpbproxy_dpy=XOpenDisplay(_display);
}
commit a132f94e5cecb6ca32efffcd29e1f51660675e73
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Tue Nov 25 01:13:35 2008 -0800
XQuartz: Removed hardcoded org.x.X11 from MachIPC as well
(cherry picked from commit b4add7826d485600a13eba6a9c7be533f2c02d51)
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index fa19eab..c1138be 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -73,6 +73,8 @@ const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Bui
char __crashreporter_info__buf[4096];
char *__crashreporter_info__ = __crashreporter_info__buf;
+static char *server_bootstrap_name = "org.x.X11";
+
#define DEBUG 1
/* This is in quartzStartup.c */
@@ -370,7 +372,7 @@ int startup_trigger(int argc, char **argv, char **envp) {
strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
}
- kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
+ kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
if (kr != KERN_SUCCESS) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
fprintf(stderr, "bootstrap_look_up(): %s\n", bootstrap_strerror(kr));
@@ -426,14 +428,19 @@ 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) */
+ /* 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)
+ if(pds) {
+ server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1));
+ strcpy(server_bootstrap_name, pds);
setenv("X11_PREFS_DOMAIN", pds, 1);
+ }
}
}
@@ -445,9 +452,9 @@ int main(int argc, char **argv, char **envp) {
}
}
- mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
+ mp = checkin_or_register(server_bootstrap_name);
if(mp == MACH_PORT_NULL) {
- fprintf(stderr, "NULL mach service: %s", SERVER_BOOTSTRAP_NAME);
+ fprintf(stderr, "NULL mach service: %s", server_bootstrap_name);
return EXIT_FAILURE;
}
diff --git a/hw/xquartz/mach-startup/mach_startup_types.h b/hw/xquartz/mach-startup/mach_startup_types.h
index 97ac147..459c750 100644
--- a/hw/xquartz/mach-startup/mach_startup_types.h
+++ b/hw/xquartz/mach-startup/mach_startup_types.h
@@ -1,7 +1,6 @@
#ifndef _MACH_STARTUP_TYPES_H_
#define _MACH_STARTUP_TYPES_H_
-#define SERVER_BOOTSTRAP_NAME "org.x.X11"
#define STRING_T_SIZE 1024
typedef char string_t[STRING_T_SIZE];
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index aa0505a..893d19c 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -40,6 +40,12 @@
#include <sys/socket.h>
#include <sys/un.h>
+static char *server_bootstrap_name = "org.x.X11";
+
+/* The launchd startup is only designed for the primary X11.app that is
+ * org.x.X11... server_bootstrap_name might be differnet if we were triggered to
+ * start by another X11.app.
+ */
#define kX11AppBundleId "org.x.X11"
#define kX11AppBundlePath "/Contents/MacOS/X11"
@@ -222,6 +228,9 @@ int main(int argc, char **argv, char **envp) {
return EXIT_SUCCESS;
}
+ if(getenv("X11_PREFS_DOMAIN"))
+ server_bootstrap_name = getenv("X11_PREFS_DOMAIN");
+
/* We don't have a mechanism in place to handle this interrupt driven
* server-start notification, so just send the signal now, so xinit doesn't
* time out waiting for it and will just poll for the server.
@@ -238,7 +247,7 @@ int main(int argc, char **argv, char **envp) {
/* Get the $DISPLAY FD */
launchd_fd = launchd_display_fd();
- kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
+ kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
if(kr != KERN_SUCCESS) {
set_x11_path();
@@ -261,7 +270,7 @@ int main(int argc, char **argv, char **envp) {
/* Try connecting for 10 seconds */
for(i=0; i < 80; i++) {
usleep(250000);
- kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
+ kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
if(kr == KERN_SUCCESS)
break;
}
More information about the xorg-commit
mailing list