XQuartz: Force X11Controller to reset a broken DISPLAY envvar.
(cherry picked from commit f1a52b5b5ac31702497937efe3ac578be9a6c54f)
This commit is contained in:
parent
0b314c50a2
commit
94df1ab7f0
|
@ -55,6 +55,8 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
BOOL xquartz_resetenv_display = NO;
|
||||||
|
|
||||||
@implementation X11Controller
|
@implementation X11Controller
|
||||||
|
|
||||||
- (void) awakeFromNib
|
- (void) awakeFromNib
|
||||||
|
@ -319,6 +321,16 @@
|
||||||
int child1, child2 = 0;
|
int child1, child2 = 0;
|
||||||
int status;
|
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[0] = "/usr/bin/login";
|
||||||
argv[1] = "-fp";
|
argv[1] = "-fp";
|
||||||
argv[2] = getlogin();
|
argv[2] = getlogin();
|
||||||
|
|
|
@ -57,6 +57,8 @@ void DarwinListenOnOpenFD(int fd);
|
||||||
|
|
||||||
extern int noPanoramiXExtension;
|
extern int noPanoramiXExtension;
|
||||||
|
|
||||||
|
extern int xquartz_resetenv_display;
|
||||||
|
|
||||||
#define DEFAULT_CLIENT "/usr/X11/bin/xterm"
|
#define DEFAULT_CLIENT "/usr/X11/bin/xterm"
|
||||||
#define DEFAULT_STARTX "/usr/X11/bin/startx"
|
#define DEFAULT_STARTX "/usr/X11/bin/startx"
|
||||||
#define DEFAULT_SHELL "/bin/sh"
|
#define DEFAULT_SHELL "/bin/sh"
|
||||||
|
@ -408,6 +410,9 @@ int startup_trigger(int argc, char **argv, char **envp) {
|
||||||
if((s = getenv("DISPLAY"))) {
|
if((s = getenv("DISPLAY"))) {
|
||||||
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
|
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
|
||||||
unsetenv("DISPLAY");
|
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 {
|
} else {
|
||||||
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
|
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,9 @@ BOOL xpbproxy_init (void) {
|
||||||
xpbproxy_dpy = XOpenDisplay(NULL);
|
xpbproxy_dpy = XOpenDisplay(NULL);
|
||||||
|
|
||||||
if(!xpbproxy_dpy && display) {
|
if(!xpbproxy_dpy && display) {
|
||||||
char *_display = alloca(sizeof(char) * (strlen(display) + 2));
|
char _display[32];
|
||||||
strcpy(_display+1, display);
|
snprintf(_display, sizeof(_display), ":%s", display);
|
||||||
*_display=':';
|
setenv("DISPLAY", _display, TRUE);
|
||||||
|
|
||||||
xpbproxy_dpy=XOpenDisplay(_display);
|
xpbproxy_dpy=XOpenDisplay(_display);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue