summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-11-25 01:30:03 -0800
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-11-25 11:53:06 -0800
commit94df1ab7f09a64f57c1e1453e3640462e984619c (patch)
tree07bcc4097f329118d69b4ecc47d1fbc1f94164c3
parent0b314c50a2a0ca1afbdc06663c3b719b05ebb851 (diff)
XQuartz: Force X11Controller to reset a broken DISPLAY envvar.
(cherry picked from commit f1a52b5b5ac31702497937efe3ac578be9a6c54f)
-rw-r--r--hw/xquartz/X11Controller.m12
-rw-r--r--hw/xquartz/mach-startup/bundle-main.c5
-rw-r--r--hw/xquartz/pbproxy/main.m6
3 files changed, 20 insertions, 3 deletions
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 76fbb573a..ae9429c3e 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 c1138be99..e58277a9e 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 17720abeb..247ff7475 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);
}