mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
io/router: don't panic on focus moves when there is nothing to focus
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -171,6 +171,9 @@ func (q *keyQueue) updateFocusLayout() {
|
|||||||
|
|
||||||
// MoveFocus attempts to move the focus in the direction of dir, returning true if it succeeds.
|
// MoveFocus attempts to move the focus in the direction of dir, returning true if it succeeds.
|
||||||
func (q *keyQueue) MoveFocus(dir FocusDirection, events *handlerEvents) bool {
|
func (q *keyQueue) MoveFocus(dir FocusDirection, events *handlerEvents) bool {
|
||||||
|
if len(q.dirOrder) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
order := 0
|
order := 0
|
||||||
if q.focus != nil {
|
if q.focus != nil {
|
||||||
order = q.handlers[q.focus].dirOrder
|
order = q.handlers[q.focus].dirOrder
|
||||||
|
|||||||
@@ -311,6 +311,11 @@ func TestFocusClick(t *testing.T) {
|
|||||||
assertEventPointerTypeSequence(t, r.Events(h), pointer.Cancel, pointer.Press, pointer.Release)
|
assertEventPointerTypeSequence(t, r.Events(h), pointer.Cancel, pointer.Press, pointer.Release)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNoFocus(t *testing.T) {
|
||||||
|
r := new(Router)
|
||||||
|
r.MoveFocus(FocusForward)
|
||||||
|
}
|
||||||
|
|
||||||
func assertKeyEvent(t *testing.T, events []event.Event, expected bool, expectedInputs ...event.Event) {
|
func assertKeyEvent(t *testing.T, events []event.Event, expected bool, expectedInputs ...event.Event) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
var evtFocus int
|
var evtFocus int
|
||||||
|
|||||||
Reference in New Issue
Block a user