summaryrefslogtreecommitdiff
path: root/mi/mieq.c
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2007-03-21 00:10:38 +0200
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2007-03-21 00:10:38 +0200
commit80d29475b9a2ebbb303a8e324e09a15c528d5556 (patch)
tree4a2963bad905ae993908d0636dd3f208e30f292d /mi/mieq.c
parentb8df961843a95b29258ae9c5d46ccfc620d8de1c (diff)
mieq: Allow event handlers for arbitrary events to be set
Allow arbitrary events to use mieq by letting custom handlers be set.
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 507cdd337..5bd87ebdb 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -74,6 +74,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;
@@ -81,11 +82,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;
}
@@ -178,6 +183,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()
@@ -215,6 +230,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 ||