diff options
author | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2009-10-27 17:16:57 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2009-11-11 18:00:19 -0800 |
commit | e87a03fd531ce7974877688680d3bf9b85c2d835 (patch) | |
tree | fab7506f05d809b9f4db3898992aee28909fbeeb /hw/xquartz | |
parent | 15fc56addcc906592af7c0f4c0a5ac906fa5c389 (diff) |
XQuartz: pbproxy: Wait for the server to finish starting up, so display is valid.
Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
Diffstat (limited to 'hw/xquartz')
-rw-r--r-- | hw/xquartz/pbproxy/app-main.m | 4 | ||||
-rw-r--r-- | hw/xquartz/pbproxy/main.m | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m index d4b43c6ae..f3f683af3 100644 --- a/hw/xquartz/pbproxy/app-main.m +++ b/hw/xquartz/pbproxy/app-main.m @@ -37,7 +37,11 @@ static const char *app_prefs_domain = "org.x.X11"; CFStringRef app_prefs_domain_cfstr; +/* Stubs */ char *display = NULL; +BOOL serverInitComplete = YES; +pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER; static void signal_handler (int sig) { switch(sig) { diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m index 5bc518243..d26b1b127 100644 --- a/hw/xquartz/pbproxy/main.m +++ b/hw/xquartz/pbproxy/main.m @@ -47,6 +47,20 @@ BOOL xpbproxy_is_standalone = NO; x_selection *_selection_object; +extern BOOL serverInitComplete; +extern pthread_mutex_t serverInitCompleteMutex; +extern pthread_cond_t serverInitCompleteCond; + +static inline void wait_for_server_init(void) { + /* If the server hasn't finished initializing, wait for it... */ + if(!serverInitComplete) { + pthread_mutex_lock(&serverInitCompleteMutex); + while(!serverInitComplete) + pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex); + pthread_mutex_unlock(&serverInitCompleteMutex); + } +} + static int x_io_error_handler (Display *dpy) { /* We lost our connection to the server. */ @@ -85,6 +99,8 @@ static void *xpbproxy_x_thread(void *args) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; size_t i; + wait_for_server_init(); + for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) { xpbproxy_dpy = XOpenDisplay(NULL); |