summaryrefslogtreecommitdiff
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
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>
-rw-r--r--hw/xfree86/common/xf86Helper.c14
-rw-r--r--hw/xfree86/common/xf86Xinput.h5
-rw-r--r--mi/mi.h6
-rw-r--r--mi/mieq.c18
4 files changed, 43 insertions, 0 deletions
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 6bdbf7c15..31aa068e0 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -39,6 +39,7 @@
#endif
#include <X11/X.h>
+#include "mi.h"
#include "os.h"
#include "servermd.h"
#include "pixmapstr.h"
@@ -1738,3 +1739,16 @@ xf86UpdateDesktopDimensions(void)
{
update_desktop_dimensions();
}
+
+
+void
+xf86AddInputEventDrainCallback(CallbackProcPtr callback, void *param)
+{
+ mieqAddCallbackOnDrained(callback, param);
+}
+
+void
+xf86RemoveInputEventDrainCallback(CallbackProcPtr callback, void *param)
+{
+ mieqRemoveCallbackOnDrained(callback, param);
+}
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 0024053c7..749a80d4b 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -199,6 +199,11 @@ xf86VIDrvMsgVerb(InputInfoPtr dev,
MessageType type, int verb, const char *format, va_list args)
_X_ATTRIBUTE_PRINTF(4, 0);
+extern _X_EXPORT void xf86AddInputEventDrainCallback(CallbackProcPtr callback,
+ void *param);
+extern _X_EXPORT void xf86RemoveInputEventDrainCallback(CallbackProcPtr callback,
+ void *param);
+
/* xf86Option.c */
extern _X_EXPORT void
xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts);
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();
}