summaryrefslogtreecommitdiff
path: root/mi/mieq.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-04-02 15:36:26 +0930
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-04-02 15:36:26 +0930
commite8777a91f37d828b9df839bf3d9cf2f954bdddb0 (patch)
tree07dbc5bb75954b39eb84809907f58025b3419773 /mi/mieq.c
parenta12054757d21edacc1c24c3077b9214726652829 (diff)
parent96ce17aa94413c4b8bcb61cae71167050130a307 (diff)
Merge branch 'master' into mpx
Conflicts: Xi/closedev.c Xi/exevents.c Xi/extinit.c Xi/listdev.c dix/window.c hw/xfree86/common/xf86Xinput.c include/extinit.h mi/mipointer.c
Diffstat (limited to 'mi/mieq.c')
-rw-r--r--mi/mieq.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/mi/mieq.c b/mi/mieq.c
index 4949f20c1..9c670612a 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -81,6 +81,7 @@ typedef struct _EventQueue {
EventRec events[QUEUE_SIZE]; /* static allocation for signals */
ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
+ mieqHandler handlers[128]; /* custom event handler */
} EventQueueRec, *EventQueuePtr;
static EventQueueRec miEventQueue;
@@ -88,11 +89,15 @@ static EventQueueRec miEventQueue;
Bool
mieqInit()
{
+ int i;
+
miEventQueue.head = miEventQueue.tail = 0;
miEventQueue.lastEventTime = GetTimeInMillis ();
miEventQueue.lastMotion = FALSE;
miEventQueue.pEnqueueScreen = screenInfo.screens[0];
miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen;
+ for (i = 0; i < 128; i++)
+ miEventQueue.handlers[i] = NULL;
SetInputCheck(&miEventQueue.head, &miEventQueue.tail);
return TRUE;
}
@@ -188,6 +193,16 @@ mieqSwitchScreen(ScreenPtr pScreen, Bool fromDIX)
miEventQueue.pDequeueScreen = pScreen;
}
+void
+mieqSetHandler(int event, mieqHandler handler)
+{
+ if (handler && miEventQueue.handlers[event])
+ ErrorF("mieq: warning: overriding existing handler %p with %p for "
+ "event %d\n", miEventQueue.handlers[event], handler, event);
+
+ miEventQueue.handlers[event] = handler;
+}
+
/* Call this from ProcessInputEvents(). */
void
mieqProcessInputEvents()
@@ -225,6 +240,15 @@ mieqProcessInputEvents()
else
++miEventQueue.head;
+ /* If someone's registered a custom event handler, let them
+ * steal it. */
+ if (miEventQueue.handlers[e->event->u.u.type]) {
+ miEventQueue.handlers[e->event->u.u.type](miEventQueue.pDequeueScreen->myNum,
+ e->event, dev,
+ e->nevents);
+ return;
+ }
+
/* If this is a core event, make sure our keymap, et al, is
* changed to suit. */
if (e->event[0].u.u.type == KeyPress ||