test: check for 2 empty dispatch run before considering a stable state

With keymap messages, we may get and process data on the wire
but it doesn't necessarily result in a visible event. We need to enter
dispatch again to process the data in the next packet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2021-08-10 17:00:23 +10:00
parent 3aa75890e9
commit 55b79c44a5

View file

@ -791,15 +791,20 @@ _peck_dispatch_ei(struct peck *peck, int lineno)
void
_peck_dispatch_until_stable(struct peck *peck, int lineno)
{
bool eis, ei;
int eis = 0, ei = 0;
log_debug(peck, "dispatching until stable (line %d) {\n", lineno);
peck_indent(peck);
/* we go two dispatch loops for both ei and EIS before we say it's
* stable. With the DEVICE_REGION/KEYMAP/DONE event split we may
* get events on the wire that don't result in an actual event
* yet, so we can get stuck if we just wait for one.
*/
do {
eis = _peck_dispatch_eis(peck, lineno);
ei = _peck_dispatch_ei(peck, lineno);
} while (ei || eis);
eis = _peck_dispatch_eis(peck, lineno) ? 0 : eis + 1;
ei = _peck_dispatch_ei(peck, lineno) ? 0 : ei + 1;
} while (ei <= 2 || eis <= 2);
peck_dedent(peck);
log_debug(peck, "}\n", lineno);