Attempt to make modifier key changes take affect when the dialogue closes. This means you don't have to restart Fenrir to apply them.

This commit is contained in:
Storm Dragon committed 2026-10-29 18:27:20 -04:00
1 parent 15e04aa8f8
commit 22f6df6af9
23 files changed
+454 -58

No files matched your search

@@ -0,0 +1,62 @@
// Copyright (c) 2026 Storm Dragon
// SPDX-License-Identifier: GPL-3.0-or-later
//go:build linux && cgo
package console
import (
"testing"
"git.stormux.org/storm/fenrir/internal/command"
"git.stormux.org/storm/fenrir/internal/input"
)
func TestConsoleModifierUpdateWaitsForCaptureAndHeldChord(t *testing.T) {
layout, _, err := input.Load_bindings([]string{"../../config/keyboard/laptop.toml"})
if err != nil {
t.Fatal(err)
}
router, err := input.New_router(layout)
if err != nil {
t.Fatal(err)
}
if err := router.Configure_modifiers([]string{"KEY_INSERT"}, []string{"KEY_COMPOSE"}); err != nil {
t.Fatal(err)
}
if err := router.Configure_scripts([]string{"KEY_COMPOSE"}, []input.ScriptBinding{{ID: "script:example", Keys: []string{"KEY_SCRIPT", "KEY_U"}}}); err != nil {
t.Fatal(err)
}
keys := &Keyboards{router: router}
update := func(want bool) {
t.Helper()
applied, err := keys.Update_modifiers([]string{"KEY_META"}, []string{"KEY_CAPSLOCK"})
if err != nil || applied != want {
t.Fatal(applied, err)
}
}
keys.router.Capture(true)
update(false)
keys.router.Capture(false)
keys.router.Key(1, input.KeyInsert, 1, false, false)
if got := keys.router.Key(1, 23, 1, false, false); got.Command != command.CurrentLine {
t.Fatal(got)
}
update(false)
keys.router.Key(1, input.KeyInsert, 0, false, false)
update(false)
if got := keys.router.Key(1, 23, 0, false, false); got.Forward {
t.Fatal("old chord release leaked", got)
}
update(true)
keys.router.Key(1, input.KeyMeta, 1, false, false)
if got := keys.router.Key(1, 23, 1, false, false); got.Command != command.CurrentLine {
t.Fatal("new reader key failed", got)
}
keys.router.Key(1, input.KeyMeta, 0, false, false)
keys.router.Key(1, 23, 0, false, false)
keys.router.Key(1, input.KeyCapsLock, 1, false, false)
if got := keys.router.Key(1, 22, 1, false, false); got.Command != "script:example" {
t.Fatal("script binding lost", got)
}
}