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

+30
View File
@@ -72,6 +72,36 @@ func (k *Keyboard) Close() error {
return nil
}
// Update_modifiers applies only between complete chords and outside modal capture.
// The native transaction retains the previous grabs if any new grab is refused.
func (k *Keyboard) Update_modifiers(fenrirKeys, scriptKeys []string) (bool, error) {
s := k.session
if s.router.Captured() || s.grabbed || s.captureBlocked || len(s.held) != 0 || len(s.replayed) != 0 {
return false, nil
}
candidate := s.router
if err := candidate.Configure_modifiers(fenrirKeys, scriptKeys); err != nil {
return false, err
}
var keys []C.int
for _, key := range append(candidate.Reader_keys(), candidate.Script_keys()...) {
keys = append(keys, C.int(key))
}
var keyPointer *C.int
if len(keys) > 0 {
keyPointer = &keys[0]
}
status := C.terminal_x_update_keys(s.x, keyPointer, C.int(len(keys)))
if err := native_error(status); err != nil {
return false, fmt.Errorf("update X11 modifier keys: %w", err)
}
if status != 0 {
return false, nil
}
s.router = candidate
return true, nil
}
// capture_keyboard treats desktop/focus contention as a refused chord, not a
// terminal-session failure. Keep modal intent while discarding stale key state.
func (s *Session) capture_keyboard() (int, error) {