Bug: block-unmapped-keys blocks transparent keys in layers
Requirements
- [X] I've searched platform-specific issues, issues and discussions to see if this has been reported before.
Describe the bug
block-unmapped-keys doesn't work quite like I imagined it would. It also seems to block transparent keys in active layers. I'd still expect them to be triggered as they should map to the keys in defsrc? delegate-to-first-layer seems to have no effect either.
Relevant kanata config
(defcfg
process-unmapped-keys yes
block-unmapped-keys yes
delegate-to-first-layer yes
log-layer-changes no
)
(defsrc
grv 1 2 3 4 5 6 7 8 9 0 -
tab q w e r t y u i o p [
caps a s d f g h j k l ; '
nubs z x c v b n m , . / rsft
lalt spc ralt
)
;; First defined layer is the starting layer
(deflayer starting
grv 1 2 3 4 5 6 7 8 9 0 -
tab q w e r t y u i o p [
@cap @a @s @d @f g h @j @k @l @scn @sqt
@ibs z x c v b n m , . / @rsf
@lat @spc @rat
)
(defalias
cap (tap-hold 200 200 esc (layer-while-held mouse))
ibs (caps-word 3000)
f (tap-hold 200 250 f lsft)
d (tap-hold 200 250 d lctl)
s (tap-hold 200 250 s lalt)
a (tap-hold 200 250 a lmet)
j (tap-hold 200 250 j rsft)
k (tap-hold 200 250 k rctl)
l (tap-hold 200 250 l lalt)
scn (tap-hold 200 250 scln lmet)
rsf (tap-hold 200 250 del rsft)
sqt (tap-hold 200 200 ' (layer-while-held misc))
lat (tap-hold 200 200 bspc (layer-while-held nav))
spc (tap-hold 200 250 spc (layer-while-held symbols))
rat (tap-hold 200 200 ret (layer-while-held numbers))
)
(deflayer nav
_ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _
_ lmet lalt lctl lsft _ left down up rght _ _
_ _ _ _ _ _ home pgdn pgup end _ _
_ _ _
)
(defalias
ma← (movemouse-accel-left 5 1000 1 5)
ma↓ (movemouse-accel-down 5 1000 1 5)
ma↑ (movemouse-accel-up 5 1000 1 5)
ma→ (movemouse-accel-right 5 1000 1 5)
mwl (mwheel-left 50 120)
mwd (mwheel-down 50 120)
mwu (mwheel-up 50 120)
mwr (mwheel-right 50 120)
)
(deflayer mouse
_ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ mlft mmid mrgt _ _ _
_ _ _ _ _ _ @ma← @ma↓ @ma↑ @ma→ _ _
_ _ _ _ _ _ @mwl @mwd @mwu @mwr _ _
_ _ _
)
(defvar
rps S-0 ;; ) Right parenthesis
exc S-1 ;; ! Exclamation mark
dlr S-4 ;; $ Dollar
per S-5 ;; % Percent
crt S-6 ;; ^ Caret or circumflex
amp S-7 ;; & Ampersand
ask S-8 ;; * Asterisk
lps S-9 ;; ( Left parenthesis
pls S-= ;; + Plus
lbc S-[ ;; { Left curly bracket
rbc S-] ;; } Right curly bracket
uds S-- ;; _ Underscore
qtm S-/ ;; ? Question mark
tld S-\ ;; Tilda
vrb S-nubs ;; Vertical bar
num bksl ;; # Number sign - on US keyboards it's where backslash is
dqm S-2 ;; Double quotation marks
eur RA-4 ;; Euro
gbp S-3 ;; £
ats S-' ;; @
lst S-, ;; <
grt S-. ;; >
cln S-; ;; :
mns - ;; Minus
)
;; Symbols in the home row are placed based on their action in Neovim,
;; left/backward movement/operation symbols are on the left hand, right/forward
;; movement/operation symbols are on the right
;; Other symbols are placed near their location on a default UK layout
(deflayer symbols
_ _ _ _ _ _ _ _ _ _ _ _
grv $exc $dqm $gbp $eur $per $crt $amp $mns eql $pls $ats
$qtm $ask [ $lbc $lps $uds $dlr $rps $rbc ] $num /
nubs $vrb _ _ _ _ _ _ $lst $grt $cln $tld
_ _ _
)
(deflayer misc
_ _ _ _ _ _ _ _ _ _ _ _
_ f12 f7 f8 f9 _ _ _ _ _ prnt _
_ f11 f4 f5 f6 _ _ vold volu mute _ _
_ f10 f1 f2 f3 _ _ brdn bru _ _ _
_ _ _
)
(deflayer numbers
_ _ _ _ _ _ _ _ _ _ _ _
_ _ 7 8 9 _ _ _ _ _ _ _
_ 0 4 5 6 _ _ rsft rctl lalt lmet _
_ _ 1 2 3 _ _ _ _ _ _ _
_ _ _
)
To Reproduce
- Hold down any layer key
- Press a transparent key
- See nothing is typed
Expected behavior
I'd expect transparent keys to still fallback to the base/starting layer.
Kanata version
1.6.0
Debug logs
No response
Operating system
Linux Pop_OS
Additional context
No response
Thanks!
The fix would be a code change in the vicinity of this area:
https://github.com/jtroo/kanata/blob/87db6b4e26c7f87609298520aaba5c0419407b0f/parser/src/cfg/mod.rs#L2942-L2946
I gave it a try, so far my attempt makes me think we should have an actual Action enum variant for an actual transparent action, or, we should have a default-value variant that's other than Action::Trans, for keys that have not been set in the config.
Either way, we have different variants that mean different things, and we no longer have one variant (Trans) used for multiple things (used for checking if a key was assigned, and used for transparent actions).
i.e at lines 41 and 42 here, the default value should not be Action::Trans, it should be something like Action::Default or Action::Unspecified or something like that, and Action::Trans should be used for actual trans keys (i.e keys in deflayer or deflayermap that have been set to _, currently setting keys to _ in deflayermap while enabling process-unmapped-keys & block-unmapped-key does not work as expected, the key is blocked):
https://github.com/jtroo/kanata/blob/1294b242de9806fb7068c0b398b5f98cbe8a5e7b/parser/src/layers.rs#L33-L46
i.e at lines 41 and 42 here, the default value should not be
Action::Trans, it should be something likeAction::DefaultorAction::Unspecifiedor something like that, andAction::Transshould be used for actual trans keys (i.e keys in deflayer or
I think adding an Action::Unspecified sounds reasonable 👍
Fixed in d3ef95de0cfa92303c3d1b2a271483b21603ccaa