io/router: search all key handlers when there is no focus

Fixes: https://todo.sr.ht/~eliasnaur/gio/434
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-07-02 20:43:57 +02:00
parent 6bf5d4dc2d
commit 0057e871d0
2 changed files with 16 additions and 11 deletions
+8 -3
View File
@@ -191,7 +191,8 @@ func (q *Router) queueKeyEvent(e key.Event) {
}
pq := &q.pointer.queue
idx := len(pq.hitTree) - 1
if f != nil {
focused := f != nil
if focused {
// If there is a focused tag, traverse its ancestry through the
// hit tree to search for handlers.
for ; pq.hitTree[idx].ktag != f; idx-- {
@@ -199,11 +200,15 @@ func (q *Router) queueKeyEvent(e key.Event) {
}
for idx != -1 {
n := &pq.hitTree[idx]
idx = n.next
if focused {
idx = n.next
} else {
idx--
}
if n.ktag == nil {
continue
}
if n.ktag != nil && kq.Accepts(n.ktag, e) {
if kq.Accepts(n.ktag, e) {
q.handlers.Add(n.ktag, e)
break
}