summaryrefslogtreecommitdiff
path: root/mi/mieq.c
diff options
context:
space:
mode:
Diffstat (limited to 'mi/mieq.c')
-rw-r--r--mi/mieq.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/mi/mieq.c b/mi/mieq.c
index db48f55e5..2905c7782 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -38,2 +38,7 @@ in this Software without prior written authorization from The Open Group.
+#ifdef XQUARTZ
+#include <pthread.h>
+static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
# define NEED_EVENTS
@@ -141,2 +146,5 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
+#ifdef XQUARTZ
+ pthread_mutex_lock(&miEventQueueMutex);
+#endif
@@ -159,2 +167,6 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
if (laste->nevents > 6) {
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
+
ErrorF("[mi] mieqEnqueue: more than six valuator events; dropping.\n");
@@ -170,2 +182,5 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
(v->deviceid & DEVICE_BITS))) {
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
ErrorF("[mi] mieqEnequeue: out-of-order valuator event; dropping.\n");
@@ -175,2 +190,5 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
memcpy((laste->events[laste->nevents++].event), e, sizeof(xEvent));
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
return;
@@ -194,2 +212,5 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
}
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
return;
@@ -211,2 +232,5 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
ErrorF("[mi] Running out of memory. Tossing event.\n");
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
return;
@@ -231,2 +255,5 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
miEventQueue.tail = (oldtail + 1) % QUEUE_SIZE;
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
}
@@ -236,2 +263,5 @@ mieqSwitchScreen(DeviceIntPtr pDev, ScreenPtr pScreen, Bool fromDIX)
{
+#ifdef XQUARTZ
+ pthread_mutex_lock(&miEventQueueMutex);
+#endif
EnqueueScreen(pDev) = pScreen;
@@ -239,2 +269,5 @@ mieqSwitchScreen(DeviceIntPtr pDev, ScreenPtr pScreen, Bool fromDIX)
DequeueScreen(pDev) = pScreen;
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
}
@@ -244,2 +277,5 @@ mieqSetHandler(int event, mieqHandler handler)
{
+#ifdef XQUARTZ
+ pthread_mutex_lock(&miEventQueueMutex);
+#endif
if (handler && miEventQueue.handlers[event])
@@ -249,2 +285,5 @@ mieqSetHandler(int event, mieqHandler handler)
miEventQueue.handlers[event] = handler;
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
}
@@ -315,2 +354,6 @@ mieqProcessInputEvents(void)
+#ifdef XQUARTZ
+ pthread_mutex_lock(&miEventQueueMutex);
+#endif
+
while (miEventQueue.head != miEventQueue.tail) {
@@ -338,2 +381,6 @@ mieqProcessInputEvents(void)
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
+
type = event->u.u.type;
@@ -387,3 +434,10 @@ mieqProcessInputEvents(void)
miPointerUpdateSprite(dev);
+
+#ifdef XQUARTZ
+ pthread_mutex_lock(&miEventQueueMutex);
+#endif
}
+#ifdef XQUARTZ
+ pthread_mutex_unlock(&miEventQueueMutex);
+#endif
}