summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorPovilas Kanapickas <povilas@radix.lt>2020-09-17 00:55:17 +0300
committerAdam Jackson <ajax@nwnk.net>2020-09-24 17:33:22 +0000
commit5eb985e3531b69d3ddc4dc0d4b69b4280b1626f8 (patch)
treea9a646d3f3b20ea250f36d61f79f0e619f0ebe17 /mi
parenta5f439dcd21b4fda093cb382bb1a758b434a1444 (diff)
mi: Add a callback to notify driver about input event submission
This is useful for mock input drivers that control the server in integration tests. Given that input submission happens on a different thread than processing, it's otherwise impossible for the driver to synchronize with the completion of the processing of submitted events. Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
Diffstat (limited to 'mi')
-rw-r--r--mi/mi.h6
-rw-r--r--mi/mieq.c18
2 files changed, 24 insertions, 0 deletions
diff --git a/mi/mi.h b/mi/mi.h
index 2cd3066c1..8b0a231ca 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -205,6 +205,12 @@ extern _X_EXPORT void mieqProcessDeviceEvent(DeviceIntPtr /* dev */ ,
extern _X_EXPORT void mieqProcessInputEvents(void
);
+extern _X_EXPORT void mieqAddCallbackOnDrained(CallbackProcPtr callback,
+ void *param);
+
+extern _X_EXPORT void mieqRemoveCallbackOnDrained(CallbackProcPtr callback,
+ void *param);
+
extern DeviceIntPtr CopyGetMasterEvent(DeviceIntPtr /* sdev */ ,
InternalEvent * /* original */ ,
InternalEvent * /* copy */
diff --git a/mi/mieq.c b/mi/mieq.c
index 09b71b639..bcd62d572 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -87,6 +87,8 @@ typedef struct _EventQueue {
static EventQueueRec miEventQueue;
+static CallbackListPtr miCallbacksWhenDrained = NULL;
+
static size_t
mieqNumEnqueued(EventQueuePtr eventQueue)
{
@@ -565,5 +567,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();
}