This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch wl-input-ack
in repository enlightenment.

View the commit online.

commit 8ab5d0fa17c181d3520991599cb6c3582363ccb6
Author: Cedric BAIL <[email protected]>
AuthorDate: Thu Dec 3 04:05:15 2026 -0600

    e_comp_wl_input - stamp injected input and report which E has processed
    
    A remote peer that sends input measures how long it took to show up,
    on its own clock. It needs a number of its choosing back with the frame
    that reflects the input, and E is the only one that can say which input
    that is. Every injector takes a stamp, an opaque 64 bits where 0 is
    none, and e_comp_wl_input_stamps_get() reports the stamp of the latest
    input E has processed. The API is not released, so the signatures
    change rather than gain a twin.
    
    "Processed" is recorded in the free callback of the ecore event, which
    ecore runs after every handler has returned: E's bindings and grabs,
    then ecore_input_evas, which feeds evas and so the client. The ring slot
    of the event is the data given to ecore, and the slot keeps the event it
    is for, so the callback knows which event it is whatever the order ecore
    frees them in, and one whose slot was reused is told from the one that
    has it now. What is reported is the end of the run of events that are
    all done. A counter of dispatched events would be wrong if a filter or
    ecore_event_del freed an event ahead of its turn. Ecore frees a rejected
    event in its turn, so that case could not be provoked and is read only.
    A sequence number would not do as the data: it becomes NULL on a 32 bit
    build when it wraps, and the event is then never done.
    
    The ring holds the last 1024 stamped events and allocates nothing on the
    input path, where a list node per event would add a malloc to each
    motion of a 1000 Hz mouse. Over the socket E never has that many
    waiting, as it reads a few thousand bytes between two iterations of its
    loop, but a module posting a burst does: the oldest are then forgotten,
    and the reported stamp catches up with a newer event. Events without a
    stamp are not remembered, and neither are those the injector drops (a
    press of a key already down, a code outside the keymap, a touch that is
    not down): a stamp reported for one would claim input that did not
    happen. Nothing is written to the ring before ecore took the event, so
    a failed post leaves it as it was, and runs the free callback so that
    the queued motion and key counters stay right.
    
    What a frame listener reads is the value when the render began, taken
    at EVAS_CALLBACK_RENDER_PRE of the canvas. A canvas that renders in the
    background, as the buffer engine of the headless backend does, delivers
    the end of the render only after the main loop ran again, so the value
    at that point includes input that is not in the frame. A render is not
    started before the previous one ended, so a begin is followed by its
    end, and the first and last callbacks for the end of the render hand
    the listeners, called between them, the value of the render. The canvas
    does not exist yet when the input is initialized, so the callbacks are
    added when the first input is injected. This stays in the Wayland input
    file, and the shared frame listener is unchanged.
    
    wl_test (version 17) injects with a time and a stamp, reads the values,
    posts a burst of motions in one call, and has a frame listener send what
    it reads in its callback. The test checks every kind of input, that
    nothing is processed before it is dispatched, stamp 0, dropped events,
    a burst that overflows the ring and the dispatch of a forgotten event
    in it, an event an ecore filter rejects, and frames caused by a commit
    and by the pointer alone. Setting the stamp when the event is posted,
    remembering stamp 0, moving the reported stamp to the newest one
    recorded, starting a slot as done, or not telling an event whose slot
    was reused each make it fail, as does a frame listener that reads a
    value other than the one of the render. What a render takes from a
    canvas that is busy, which is live against the value of the render, is
    told apart by the next change, which has content to show.
    
    Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
 src/bin/e_comp_wl_input.c             | 219 +++++++++++++++++--
 src/bin/e_comp_wl_input.h             |  47 +++-
 src/modules/wl_test/e_mod_main.c      | 150 ++++++++++++-
 src/protocol/wl-test.xml              |  98 ++++++++-
 src/tests/wayland/meson.build         |   1 +
 src/tests/wayland/test_input_stamps.c | 390 ++++++++++++++++++++++++++++++++++
 6 files changed, 866 insertions(+), 39 deletions(-)

diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c
index 1ca241c17..d99c6eb5e 100644
--- a/src/bin/e_comp_wl_input.c
+++ b/src/bin/e_comp_wl_input.c
@@ -1069,9 +1069,107 @@ static int _inject_keys_queued = 0;
  * however often a remote peer repeats its press. */
 static Eina_List *_inject_held = NULL;
 
+/* The stamps of the injected events, kept in a ring of the last STAMPS_MAX
+ * events that carry one, so that nothing is allocated on the input path.
+ * An event is given a slot when it is posted, and the slot, as the data
+ * ecore keeps with the event, tells the free callback which one is the
+ * event's, whatever order ecore frees them in. A slot also holds the event it
+ * is for, so that an event whose slot was reused is told from the one that
+ * has it now. More than STAMPS_MAX events waiting to be dispatched, which
+ * takes a burst from one call, make the oldest forgotten: the stamp reported
+ * then catches up with a newer event. */
+#define STAMPS_MAX 1024
+
+typedef struct
+{
+   const void *event;
+   uint64_t stamp;
+   Eina_Bool done;
+} E_Comp_Wl_Input_Stamp;
+
+/* What E reports. */
+typedef struct
+{
+   uint64_t processed;
+} E_Comp_Wl_Input_Stamps;
+
+static E_Comp_Wl_Input_Stamp _stamps[STAMPS_MAX];
+/* The number of the next event to be recorded, and the number below which
+ * every event is dispatched or forgotten. The slot of the event numbered n is
+ * n % STAMPS_MAX. */
+static uint64_t _stamps_next = 0;
+static uint64_t _stamps_prefix = 0;
+static E_Comp_Wl_Input_Stamps _stamps_live;
+
+static void _e_comp_wl_input_frame_callbacks_ensure(void);
+
+/* The values E reports from a frame listener: those of the canvas when the
+ * render began, since what happens while it renders is not in the frame. A
+ * render in the background is not started before the previous one is
+ * finished, so a begin is followed by its end. */
+static E_Comp_Wl_Input_Stamps _stamps_render;
+static E_Comp_Wl_Input_Stamps _stamps_frame;
+static Eina_Bool _stamps_in_frame = EINA_FALSE;
+static Eina_Bool _stamps_callbacks = EINA_FALSE;
+
+/* An event is done once ecore frees it, whether it was dispatched or dropped
+ * by a filter, and not necessarily in the order they were posted. What is
+ * reported is the stamp of the last of the events that are all done. */
+static void
+_e_comp_wl_input_stamp_done(E_Comp_Wl_Input_Stamp *slot, const void *ev)
+{
+   if (slot->event != ev) return;
+   slot->event = NULL;
+   slot->done = EINA_TRUE;
+   while ((_stamps_prefix < _stamps_next) &&
+          _stamps[_stamps_prefix % STAMPS_MAX].done)
+     {
+        _stamps_live.processed = _stamps[_stamps_prefix % STAMPS_MAX].stamp;
+        _stamps_prefix++;
+     }
+}
+
+/* Called once a posted event is dispatched, which is after every handler
+ * has run: E's own, then ecore_input_evas, which hands the event to evas and
+ * so to the client. The data is the one given to
+ * _e_comp_wl_input_inject_post(): the slot of the event, or NULL. */
+static void
+_e_comp_wl_input_inject_free(void *data, void *ev)
+{
+   if (data) _e_comp_wl_input_stamp_done(data, ev);
+   free(ev);
+}
+
+/* Post an event from the injectors, remembering its stamp if it has one. A
+ * stamp of 0 is none, and is not remembered. free_cb is called with the
+ * event once it has been dispatched, or if it could not be posted, and has
+ * to end with _e_comp_wl_input_inject_free(). Nothing is written to the
+ * ring unless the event is posted. */
+static void
+_e_comp_wl_input_inject_post(int type, void *ev, Ecore_End_Cb free_cb,
+                             unsigned int timestamp EINA_UNUSED, uint64_t stamp)
+{
+   E_Comp_Wl_Input_Stamp *slot = &_stamps[_stamps_next % STAMPS_MAX];
+
+   _e_comp_wl_input_frame_callbacks_ensure();
+   if (!ecore_event_add(type, ev, free_cb, stamp ? slot : NULL))
+     {
+        free_cb(NULL, ev);
+        return;
+     }
+   if (!stamp) return;
+
+   if ((_stamps_next - _stamps_prefix) >= STAMPS_MAX)
+     _stamps_prefix = _stamps_next - STAMPS_MAX + 1;
+   slot->event = ev;
+   slot->stamp = stamp;
+   slot->done = EINA_FALSE;
+   _stamps_next++;
+}
+
 static void
 _e_comp_wl_input_inject_mouse_post(int type, int device, int button,
-                                   int x, int y, unsigned int timestamp)
+                                   int x, int y, unsigned int timestamp, uint64_t stamp)
 {
    Ecore_Event_Mouse_Button *ev;
 
@@ -1094,19 +1192,19 @@ _e_comp_wl_input_inject_mouse_post(int type, int device, int button,
    ev->multi.radius_y = 1;
    ev->multi.pressure = 1.0;
 
-   ecore_event_add(type, ev, NULL, NULL);
+   _e_comp_wl_input_inject_post(type, ev, _e_comp_wl_input_inject_free, timestamp, stamp);
 }
 
 /* Called once the event has been dispatched, whatever became of it. */
 static void
-_e_comp_wl_input_inject_motion_free(void *data EINA_UNUSED, void *ev)
+_e_comp_wl_input_inject_motion_free(void *data, void *ev)
 {
    _inject_motions_queued--;
-   free(ev);
+   _e_comp_wl_input_inject_free(data, ev);
 }
 
 static void
-_e_comp_wl_input_inject_move_post(int device, int x, int y, unsigned int timestamp)
+_e_comp_wl_input_inject_move_post(int device, int x, int y, unsigned int timestamp, uint64_t stamp)
 {
    Ecore_Event_Mouse_Move *ev;
 
@@ -1130,12 +1228,13 @@ _e_comp_wl_input_inject_move_post(int device, int x, int y, unsigned int timesta
 
    if (device)
      {
-        ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
+        _e_comp_wl_input_inject_post(ECORE_EVENT_MOUSE_MOVE, ev,
+                                     _e_comp_wl_input_inject_free, timestamp, stamp);
         return;
      }
    _inject_motions_queued++;
-   ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev,
-                   _e_comp_wl_input_inject_motion_free, NULL);
+   _e_comp_wl_input_inject_post(ECORE_EVENT_MOUSE_MOVE, ev,
+                                _e_comp_wl_input_inject_motion_free, timestamp, stamp);
 }
 
 static Eina_Bool
@@ -1152,6 +1251,50 @@ _e_comp_wl_input_inject_cb_mouse_move(void *data EINA_UNUSED, int type EINA_UNUS
    return ECORE_CALLBACK_PASS_ON;
 }
 
+/* The canvas takes what it draws from its objects as they are when the
+ * render begins, and may deliver the end of a render only after the main
+ * loop has run again. Whatever E does in between is for the next frame,
+ * which is why what a frame listener reads is taken here and not when it is
+ * called. The two callbacks for the end of the render are the first and the
+ * last of the canvas, so every listener is called between them. */
+static void
+_e_comp_wl_input_cb_render_pre(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   _stamps_render = _stamps_live;
+}
+
+static void
+_e_comp_wl_input_cb_render_post_begin(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   _stamps_frame = _stamps_render;
+   _stamps_in_frame = EINA_TRUE;
+}
+
+static void
+_e_comp_wl_input_cb_render_post_end(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   _stamps_in_frame = EINA_FALSE;
+}
+
+/* The canvas does not exist yet when the input is initialized, so the
+ * callbacks are added when the first input is injected, which comes before
+ * any acknowledgement and any render they are to cover. */
+static void
+_e_comp_wl_input_frame_callbacks_ensure(void)
+{
+   if (_stamps_callbacks || (!e_comp) || (!e_comp->evas)) return;
+   _stamps_callbacks = EINA_TRUE;
+   evas_event_callback_priority_add(e_comp->evas, EVAS_CALLBACK_RENDER_PRE,
+                                    EVAS_CALLBACK_PRIORITY_BEFORE,
+                                    _e_comp_wl_input_cb_render_pre, NULL);
+   evas_event_callback_priority_add(e_comp->evas, EVAS_CALLBACK_RENDER_POST,
+                                    EVAS_CALLBACK_PRIORITY_BEFORE,
+                                    _e_comp_wl_input_cb_render_post_begin, NULL);
+   evas_event_callback_priority_add(e_comp->evas, EVAS_CALLBACK_RENDER_POST,
+                                    EVAS_CALLBACK_PRIORITY_AFTER,
+                                    _e_comp_wl_input_cb_render_post_end, NULL);
+}
+
 static void
 _e_comp_wl_input_inject_init(void)
 {
@@ -1159,6 +1302,7 @@ _e_comp_wl_input_inject_init(void)
     * swallowed: this one must still see it to know where the pointer is. */
    E_LIST_HANDLER_APPEND_PRE(_inject_handlers, ECORE_EVENT_MOUSE_MOVE,
                              _e_comp_wl_input_inject_cb_mouse_move, NULL);
+
 }
 
 static void
@@ -1168,10 +1312,34 @@ _e_comp_wl_input_inject_shutdown(void)
    E_FREE_LIST(_inject_touches, free);
    _inject_held = eina_list_free(_inject_held);
    _dispatched_seen = EINA_FALSE;
+   _stamps_next = _stamps_prefix = 0;
+   memset(&_stamps_live, 0, sizeof(_stamps_live));
+   memset(&_stamps_render, 0, sizeof(_stamps_render));
+   memset(&_stamps_frame, 0, sizeof(_stamps_frame));
+   _stamps_in_frame = EINA_FALSE;
+   if (_stamps_callbacks && e_comp && e_comp->evas)
+     {
+        evas_event_callback_del_full(e_comp->evas, EVAS_CALLBACK_RENDER_PRE,
+                                     _e_comp_wl_input_cb_render_pre, NULL);
+        evas_event_callback_del_full(e_comp->evas, EVAS_CALLBACK_RENDER_POST,
+                                     _e_comp_wl_input_cb_render_post_begin, NULL);
+        evas_event_callback_del_full(e_comp->evas, EVAS_CALLBACK_RENDER_POST,
+                                     _e_comp_wl_input_cb_render_post_end, NULL);
+     }
+   _stamps_callbacks = EINA_FALSE;
    E_FREE_FUNC(_inject_state, xkb_state_unref);
    E_FREE_FUNC(_inject_keymap, xkb_keymap_unref);
 }
 
+E_API Eina_Bool
+e_comp_wl_input_stamps_get(uint64_t *processed)
+{
+   const E_Comp_Wl_Input_Stamps *stamps = _stamps_in_frame ? &_stamps_frame : &_stamps_live;
+
+   if (processed) *processed = stamps->processed;
+   return !!e_comp_wl;
+}
+
 /* ecore_event_add queues, so until a posted motion has been dispatched evas
  * still reports the position from before it. A button pressed in between
  * must use the posted position, or it clicks where the pointer used to be.
@@ -1196,15 +1364,16 @@ e_comp_wl_input_pointer_xy_get(int *x, int *y)
 }
 
 E_API void
-e_comp_wl_input_inject_pointer_motion(int x, int y, unsigned int timestamp)
+e_comp_wl_input_inject_pointer_motion(int x, int y, unsigned int timestamp, uint64_t stamp)
 {
    _inject_x = x;
    _inject_y = y;
-   _e_comp_wl_input_inject_move_post(0, x, y, timestamp);
+   _e_comp_wl_input_inject_move_post(0, x, y, timestamp, stamp);
 }
 
 E_API void
-e_comp_wl_input_inject_pointer_button(unsigned int button, Eina_Bool pressed, unsigned int timestamp)
+e_comp_wl_input_inject_pointer_button(unsigned int button, Eina_Bool pressed, unsigned int timestamp,
+                                      uint64_t stamp)
 {
    int b, x, y;
 
@@ -1220,11 +1389,12 @@ e_comp_wl_input_inject_pointer_button(unsigned int button, Eina_Bool pressed, un
 
    e_comp_wl_input_pointer_xy_get(&x, &y);
    _e_comp_wl_input_inject_mouse_post(pressed ? ECORE_EVENT_MOUSE_BUTTON_DOWN
-                              : ECORE_EVENT_MOUSE_BUTTON_UP, 0, b, x, y, timestamp);
+                              : ECORE_EVENT_MOUSE_BUTTON_UP, 0, b, x, y, timestamp, stamp);
 }
 
 E_API void
-e_comp_wl_input_inject_pointer_axis(Eina_Bool horizontal, int steps, unsigned int timestamp)
+e_comp_wl_input_inject_pointer_axis(Eina_Bool horizontal, int steps, unsigned int timestamp,
+                                    uint64_t stamp)
 {
    Ecore_Event_Mouse_Wheel *ev;
    int x, y;
@@ -1243,7 +1413,8 @@ e_comp_wl_input_inject_pointer_axis(Eina_Bool horizontal, int steps, unsigned in
    ev->x = ev->root.x = x;
    ev->y = ev->root.y = y;
 
-   ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
+   _e_comp_wl_input_inject_post(ECORE_EVENT_MOUSE_WHEEL, ev, _e_comp_wl_input_inject_free,
+                                timestamp, stamp);
 }
 
 static E_Comp_Wl_Input_Touch *
@@ -1264,7 +1435,7 @@ _e_comp_wl_input_inject_touch_find(int id)
  * 0 is the pointer, which is why a touch id has to be positive. */
 E_API void
 e_comp_wl_input_inject_touch(int id, int x, int y, E_Comp_Wl_Touch_Phase phase,
-                             unsigned int timestamp)
+                             unsigned int timestamp, uint64_t stamp)
 {
    E_Comp_Wl_Input_Touch *t;
 
@@ -1283,21 +1454,22 @@ e_comp_wl_input_inject_touch(int id, int x, int y, E_Comp_Wl_Touch_Phase phase,
           }
         t->x = x;
         t->y = y;
-        _e_comp_wl_input_inject_mouse_post(ECORE_EVENT_MOUSE_BUTTON_DOWN, id, 1, x, y, timestamp);
+        _e_comp_wl_input_inject_mouse_post(ECORE_EVENT_MOUSE_BUTTON_DOWN, id, 1, x, y, timestamp,
+                                           stamp);
         break;
 
       case E_COMP_WL_TOUCH_MOVE:
         if (!t) return;
         t->x = x;
         t->y = y;
-        _e_comp_wl_input_inject_move_post(id, x, y, timestamp);
+        _e_comp_wl_input_inject_move_post(id, x, y, timestamp, stamp);
         break;
 
       case E_COMP_WL_TOUCH_UP:
         if (!t) return;
         _inject_touches = eina_list_remove(_inject_touches, t);
         _e_comp_wl_input_inject_mouse_post(ECORE_EVENT_MOUSE_BUTTON_UP, id, 1, t->x, t->y,
-                                           timestamp);
+                                           timestamp, stamp);
         free(t);
         break;
      }
@@ -1360,14 +1532,15 @@ _e_comp_wl_input_inject_keysym_name_get(xkb_keysym_t sym, xkb_keycode_t code, ch
 
 /* Called once the event has been dispatched, whatever became of it. */
 static void
-_e_comp_wl_input_inject_key_free(void *data EINA_UNUSED, void *ev)
+_e_comp_wl_input_inject_key_free(void *data, void *ev)
 {
    _inject_keys_queued--;
-   free(ev);
+   _e_comp_wl_input_inject_free(data, ev);
 }
 
 E_API void
-e_comp_wl_input_inject_key(unsigned int keycode, Eina_Bool pressed, unsigned int timestamp)
+e_comp_wl_input_inject_key(unsigned int keycode, Eina_Bool pressed, unsigned int timestamp,
+                           uint64_t stamp)
 {
    Ecore_Event_Key *ev;
    Eina_List *held;
@@ -1452,6 +1625,6 @@ e_comp_wl_input_inject_key(unsigned int keycode, Eina_Bool pressed, unsigned int
    ev->modifiers = modifiers;
    ev->keycode = code;
    _inject_keys_queued++;
-   ecore_event_add(pressed ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, ev,
-                   _e_comp_wl_input_inject_key_free, NULL);
+   _e_comp_wl_input_inject_post(pressed ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, ev,
+                                _e_comp_wl_input_inject_key_free, timestamp, stamp);
 }
diff --git a/src/bin/e_comp_wl_input.h b/src/bin/e_comp_wl_input.h
index a978ceacc..21790bb2a 100644
--- a/src/bin/e_comp_wl_input.h
+++ b/src/bin/e_comp_wl_input.h
@@ -49,22 +49,36 @@ typedef enum
  * constraints, relative motion, popup dismissal and the idle timer. A
  * motion, a button or a key is not acted on before the call returns, but
  * on the next main loop iteration. The timestamp of each is in milliseconds,
- * from the caller. */
+ * from the caller.
+ *
+ * Each also takes a stamp, an opaque number of the caller's, 0 being none,
+ * that e_comp_wl_input_stamps_get() reports once E has dealt with the event,
+ * so that a remote peer can measure how long its input took to show on its
+ * own clock.
+ *
+ * The last 1024 events with a stamp are remembered, in a ring that costs
+ * no allocation on the input path. When more than that wait to be
+ * dispatched, which one call can cause by posting a burst, the oldest are
+ * forgotten: the stamp reported then catches up with a newer event. An
+ * event without a stamp is not remembered, and neither is one that E
+ * drops, as each injector below says: its stamp is never reported, though
+ * that of a later event is. */
 
 /** The pointer position in canvas coordinates, with a posted motion counted. */
 E_API void e_comp_wl_input_pointer_xy_get(int *x, int *y);
 
 /** Move the pointer to a position in canvas coordinates. */
 E_API void e_comp_wl_input_inject_pointer_motion(int x, int y,
-                                                 unsigned int timestamp);
+                                                 unsigned int timestamp, uint64_t stamp);
 
 /** Press or release a pointer button, BTN_* of linux/input.h, where the
  * pointer is, a motion posted just before included. */
 E_API void e_comp_wl_input_inject_pointer_button(unsigned int button, Eina_Bool pressed,
-                                                 unsigned int timestamp);
+                                                 unsigned int timestamp, uint64_t stamp);
 
 /** Turn a wheel by steps, a click for each, negative for up or left. */
-E_API void e_comp_wl_input_inject_pointer_axis(Eina_Bool horizontal, int steps, unsigned int timestamp);
+E_API void e_comp_wl_input_inject_pointer_axis(Eina_Bool horizontal, int steps, unsigned int timestamp,
+                                               uint64_t stamp);
 
 /** Press or release a key by its evdev code, KEY_* of linux/input.h,
  * read through E's current keymap. It is dealt with as a key of a keyboard
@@ -75,14 +89,35 @@ E_API void e_comp_wl_input_inject_pointer_axis(Eina_Bool horizontal, int steps,
  * E keeps a key down until it is released, as it does for a device. The
  * caller must release every key it pressed, for instance when the remote
  * peer that sent the presses goes away. */
-E_API void e_comp_wl_input_inject_key(unsigned int keycode, Eina_Bool pressed, unsigned int timestamp);
+E_API void e_comp_wl_input_inject_key(unsigned int keycode, Eina_Bool pressed, unsigned int timestamp,
+                                      uint64_t stamp);
 
 /** Put a touch point down, move it or lift it. The id is positive, as 0 is
  * the pointer, and is kept while the point is down. A move or a lift of an
  * id that is not down is ignored, and a lift ignores x and y: the point
  * lifts where it last was. */
 E_API void e_comp_wl_input_inject_touch(int id, int x, int y, E_Comp_Wl_Touch_Phase phase,
-                                        unsigned int timestamp);
+                                        unsigned int timestamp, uint64_t stamp);
+
+/** The stamp of the latest injected input E has processed, to be called from
+ * a frame listener, see e_comp_canvas_frame_listener_add(): the value is
+ * then the one of the render the listener is told about. A stamp of 0 is
+ * none yet, and processed may be NULL. Returns EINA_FALSE if E is not a Wayland
+ * compositor. Called from anywhere else it gives the value now.
+ *
+ * An event is processed once its ecore event has been dispatched: every
+ * handler of E has run, bindings and grabs included, and what the client is
+ * sent has been queued for it. What E draws in answer, the cursor moving, is
+ * in the render that follows, or one later if E defers it. An event that an
+ * ecore filter rejects is counted as processed too, as ecore frees it. The
+ * value is the stamp of the last event of those that are all processed, in
+ * the order they were injected, so it never skips back, and a stamp is
+ * passed over only when it was forgotten.
+ *
+ * What a frame listener may conclude: the render began with the value it
+ * reads, and an event processed while the render was running, in the
+ * background for a canvas that does that, is not in the frame. */
+E_API Eina_Bool e_comp_wl_input_stamps_get(uint64_t *processed);
 
 EINTERN int _e_comp_wl_input_keymap_fd_get(void);
 
diff --git a/src/modules/wl_test/e_mod_main.c b/src/modules/wl_test/e_mod_main.c
index b57f2d1cd..e012067e4 100644
--- a/src/modules/wl_test/e_mod_main.c
+++ b/src/modules/wl_test/e_mod_main.c
@@ -56,6 +56,7 @@ typedef struct _Wl_Test_Frame_Listener
    unsigned int remove_id;
    int x, y;
    E_Comp_Canvas_Frame_Listener *listener; /* NULL once deleted from a callback */
+   Eina_Bool stamps_watch;
    Wl_Test_Frame_Zone zones[FRAME_ZONES_MAX];
 } Wl_Test_Frame_Listener;
 
@@ -460,7 +461,7 @@ _input_timestamp(void)
 static void
 _wl_test_cb_pointer_warp(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, int32_t x, int32_t y)
 {
-   e_comp_wl_input_inject_pointer_motion(x, y, _input_timestamp());
+   e_comp_wl_input_inject_pointer_motion(x, y, _input_timestamp(), 0);
 }
 
 static void
@@ -469,19 +470,19 @@ _wl_test_cb_pointer_move(struct wl_client *client EINA_UNUSED, struct wl_resourc
    int px, py;
 
    e_comp_wl_input_pointer_xy_get(&px, &py);
-   e_comp_wl_input_inject_pointer_motion(px + dx, py + dy, _input_timestamp());
+   e_comp_wl_input_inject_pointer_motion(px + dx, py + dy, _input_timestamp(), 0);
 }
 
 static void
 _wl_test_cb_pointer_button(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, uint32_t button, uint32_t pressed)
 {
-   e_comp_wl_input_inject_pointer_button(button, !!pressed, _input_timestamp());
+   e_comp_wl_input_inject_pointer_button(button, !!pressed, _input_timestamp(), 0);
 }
 
 static void
 _wl_test_cb_pointer_axis(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, uint32_t direction, int32_t steps)
 {
-   e_comp_wl_input_inject_pointer_axis(!!direction, steps, _input_timestamp());
+   e_comp_wl_input_inject_pointer_axis(!!direction, steps, _input_timestamp(), 0);
 }
 
 /* The device number of a touch point is the wl_touch id E sends, and 0 is
@@ -499,21 +500,21 @@ static void
 _wl_test_cb_touch_down(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t id, int32_t x, int32_t y)
 {
    if (!_wl_test_touch_id_check(resource, id)) return;
-   e_comp_wl_input_inject_touch(id, x, y, E_COMP_WL_TOUCH_DOWN, _input_timestamp());
+   e_comp_wl_input_inject_touch(id, x, y, E_COMP_WL_TOUCH_DOWN, _input_timestamp(), 0);
 }
 
 static void
 _wl_test_cb_touch_move(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t id, int32_t x, int32_t y)
 {
    if (!_wl_test_touch_id_check(resource, id)) return;
-   e_comp_wl_input_inject_touch(id, x, y, E_COMP_WL_TOUCH_MOVE, _input_timestamp());
+   e_comp_wl_input_inject_touch(id, x, y, E_COMP_WL_TOUCH_MOVE, _input_timestamp(), 0);
 }
 
 static void
 _wl_test_cb_touch_up(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t id)
 {
    if (!_wl_test_touch_id_check(resource, id)) return;
-   e_comp_wl_input_inject_touch(id, 0, 0, E_COMP_WL_TOUCH_UP, _input_timestamp());
+   e_comp_wl_input_inject_touch(id, 0, 0, E_COMP_WL_TOUCH_UP, _input_timestamp(), 0);
 }
 
 /* E's own generator, the one behind the keyboard_send action: it maps the
@@ -562,7 +563,7 @@ _wl_test_cb_virtual_output_set(struct wl_client *client EINA_UNUSED, struct wl_r
 static void
 _wl_test_cb_key_code(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, uint32_t keycode, uint32_t pressed)
 {
-   e_comp_wl_input_inject_key(keycode, !!pressed, _input_timestamp());
+   e_comp_wl_input_inject_key(keycode, !!pressed, _input_timestamp(), 0);
 }
 
 static Wl_Test_Frame_Listener *
@@ -614,6 +615,16 @@ _wl_test_cb_frame(void *data, const E_Comp_Canvas_Frame *frame)
      fz->argb = *(const unsigned int *)((const unsigned char *)pixels +
                                         (fl->y * fz->pixels_stride) + (fl->x * 4));
 
+   if (fl->stamps_watch)
+     {
+        uint64_t processed;
+
+        e_comp_wl_input_stamps_get(&processed);
+        wl_test_send_frame_stamps(fl->resource, fl->id, zone->num, fz->count,
+                                  processed >> 32, processed & 0xffffffff,
+                                  fz->argb);
+     }
+
    if (!fl->remove_id) return;
    other = _wl_test_frame_listener_find(fl->resource, fl->remove_id);
    if ((other) && (other->listener))
@@ -1057,6 +1068,121 @@ _wl_test_selection_free(Wl_Test_Selection *sel)
    free(sel);
 }
 
+static void
+_wl_test_cb_input_inject(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t kind, int32_t a, int32_t b, int32_t c, uint32_t time, uint32_t stamp_hi, uint32_t stamp_lo)
+{
+   uint64_t stamp = ((uint64_t)stamp_hi << 32) | stamp_lo;
+
+   switch (kind)
+     {
+      case WL_TEST_INJECT_KIND_POINTER_MOTION:
+        e_comp_wl_input_inject_pointer_motion(a, b, time, stamp);
+        break;
+      case WL_TEST_INJECT_KIND_POINTER_BUTTON:
+        e_comp_wl_input_inject_pointer_button(a, !!b, time, stamp);
+        break;
+      case WL_TEST_INJECT_KIND_POINTER_AXIS:
+        e_comp_wl_input_inject_pointer_axis(!!a, b, time, stamp);
+        break;
+      case WL_TEST_INJECT_KIND_KEY:
+        e_comp_wl_input_inject_key(a, !!b, time, stamp);
+        break;
+      case WL_TEST_INJECT_KIND_TOUCH_DOWN:
+        if (!_wl_test_touch_id_check(resource, a)) return;
+        e_comp_wl_input_inject_touch(a, b, c, E_COMP_WL_TOUCH_DOWN, time, stamp);
+        break;
+      case WL_TEST_INJECT_KIND_TOUCH_MOVE:
+        if (!_wl_test_touch_id_check(resource, a)) return;
+        e_comp_wl_input_inject_touch(a, b, c, E_COMP_WL_TOUCH_MOVE, time, stamp);
+        break;
+      case WL_TEST_INJECT_KIND_TOUCH_UP:
+        if (!_wl_test_touch_id_check(resource, a)) return;
+        e_comp_wl_input_inject_touch(a, 0, 0, E_COMP_WL_TOUCH_UP, time, stamp);
+        break;
+      default:
+        wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_METHOD,
+                               "input kind %u is not an inject_kind", kind);
+     }
+}
+
+static void
+_wl_test_cb_get_stamps(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
+{
+   uint64_t processed;
+   Eina_Bool ok = e_comp_wl_input_stamps_get(&processed);
+
+   wl_test_send_stamps(resource, ok, processed >> 32, processed & 0xffffffff);
+}
+
+static void
+_wl_test_cb_frame_stamps_watch(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t id)
+{
+   Wl_Test_Frame_Listener *fl = _wl_test_frame_listener_find(resource, id);
+
+   if (fl) fl->stamps_watch = EINA_TRUE;
+}
+
+static void
+_wl_test_cb_input_burst(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, uint32_t count, int32_t x, int32_t y, uint32_t time, uint32_t step, uint32_t stamp_hi, uint32_t stamp_lo)
+{
+   uint64_t stamp = ((uint64_t)stamp_hi << 32) | stamp_lo;
+   uint32_t i;
+
+   for (i = 0; i < count; i++)
+     e_comp_wl_input_inject_pointer_motion(x, y, time + (i * step), stamp + i);
+}
+
+/* The trap of event_trap: the times it acts on, and what it installed. */
+static struct
+{
+   struct wl_resource *resource;
+   unsigned int reject_time, probe_time;
+   Ecore_Event_Filter *filter;
+   Ecore_Event_Handler *handler;
+} _trap;
+
+static void
+_wl_test_trap_clear(void)
+{
+   if (_trap.filter) ecore_event_filter_del(_trap.filter);
+   if (_trap.handler) ecore_event_handler_del(_trap.handler);
+   memset(&_trap, 0, sizeof(_trap));
+}
+
+static Eina_Bool
+_wl_test_trap_cb_filter(void *data EINA_UNUSED, void *loop_data EINA_UNUSED, int type, void *event)
+{
+   Ecore_Event_Mouse_Move *ev = event;
+
+   if (type != ECORE_EVENT_MOUSE_MOVE) return EINA_TRUE;
+   return ev->timestamp != _trap.reject_time;
+}
+
+static Eina_Bool
+_wl_test_trap_cb_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+   Ecore_Event_Mouse_Move *ev = event;
+   struct wl_resource *resource = _trap.resource;
+   uint64_t processed;
+
+   if (ev->timestamp != _trap.probe_time) return ECORE_CALLBACK_PASS_ON;
+   e_comp_wl_input_stamps_get(&processed);
+   wl_test_send_trap_stamps(resource, processed >> 32, processed & 0xffffffff);
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static void
+_wl_test_cb_event_trap(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t reject_time, uint32_t probe_time)
+{
+   _wl_test_trap_clear();
+   _trap.resource = resource;
+   _trap.reject_time = reject_time;
+   _trap.probe_time = probe_time;
+   _trap.filter = ecore_event_filter_add(NULL, _wl_test_trap_cb_filter, NULL, NULL);
+   _trap.handler = ecore_event_handler_prepend(ECORE_EVENT_MOUSE_MOVE,
+                                               _wl_test_trap_cb_move, NULL);
+}
+
 static const struct wl_test_interface _wl_test_implementation =
 {
    _wl_test_cb_destroy,
@@ -1093,6 +1219,11 @@ static const struct wl_test_interface _wl_test_implementation =
    _wl_test_cb_selection_withdraw,
    _wl_test_cb_selection_watch,
    _wl_test_cb_selection_read,
+   _wl_test_cb_input_inject,
+   _wl_test_cb_get_stamps,
+   _wl_test_cb_frame_stamps_watch,
+   _wl_test_cb_input_burst,
+   _wl_test_cb_event_trap,
 };
 
 static void
@@ -1103,6 +1234,7 @@ _wl_test_cb_unbind(struct wl_resource *resource)
    Eina_List *l, *ll;
 
    if (sel) _wl_test_selection_free(sel);
+   if (_trap.resource == resource) _wl_test_trap_clear();
    _pending_syncs = eina_list_remove(_pending_syncs, resource);
    EINA_LIST_FOREACH_SAFE(_frame_listeners, l, ll, fl)
      if (fl->resource == resource) _wl_test_frame_listener_free(fl);
@@ -1133,7 +1265,7 @@ e_modapi_init(E_Module *m)
         return NULL;
      }
 
-   _wl_test_global = wl_global_create(e_comp_wl->wl.disp, &wl_test_interface, 16,
+   _wl_test_global = wl_global_create(e_comp_wl->wl.disp, &wl_test_interface, 17,
                                      NULL, _wl_test_cb_bind);
    if (!_wl_test_global)
      {
diff --git a/src/protocol/wl-test.xml b/src/protocol/wl-test.xml
index 404a29b0c..84e6de297 100644
--- a/src/protocol/wl-test.xml
+++ b/src/protocol/wl-test.xml
@@ -23,7 +23,7 @@
     DEALINGS IN THE SOFTWARE.
   </copyright>
 
-  <interface name="wl_test" version="16">
+  <interface name="wl_test" version="17">
     <description summary="private interface for the compositor test suite">
       A back door into the compositor for its own test suite. It exposes
       internal state and synthesises input, so it is only built with
@@ -546,5 +546,101 @@
       <arg name="text" type="string"
            summary="the bytes read when there are at most 1024 of them, else empty"/>
     </event>
+
+    <enum name="inject_kind" since="17">
+      <entry name="pointer_motion" value="0" summary="a and b are the position"/>
+      <entry name="pointer_button" value="1" summary="a is the button, b is 1 to press"/>
+      <entry name="pointer_axis" value="2" summary="a is 1 for horizontal, b is the steps"/>
+      <entry name="key" value="3" summary="a is the key code, b is 1 to press"/>
+      <entry name="touch_down" value="4" summary="a is the id, b and c the position"/>
+      <entry name="touch_move" value="5" summary="a is the id, b and c the position"/>
+      <entry name="touch_up" value="6" summary="a is the id"/>
+    </enum>
+
+    <request name="input_inject" since="17">
+      <description summary="inject input with a timestamp and a stamp">
+        Calls the e_comp_wl_input_inject_*() function of the kind, with the
+        timestamp and the stamp given instead of E's clock and none. The
+        stamp is 64 bits, sent as two halves.
+      </description>
+      <arg name="kind" type="uint" enum="inject_kind"/>
+      <arg name="a" type="int"/>
+      <arg name="b" type="int"/>
+      <arg name="c" type="int"/>
+      <arg name="time" type="uint" summary="milliseconds, as the clients are sent it"/>
+      <arg name="stamp_hi" type="uint"/>
+      <arg name="stamp_lo" type="uint"/>
+    </request>
+
+    <request name="get_stamps" since="17">
+      <description summary="ask what e_comp_wl_input_stamps_get() says now">
+        Answers with a stamps event, with the values now. A frame listener
+        reads those of the render it is told about, see frame_stamps_watch.
+      </description>
+    </request>
+
+    <event name="stamps" since="17">
+      <arg name="ok" type="uint" summary="what e_comp_wl_input_stamps_get() returned"/>
+      <arg name="processed_hi" type="uint"/>
+      <arg name="processed_lo" type="uint"/>
+    </event>
+
+    <request name="frame_stamps_watch" since="17">
+      <description summary="have a frame listener report the stamps it sees">
+        From then on the callback of the listener made by frame_listen with
+        this id calls e_comp_wl_input_stamps_get() and sends what it got in
+        a frame_stamps event, along with the pixel it reads through the
+        frame, for every zone it is called for. Does nothing for a number
+        that is not a listener.
+      </description>
+      <arg name="id" type="uint"/>
+    </request>
+
+    <event name="frame_stamps" since="17">
+      <arg name="id" type="uint"/>
+      <arg name="zone" type="uint"/>
+      <arg name="frames" type="uint" summary="frames of this zone the listener was told of, this one included"/>
+      <arg name="processed_hi" type="uint"/>
+      <arg name="processed_lo" type="uint"/>
+      <arg name="argb" type="uint"
+           summary="the pixel asked for in frame_listen, read through this frame, as in frames"/>
+    </event>
+
+    <request name="input_burst" since="17">
+      <description summary="inject many pointer motions in one call">
+        Calls e_comp_wl_input_inject_pointer_motion() count times before E
+        dispatches any of them, which requests sent over the socket cannot
+        do: E reads a few thousand bytes of them between two iterations of
+        its main loop. The motion i is at the position x, y, has the time
+        time + i * step milliseconds and the stamp stamp + i.
+      </description>
+      <arg name="count" type="uint"/>
+      <arg name="x" type="int"/>
+      <arg name="y" type="int"/>
+      <arg name="time" type="uint"/>
+      <arg name="step" type="uint" summary="milliseconds between two motions, may be 0"/>
+      <arg name="stamp_hi" type="uint"/>
+      <arg name="stamp_lo" type="uint"/>
+    </request>
+
+    <request name="event_trap" since="17">
+      <description summary="have an ecore event filter reject an injected motion">
+        Installs an ecore event filter that rejects the pointer motion whose
+        time is reject_time, so that it is dropped from the queue without
+        being dispatched. It also
+        installs a handler that, when the motion whose time is probe_time is
+        dispatched, answers with a trap_stamps event holding what
+        e_comp_wl_input_stamps_get() says at that moment, before the event is
+        freed. A new trap replaces an older one, and it goes with the
+        connection.
+      </description>
+      <arg name="reject_time" type="uint"/>
+      <arg name="probe_time" type="uint"/>
+    </request>
+
+    <event name="trap_stamps" since="17">
+      <arg name="processed_hi" type="uint"/>
+      <arg name="processed_lo" type="uint"/>
+    </event>
   </interface>
 </protocol>
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index e1b31afe4..d201de4f6 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -131,6 +131,7 @@ wl_protocol_tests = [
   ['virtual-output', 'test_virtual_output.c'],
   ['virtual-output-zones', 'test_virtual_output_zones.c'],
   ['input-inject', 'test_input_inject.c'],
+  ['input-stamps', 'test_input_stamps.c'],
   ['frame-listener', 'test_frame_listener.c'],
   ['frame-listener-zones', 'test_frame_listener_zones.c'],
   ['headless-fullscreen', 'test_headless_fullscreen.c'],
diff --git a/src/tests/wayland/test_input_stamps.c b/src/tests/wayland/test_input_stamps.c
new file mode 100644
index 000000000..99b45351f
--- /dev/null
+++ b/src/tests/wayland/test_input_stamps.c
@@ -0,0 +1,390 @@
+/* The stamp of an injected input comes back once E has dealt with it:
+ *
+ *   * "processed" moves to the stamp of the latest injected event E has
+ *     dispatched, for every kind of input, with no client involved;
+ *   * an event with no stamp, and one E drops, do not move it;
+ *   * what a frame listener reads in its callback is that value as it is at
+ *     the frame, and never goes back.
+ *
+ * Stamps only ever grow in this test, so that "moved forward" can be told
+ * from "changed". */
+#include <stdio.h>
+#include <string.h>
+#include <linux/input-event-codes.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-input-stamps"
+#define APP "e.test.input.stamps"
+#define LISTENER 1
+#define FRAMES_MAX 4096
+
+static Tk *tk;
+static struct wl_test *tester;
+static uint64_t next_stamp = 1000;
+
+static int answered;
+static unsigned int stamps_ok;
+static uint64_t processed;
+static int trap_answered;
+static uint64_t trap_processed;
+
+static uint64_t frames[FRAMES_MAX];
+static int frame_count;
+
+static uint64_t
+_u64(uint32_t hi, uint32_t lo)
+{
+   return ((uint64_t)hi << 32) | lo;
+}
+
+static void
+_stamps(void *d __attribute__((unused)), struct wl_test *t __attribute__((unused)),
+        uint32_t ok, uint32_t phi, uint32_t plo)
+{
+   stamps_ok = ok;
+   processed = _u64(phi, plo);
+   answered = 1;
+}
+
+static void
+_trap_stamps(void *d __attribute__((unused)), struct wl_test *t __attribute__((unused)),
+             uint32_t phi, uint32_t plo)
+{
+   trap_processed = _u64(phi, plo);
+   trap_answered = 1;
+}
+
+static void
+_frame_stamps(void *d __attribute__((unused)), struct wl_test *t __attribute__((unused)),
+              uint32_t id __attribute__((unused)), uint32_t zone __attribute__((unused)),
+              uint32_t count __attribute__((unused)),
+              uint32_t phi, uint32_t plo, uint32_t argb __attribute__((unused)))
+{
+   if (frame_count == FRAMES_MAX) tk_fail(tk, "too many frames");
+   frames[frame_count++] = _u64(phi, plo);
+}
+
+static const struct wl_test_listener _tester_listener =
+{
+   .stamps = _stamps,
+   .frame_stamps = _frame_stamps,
+   .trap_stamps = _trap_stamps,
+};
+
+static void
+_inject(unsigned int kind, int a, int b, int c, uint64_t stamp)
+{
+   wl_test_input_inject(tester, kind, a, b, c, (uint32_t)next_stamp,
+                        stamp >> 32, stamp & 0xffffffff);
+}
+
+/* What E reports once what was posted has been dispatched: the answer to a
+ * sync comes after it. */
+static void
+_read(void)
+{
+   tk_sync(tk);
+   answered = 0;
+   wl_test_get_stamps(tester);
+   tk_sync(tk);
+   if (!answered) tk_fail(tk, "no answer to get_stamps");
+   if (!stamps_ok) tk_fail(tk, "e_comp_wl_input_stamps_get() failed");
+}
+
+/* The answer to get_stamps, sent right after the requests before it, so
+ * before E has dispatched the events they posted. */
+static void
+_peek(void)
+{
+   answered = 0;
+   wl_test_get_stamps(tester);
+   tk_sync(tk);
+   if (!answered) tk_fail(tk, "no answer to get_stamps");
+}
+
+static void
+_processed_expect(uint64_t want, const char *what)
+{
+   _read();
+   if (processed != want)
+     tk_fail(tk, "%s: processed is %llu, wanted %llu", what,
+             (unsigned long long)processed, (unsigned long long)want);
+   printf(PROG ": %s\n", what);
+}
+
+static uint64_t
+_stamp_new(void)
+{
+   return ++next_stamp;
+}
+
+static void
+_kinds(void)
+{
+   static const struct
+   {
+      unsigned int kind;
+      int a, b, c;
+      const char *name;
+   } events[] =
+     {
+        { WL_TEST_INJECT_KIND_POINTER_MOTION, 300, 200, 0, "a pointer motion" },
+        { WL_TEST_INJECT_KIND_POINTER_BUTTON, BTN_LEFT, 1, 0, "a button press" },
+        { WL_TEST_INJECT_KIND_POINTER_BUTTON, BTN_LEFT, 0, 0, "a button release" },
+        { WL_TEST_INJECT_KIND_POINTER_AXIS, 0, 2, 0, "a wheel" },
+        { WL_TEST_INJECT_KIND_KEY, KEY_A, 1, 0, "a key press" },
+        { WL_TEST_INJECT_KIND_KEY, KEY_A, 0, 0, "a key release" },
+        { WL_TEST_INJECT_KIND_TOUCH_DOWN, 1, 310, 210, "a touch down" },
+        { WL_TEST_INJECT_KIND_TOUCH_MOVE, 1, 320, 220, "a touch move" },
+        { WL_TEST_INJECT_KIND_TOUCH_UP, 1, 0, 0, "a touch up" },
+     };
+   unsigned int i;
+   uint64_t stamp;
+   char what[64];
+
+   for (i = 0; i < sizeof(events) / sizeof(events[0]); i++)
+     {
+        stamp = _stamp_new();
+        _inject(events[i].kind, events[i].a, events[i].b, events[i].c, stamp);
+        snprintf(what, sizeof(what), "%s is processed", events[i].name);
+        _processed_expect(stamp, what);
+     }
+}
+
+/* Posted is not dispatched: E has not dealt with an event until its handlers
+ * have run, and a stamp reported earlier would be a promise it has not kept. */
+static void
+_not_before_dispatch(void)
+{
+   uint64_t before, stamp;
+
+   _read();
+   before = processed;
+   stamp = _stamp_new();
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 90, 100, 0, stamp);
+   _peek();
+   if (processed != before)
+     tk_fail(tk, "processed is %llu with the event only posted, was %llu",
+             (unsigned long long)processed, (unsigned long long)before);
+   _processed_expect(stamp, "an event is processed once dispatched, not when posted");
+}
+
+static void
+_batch(void)
+{
+   uint64_t first = _stamp_new(), last;
+
+   /* All handled by E before the first of them is dispatched. */
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 100, 100, 0, first);
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 110, 100, 0, _stamp_new());
+   last = _stamp_new();
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 120, 100, 0, last);
+   _processed_expect(last, "the last of three events posted together is processed");
+}
+
+static void
+_unstamped(void)
+{
+   uint64_t stamp = _stamp_new();
+
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 130, 100, 0, stamp);
+   _processed_expect(stamp, "a stamped motion");
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 140, 100, 0, 0);
+   _processed_expect(stamp, "an event with the stamp 0 changes nothing");
+   _inject(WL_TEST_INJECT_KIND_KEY, KEY_C, 1, 0, 0);
+   _inject(WL_TEST_INJECT_KIND_KEY, KEY_C, 0, 0, 0);
+   _processed_expect(stamp, "unstamped keys change nothing");
+}
+
+static void
+_dropped(void)
+{
+   uint64_t down = _stamp_new(), repeat, up, again;
+
+   _inject(WL_TEST_INJECT_KIND_KEY, KEY_B, 1, 0, down);
+   _processed_expect(down, "a key press");
+   repeat = _stamp_new();
+   _inject(WL_TEST_INJECT_KIND_KEY, KEY_B, 1, 0, repeat);
+   _processed_expect(down, "a press of a key that is down is dropped, its stamp is not reported");
+   up = _stamp_new();
+   _inject(WL_TEST_INJECT_KIND_KEY, KEY_B, 0, 0, up);
+   _processed_expect(up, "a key release");
+   again = _stamp_new();
+   _inject(WL_TEST_INJECT_KIND_KEY, KEY_B, 0, 0, again);
+   _processed_expect(up, "a release of a key that is up is dropped");
+   _inject(WL_TEST_INJECT_KIND_KEY, 0xfff0, 1, 0, _stamp_new());
+   _processed_expect(up, "a key that the keymap does not have is dropped");
+   _inject(WL_TEST_INJECT_KIND_TOUCH_MOVE, 7, 1, 1, _stamp_new());
+   _inject(WL_TEST_INJECT_KIND_TOUCH_UP, 7, 0, 0, _stamp_new());
+   _processed_expect(up, "a touch that is not down is dropped");
+
+   /* The dropped events must not have shifted what comes after them. */
+   again = _stamp_new();
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 150, 100, 0, again);
+   _processed_expect(again, "an event after dropped ones is processed");
+}
+
+/* More events than E remembers, posted before the first is dispatched: the
+ * oldest stamps are forgotten, and the last must still be the one reported. */
+static void
+_flood(void)
+{
+   uint64_t last = 0;
+   int i;
+
+   for (i = 0; i < 3000; i++)
+     {
+        last = _stamp_new();
+        _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 200 + (i % 50), 100, 0, last);
+     }
+   _processed_expect(last, "the last of three thousand events posted together is processed");
+   last = _stamp_new();
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 201, 101, 0, last);
+   _processed_expect(last, "an event after the flood is processed");
+}
+
+/* Until a frame has been told the stamp, with nothing but the pointer
+ * having moved. */
+static void
+_frame_wait(uint64_t want, const char *what)
+{
+   double end = tk_now() + tk_wait_seconds();
+   int i;
+
+   for (;;)
+     {
+        for (i = 0; i < frame_count; i++)
+          if (frames[i] == want) return;
+        if (tk_now() > end)
+          tk_fail(tk, "%s: no frame was told %llu in %d frames", what,
+                  (unsigned long long)want, frame_count);
+        tk_sync(tk);
+     }
+}
+
+/* More events than E remembers, in one call so that none is dispatched
+ * before the last is posted. The ones that do not fit are forgotten, and
+ * the last must still be the one reported. */
+static void
+_burst(void)
+{
+   uint64_t before, first = next_stamp + 1;
+
+   _read();
+   before = processed;
+   next_stamp += 2500;
+   /* The event 800 is dispatched while the ones E kept are not, and its slot
+    * is that of one of them. */
+   trap_answered = 0;
+   wl_test_event_trap(tester, 1, 100800);
+   wl_test_input_burst(tester, 2500, 120, 120, 100000, 1, first >> 32,
+                       first & 0xffffffff);
+   _read();
+   if (!trap_answered) tk_fail(tk, "the trap was never reached");
+   if (trap_processed != before)
+     tk_fail(tk, "processed was %llu when a forgotten event was dispatched, "
+             "wanted %llu", (unsigned long long)trap_processed,
+             (unsigned long long)before);
+   printf(PROG ": an event that was forgotten does not mark one that was kept\n");
+   _processed_expect(first + 2499, "the last of 2500 events posted by one call is processed");
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 121, 121, 0, _stamp_new());
+   _processed_expect(next_stamp, "an event after the burst is processed");
+}
+
+/* An event that an ecore filter rejects is never dispatched, and ecore
+ * frees it all the same: it counts as processed. Ecore frees it in its turn,
+ * so this does not reach what E does if one is freed ahead of the events
+ * before it, which it handles by the slot of the event, and is not tested. */
+static void
+_filtered(void)
+{
+   uint64_t a = _stamp_new(), b = _stamp_new(), c = _stamp_new();
+
+   wl_test_event_trap(tester, 700002, 0);
+   wl_test_input_inject(tester, WL_TEST_INJECT_KIND_POINTER_MOTION, 130, 130, 0,
+                        700000, a >> 32, a & 0xffffffff);
+   wl_test_input_inject(tester, WL_TEST_INJECT_KIND_POINTER_MOTION, 131, 130, 0,
+                        700001, b >> 32, b & 0xffffffff);
+   wl_test_input_inject(tester, WL_TEST_INJECT_KIND_POINTER_MOTION, 132, 130, 0,
+                        700002, c >> 32, c & 0xffffffff);
+   _processed_expect(c, "an event that a filter rejects is processed");
+}
+
+static void
+_frames_check(void)
+{
+   uint64_t before;
+   int i;
+
+   /* Whatever E reports at a frame is what it has dispatched by then, in
+    * order: never ahead of what a later read says, never going back. */
+   _read();
+   before = processed;
+   for (i = 0; i < frame_count; i++)
+     {
+        if (frames[i] > before)
+          tk_fail(tk, "frame %d was told %llu, ahead of %llu", i,
+                  (unsigned long long)frames[i], (unsigned long long)before);
+        if ((i > 0) && (frames[i] < frames[i - 1]))
+          tk_fail(tk, "frame %d was told %llu, after %llu", i,
+                  (unsigned long long)frames[i],
+                  (unsigned long long)frames[i - 1]);
+     }
+   printf(PROG ": %d frames were told stamps in order\n", frame_count);
+}
+
+static void
+_frames(Tk_Toplevel *top)
+{
+   uint64_t stamp = _stamp_new();
+
+   /* A frame that a client's commit causes. */
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 160, 100, 0, stamp);
+   _read();
+   tk_toplevel_paint(top, 220, 160);
+   _frame_wait(stamp, "a commit after the input");
+   printf(PROG ": a frame for a client commit reads the stamp\n");
+
+   /* One that nobody asks for: E draws the pointer moving. */
+   stamp = _stamp_new();
+   _inject(WL_TEST_INJECT_KIND_POINTER_MOTION, 400, 300, 0, stamp);
+   _frame_wait(stamp, "a pointer motion alone");
+   printf(PROG ": a frame for the pointer moving reads the stamp\n");
+   _frames_check();
+}
+
+int
+main(void)
+{
+   Tk_Toplevel *top;
+
+   tk = tk_connect(PROG);
+   tester = tk_bind(tk, &wl_test_interface, 17);
+   if (!tester) tk_fail(tk, "no wl_test version 17");
+   wl_test_add_listener(tester, &_tester_listener, NULL);
+   top = tk_toplevel_new(tk, APP, "input stamps", 200, 150);
+   tk_settle(tk);
+
+   _read();
+   if (processed)
+     tk_fail(tk, "stamp %llu before any input", (unsigned long long)processed);
+   wl_test_frame_listen(tester, LISTENER, 0, 0, 0);
+   wl_test_frame_stamps_watch(tester, LISTENER);
+   tk_sync(tk);
+
+   _kinds();
+   _not_before_dispatch();
+   _batch();
+   _unstamped();
+   _dropped();
+   _flood();
+   _burst();
+   _filtered();
+   _frames(top);
+
+   tk_toplevel_del(top);
+   tk_disconnect(tk);
+   printf(PROG ": ok\n");
+   return 0;
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to