io/router: send key events to root handlers if nothing else wants them

Fixes: https://todo.sr.ht/~eliasnaur/gio/403
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-04-23 09:40:23 +02:00
parent 6ddc13ce66
commit 30fa85f518
2 changed files with 49 additions and 31 deletions
+14
View File
@@ -345,6 +345,20 @@ func TestKeyRouting(t *testing.T) {
assertKeyEvent(t, r.Events(&handlers[0]), false)
}
func TestTopLevelInputOp(t *testing.T) {
h := new(int)
ops := new(op.Ops)
r := new(Router)
key.InputOp{Tag: h, Keys: "A"}.Add(ops)
r.Frame(ops)
A := key.Event{Name: "A"}
r.Queue(A)
assertKeyEvent(t, r.Events(h), false, A)
}
func assertKeyEvent(t *testing.T, events []event.Event, expected bool, expectedInputs ...event.Event) {
t.Helper()
var evtFocus int