aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/pbproxy/main.m
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xquartz/pbproxy/main.m')
-rw-r--r--xorg-server/hw/xquartz/pbproxy/main.m43
1 files changed, 13 insertions, 30 deletions
diff --git a/xorg-server/hw/xquartz/pbproxy/main.m b/xorg-server/hw/xquartz/pbproxy/main.m
index d26b1b127..560cf0182 100644
--- a/xorg-server/hw/xquartz/pbproxy/main.m
+++ b/xorg-server/hw/xquartz/pbproxy/main.m
@@ -82,25 +82,12 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
return 0;
}
-static inline pthread_t create_thread(void *func, void *arg) {
- pthread_attr_t attr;
- pthread_t tid;
-
- pthread_attr_init(&attr);
- pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_create(&tid, &attr, func, arg);
- pthread_attr_destroy(&attr);
-
- return tid;
-}
-
-static void *xpbproxy_x_thread(void *args) {
+int xpbproxy_run (void) {
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);
@@ -108,7 +95,7 @@ static void *xpbproxy_x_thread(void *args) {
char _display[32];
snprintf(_display, sizeof(_display), ":%s", display);
setenv("DISPLAY", _display, TRUE);
-
+
xpbproxy_dpy=XOpenDisplay(_display);
}
if(!xpbproxy_dpy)
@@ -118,7 +105,7 @@ static void *xpbproxy_x_thread(void *args) {
if (xpbproxy_dpy == NULL) {
fprintf (stderr, "xpbproxy: can't open default display\n");
[pool release];
- return NULL;
+ return EXIT_FAILURE;
}
XSetIOErrorHandler (x_io_error_handler);
@@ -128,11 +115,11 @@ static void *xpbproxy_x_thread(void *args) {
&xpbproxy_apple_wm_error_base)) {
fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
[pool release];
- return NULL;
+ return EXIT_FAILURE;
}
-
+
xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
-
+
XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
AppleWMPasteboardNotifyMask);
@@ -140,18 +127,14 @@ static void *xpbproxy_x_thread(void *args) {
if(!xpbproxy_input_register()) {
[pool release];
- return NULL;
+ return EXIT_FAILURE;
}
-
+
[pool release];
-
- xpbproxy_input_loop();
- return NULL;
-}
+
+ CFRunLoopRun();
-BOOL xpbproxy_init (void) {
- create_thread(xpbproxy_x_thread, NULL);
- return TRUE;
+ return EXIT_SUCCESS;
}
id xpbproxy_selection_object (void) {