-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
input/keyboard: extend bindsym --to-code to work with duplicate matches #8358
base: master
Are you sure you want to change the base?
Conversation
to test: swaymsg 'input * xkb_layout us'
swaymsg 'bindsym --to-code $mod1+a exec notify-send hi'
# test that alt+a sends hi according to a US QWERTY layout
swaymsg 'input * xkb_layout fr'
# Test that alt+q now sends hi, as the French AZERTY layout is the new
# "first configured layout" that `--to-code` should respect
swaymsg 'input * xkb_layout us'
swaymsg 'bindsym --to-code Print+a exec notify-send hi'
# test that Print+a sends hi according to a US QWERTY layout
swaymsg 'input * xkb_layout fr'
# Test that Print+q now sends hi, as the French AZERTY layout is the new
# "first configured layout" that `--to-code` should respect |
@kennylevinsen what do you think of this approach? It's been working without issues for me so far. |
@emersion Any concerns with this approach? |
A reasonable rate of poking is if roughly 2 weeks have passed - daily is far too much noise for volunteers who are also busy with their day jobs and other projects. |
55bea8e
to
e812139
Compare
@kennylevinsen me waiting for review : 👁️👄👁️ |
e812139
to
7ded6e4
Compare
I haven't run into any crashes using this. Any chance we can merge it? |
This modifies `get_active_binding` to treat bindsym --to-codes separately: per each keysym `i` in `binding->keys`, look through the list of matching keycodes in `binding->translations[i]`. Another solution is to take the cartesian product of all syms and make a binding per each product. This makes retranslation more difficult though because the dups from the old layout have to be cleared out before translating to the new `xkb_layout`. Whether by retaining a parent binding, searching through all bindings for matching `binding->command`, or some other ref count structure, that would introduce more complexity than modifying get_active binding to account for dups. Notice this requires no changes to the existing retranslation logic.
7ded6e4
to
4d0d553
Compare
@emersion Any chance we can get this merged? |
This modifies
get_active_binding
to treat bindsym --to-codes separately: per each keysymi
inbinding->keys
, look through the list of matching keycodes inbinding->translations[i]
.Another solution is to take the cartesian product of all syms and make a binding per each product. This makes retranslation more difficult though because the dups from the old layout have to be cleared out before translating to the new
xkb_layout
. Whether by retaining a parent binding, searching through all bindings for matchingbinding->command
, or some other ref count structure, that would introduce more complexity than modifying get_active binding to account for dups. Notice this requires no changes to the existing retranslation logic.