summaryrefslogtreecommitdiff
path: root/xserver/mi/mieq.c
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/mi/mieq.c')
-rw-r--r--xserver/mi/mieq.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/xserver/mi/mieq.c b/xserver/mi/mieq.c
index 555f0ec7e..c98d46862 100644
--- a/xserver/mi/mieq.c
+++ b/xserver/mi/mieq.c
@@ -87,6 +87,8 @@ typedef struct _EventQueue {
static EventQueueRec miEventQueue;
+static CallbackListPtr miCallbacksWhenDrained = NULL;
+
static size_t
mieqNumEnqueued(EventQueuePtr eventQueue)
{
@@ -126,11 +128,13 @@ mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents)
/* First copy the existing events */
first_hunk = eventQueue->nevents - eventQueue->head;
- memcpy(new_events,
- &eventQueue->events[eventQueue->head],
- first_hunk * sizeof(EventRec));
- memcpy(&new_events[first_hunk],
- eventQueue->events, eventQueue->head * sizeof(EventRec));
+ if (eventQueue->events) {
+ memcpy(new_events,
+ &eventQueue->events[eventQueue->head],
+ first_hunk * sizeof(EventRec));
+ memcpy(&new_events[first_hunk],
+ eventQueue->events, eventQueue->head * sizeof(EventRec));
+ }
/* Initialize the new portion */
for (i = eventQueue->nevents; i < new_nevents; i++) {
@@ -289,7 +293,7 @@ mieqSwitchScreen(DeviceIntPtr pDev, ScreenPtr pScreen, Bool set_dequeue_screen)
void
mieqSetHandler(int event, mieqHandler handler)
{
- if (handler && miEventQueue.handlers[event])
+ if (handler && miEventQueue.handlers[event] != handler)
ErrorF("[mi] mieq: warning: overriding existing handler %p with %p for "
"event %d\n", miEventQueue.handlers[event], handler, event);
@@ -338,6 +342,14 @@ ChangeDeviceID(DeviceIntPtr dev, InternalEvent *event)
case ET_BarrierLeave:
event->barrier_event.deviceid = dev->id;
break;
+ case ET_GesturePinchBegin:
+ case ET_GesturePinchUpdate:
+ case ET_GesturePinchEnd:
+ case ET_GestureSwipeBegin:
+ case ET_GestureSwipeUpdate:
+ case ET_GestureSwipeEnd:
+ event->gesture_event.deviceid = dev->id;
+ break;
default:
ErrorF("[mi] Unknown event type (%d), cannot change id.\n",
event->any.type);
@@ -563,5 +575,21 @@ mieqProcessInputEvents(void)
inProcessInputEvents = FALSE;
+ CallCallbacks(&miCallbacksWhenDrained, NULL);
+
+ input_unlock();
+}
+
+void mieqAddCallbackOnDrained(CallbackProcPtr callback, void *param)
+{
+ input_lock();
+ AddCallback(&miCallbacksWhenDrained, callback, param);
+ input_unlock();
+}
+
+void mieqRemoveCallbackOnDrained(CallbackProcPtr callback, void *param)
+{
+ input_lock();
+ DeleteCallback(&miCallbacksWhenDrained, callback, param);
input_unlock();
}