aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/pbproxy/x-input.m
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-04-02 12:30:48 +0000
committermarha <marha@users.sourceforge.net>2010-04-02 12:30:48 +0000
commit1d59691fe77c20ecb010ea8589a940c4ea6ac356 (patch)
treed1ee8df3981303c35e46905c9df26203bb232973 /xorg-server/hw/xquartz/pbproxy/x-input.m
parent0be07f8b067afad77df8cac086b43f6d213fbe20 (diff)
downloadvcxsrv-1d59691fe77c20ecb010ea8589a940c4ea6ac356.tar.gz
vcxsrv-1d59691fe77c20ecb010ea8589a940c4ea6ac356.tar.bz2
vcxsrv-1d59691fe77c20ecb010ea8589a940c4ea6ac356.zip
Updated to following packages:
pixman-0.18.0 xorg-server-1.8.0
Diffstat (limited to 'xorg-server/hw/xquartz/pbproxy/x-input.m')
-rw-r--r--xorg-server/hw/xquartz/pbproxy/x-input.m100
1 files changed, 43 insertions, 57 deletions
diff --git a/xorg-server/hw/xquartz/pbproxy/x-input.m b/xorg-server/hw/xquartz/pbproxy/x-input.m
index 6ba30c610..405ba3c73 100644
--- a/xorg-server/hw/xquartz/pbproxy/x-input.m
+++ b/xorg-server/hw/xquartz/pbproxy/x-input.m
@@ -39,17 +39,12 @@
#include <unistd.h>
-#include <pthread.h>
-
static CFRunLoopSourceRef xpbproxy_dpy_source;
#ifdef STANDALONE_XPBPROXY
BOOL xpbproxy_prefs_reload = NO;
#endif
-static pthread_mutex_t xpbproxy_dpy_rdy_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t xpbproxy_dpy_rdy_cond = PTHREAD_COND_INITIALIZER;
-
/* Timestamp when the X server last told us it's active */
static Time last_activation_time;
@@ -88,58 +83,51 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
}
}
-void xpbproxy_input_loop() {
- pthread_mutex_lock(&xpbproxy_dpy_rdy_lock);
- while(true) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+static void xpbproxy_process_xevents(void) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if(pool == nil) {
+ fprintf(stderr, "unable to allocate/init auto release pool!\n");
+ return;
+ }
+
+ while (XPending(xpbproxy_dpy) != 0) {
+ XEvent e;
- if(pool == nil) {
- fprintf(stderr, "unable to allocate/init auto release pool!\n");
- break;
- }
+ XNextEvent (xpbproxy_dpy, &e);
- while (XPending(xpbproxy_dpy) != 0) {
- XEvent e;
-
- pthread_mutex_unlock(&xpbproxy_dpy_rdy_lock);
- XNextEvent (xpbproxy_dpy, &e);
-
- switch (e.type) {
- case SelectionClear:
- if([xpbproxy_selection_object() is_active])
- [xpbproxy_selection_object () clear_event:&e.xselectionclear];
- break;
-
- case SelectionRequest:
- [xpbproxy_selection_object () request_event:&e.xselectionrequest];
- break;
-
- case SelectionNotify:
- [xpbproxy_selection_object () notify_event:&e.xselection];
- break;
-
- case PropertyNotify:
- [xpbproxy_selection_object () property_event:&e.xproperty];
- break;
-
- default:
- if(e.type >= xpbproxy_apple_wm_event_base &&
- e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) {
- x_event_apple_wm_notify((XAppleWMNotifyEvent *) &e);
- } else if(e.type == xpbproxy_xfixes_event_base + XFixesSelectionNotify) {
- [xpbproxy_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
- }
- break;
- }
-
- XFlush(xpbproxy_dpy);
- pthread_mutex_lock(&xpbproxy_dpy_rdy_lock);
+ switch (e.type) {
+ case SelectionClear:
+ if([xpbproxy_selection_object() is_active])
+ [xpbproxy_selection_object () clear_event:&e.xselectionclear];
+ break;
+
+ case SelectionRequest:
+ [xpbproxy_selection_object () request_event:&e.xselectionrequest];
+ break;
+
+ case SelectionNotify:
+ [xpbproxy_selection_object () notify_event:&e.xselection];
+ break;
+
+ case PropertyNotify:
+ [xpbproxy_selection_object () property_event:&e.xproperty];
+ break;
+
+ default:
+ if(e.type >= xpbproxy_apple_wm_event_base &&
+ e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) {
+ x_event_apple_wm_notify((XAppleWMNotifyEvent *) &e);
+ } else if(e.type == xpbproxy_xfixes_event_base + XFixesSelectionNotify) {
+ [xpbproxy_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
+ }
+ break;
}
- [pool release];
-
- pthread_cond_wait(&xpbproxy_dpy_rdy_cond, &xpbproxy_dpy_rdy_lock);
+ XFlush(xpbproxy_dpy);
}
+
+ [pool release];
}
static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
@@ -161,7 +149,7 @@ static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
if (*cf_source == NULL)
return FALSE;
- CFRunLoopAddSource (CFRunLoopGetMain (),
+ CFRunLoopAddSource (CFRunLoopGetCurrent (),
*cf_source, kCFRunLoopDefaultMode);
return TRUE;
}
@@ -175,10 +163,8 @@ static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
xpbproxy_prefs_reload = NO;
}
#endif
-
- pthread_mutex_lock(&xpbproxy_dpy_rdy_lock);
- pthread_cond_broadcast(&xpbproxy_dpy_rdy_cond);
- pthread_mutex_unlock(&xpbproxy_dpy_rdy_lock);
+
+ xpbproxy_process_xevents();
}
BOOL xpbproxy_input_register(void) {