mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
io/input: permit FocusCmd to explicitly set the focus to any tag
If the client asks for the focus to be set to a tag, allow it. There is a check at the end of Router.Frame that clears the focus if the tag turns out to fail the requirements (visible and has asked for FocusEvents). The change simplifies the logic for determining whether a command can be executed immediately. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+15
-16
@@ -62,6 +62,10 @@ func TestKeyStacked(t *testing.T) {
|
||||
ops := new(op.Ops)
|
||||
r := new(Router)
|
||||
|
||||
for i := range handlers {
|
||||
assertKeyEvent(t, events(r, &handlers[i], key.FocusFilter{}), false)
|
||||
}
|
||||
|
||||
event.InputOp(ops, &handlers[0])
|
||||
r.Source().Execute(key.FocusCmd{})
|
||||
r.Source().Execute(key.SoftKeyboardCmd{Show: false})
|
||||
@@ -71,10 +75,6 @@ func TestKeyStacked(t *testing.T) {
|
||||
r.Source().Execute(key.SoftKeyboardCmd{Show: true})
|
||||
event.InputOp(ops, &handlers[3])
|
||||
|
||||
for i := range handlers {
|
||||
assertKeyEvent(t, events(r, &handlers[i], key.FocusFilter{}), false)
|
||||
}
|
||||
|
||||
r.Frame(ops)
|
||||
|
||||
assertKeyEvent(t, events(r, &handlers[1], key.FocusFilter{}), true)
|
||||
@@ -101,14 +101,6 @@ func TestKeyRemoveFocus(t *testing.T) {
|
||||
ops := new(op.Ops)
|
||||
r := new(Router)
|
||||
|
||||
// New InputOp with Focus and Keyboard:
|
||||
event.InputOp(ops, &handlers[0])
|
||||
r.Source().Execute(key.FocusCmd{Tag: &handlers[0]})
|
||||
r.Source().Execute(key.SoftKeyboardCmd{Show: true})
|
||||
|
||||
// New InputOp without any focus:
|
||||
event.InputOp(ops, &handlers[1])
|
||||
|
||||
filters := []event.Filter{
|
||||
key.FocusFilter{},
|
||||
key.Filter{Name: key.NameTab, Required: key.ModShortcut},
|
||||
@@ -116,6 +108,13 @@ func TestKeyRemoveFocus(t *testing.T) {
|
||||
for i := range handlers {
|
||||
assertKeyEvent(t, events(r, &handlers[i], filters...), false)
|
||||
}
|
||||
// New InputOp with Focus and Keyboard:
|
||||
event.InputOp(ops, &handlers[0])
|
||||
r.Source().Execute(key.FocusCmd{Tag: &handlers[0]})
|
||||
r.Source().Execute(key.SoftKeyboardCmd{Show: true})
|
||||
|
||||
// New InputOp without any focus:
|
||||
event.InputOp(ops, &handlers[1])
|
||||
|
||||
r.Frame(ops)
|
||||
|
||||
@@ -180,6 +179,10 @@ func TestKeyFocusedInvisible(t *testing.T) {
|
||||
ops := new(op.Ops)
|
||||
r := new(Router)
|
||||
|
||||
for i := range handlers {
|
||||
assertKeyEvent(t, events(r, &handlers[i], key.FocusFilter{}), false)
|
||||
}
|
||||
|
||||
// Set new InputOp with focus:
|
||||
r.Source().Execute(key.FocusCmd{Tag: &handlers[0]})
|
||||
event.InputOp(ops, &handlers[0])
|
||||
@@ -188,10 +191,6 @@ func TestKeyFocusedInvisible(t *testing.T) {
|
||||
// Set new InputOp without focus:
|
||||
event.InputOp(ops, &handlers[1])
|
||||
|
||||
for i := range handlers {
|
||||
assertKeyEvent(t, events(r, &handlers[i], key.FocusFilter{}), false)
|
||||
}
|
||||
|
||||
r.Frame(ops)
|
||||
|
||||
assertKeyEvent(t, events(r, &handlers[0], key.FocusFilter{}), true)
|
||||
|
||||
Reference in New Issue
Block a user