mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
ui/input: keep default focus on earliest focusable
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+8
-2
@@ -103,7 +103,8 @@ loop:
|
|||||||
default:
|
default:
|
||||||
newPri = priDefault
|
newPri = priDefault
|
||||||
}
|
}
|
||||||
if newPri >= pri {
|
// Switch focus if higher priority or if focus requested.
|
||||||
|
if newPri.replaces(pri) {
|
||||||
k, pri = op.Key, newPri
|
k, pri = op.Key, newPri
|
||||||
}
|
}
|
||||||
h, ok := q.handlers[op.Key]
|
h, ok := q.handlers[op.Key]
|
||||||
@@ -119,7 +120,7 @@ loop:
|
|||||||
case ops.TypePush:
|
case ops.TypePush:
|
||||||
newK, newPri, h := q.resolveFocus(events)
|
newK, newPri, h := q.resolveFocus(events)
|
||||||
hide = hide || h
|
hide = hide || h
|
||||||
if newPri >= pri {
|
if newPri.replaces(pri) {
|
||||||
k, pri = newK, newPri
|
k, pri = newK, newPri
|
||||||
}
|
}
|
||||||
case ops.TypePop:
|
case ops.TypePop:
|
||||||
@@ -128,3 +129,8 @@ loop:
|
|||||||
}
|
}
|
||||||
return k, pri, hide
|
return k, pri, hide
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p listenerPriority) replaces(p2 listenerPriority) bool {
|
||||||
|
// Favor earliest default focus or latest requested focus.
|
||||||
|
return p > p2 || p == p2 && p == priNewFocus
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user