summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/xquartz/pbproxy/app-main.m2
-rw-r--r--hw/xquartz/pbproxy/main.m25
2 files changed, 23 insertions, 4 deletions
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index e4a4652fc..cb0fa5744 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -37,6 +37,8 @@
static const char *app_prefs_domain = "org.x.X11";
CFStringRef app_prefs_domain_cfstr;
+char *display = NULL;
+
static void signal_handler (int sig) {
switch(sig) {
case SIGHUP:
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index efa42e3a3..17720abeb 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -31,6 +31,7 @@
#import "x-selection.h"
#include <pthread.h>
+#include <unistd.h>
#include <X11/extensions/applewm.h>
Display *xpbproxy_dpy;
@@ -38,6 +39,8 @@ int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
BOOL xpbproxy_have_xfixes;
+extern char *display;
+
#ifdef STANDALONE_XPBPROXY
BOOL xpbproxy_is_standalone = NO;
#endif
@@ -67,10 +70,24 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
BOOL xpbproxy_init (void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- xpbproxy_dpy = XOpenDisplay (NULL);
+ size_t i;
+
+ for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) {
+ xpbproxy_dpy = XOpenDisplay(NULL);
+
+ if(!xpbproxy_dpy && display) {
+ char *_display = alloca(sizeof(char) * (strlen(display) + 2));
+ strcpy(_display+1, display);
+ *_display=':';
+
+ xpbproxy_dpy=XOpenDisplay(_display);
+ }
+ if(!xpbproxy_dpy)
+ sleep(1);
+ }
+
if (xpbproxy_dpy == NULL) {
- fprintf (stderr, "can't open default display\n");
+ fprintf (stderr, "xpbproxy: can't open default display\n");
[pool release];
return FALSE;
}
@@ -80,7 +97,7 @@ BOOL xpbproxy_init (void) {
if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
&xpbproxy_apple_wm_error_base)) {
- fprintf (stderr, "can't open AppleWM server extension\n");
+ fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
[pool release];
return FALSE;
}