Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sahinf
Copy link
Contributor

@sahinf sahinf commented Sep 23, 2024

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.

@sahinf
Copy link
Contributor Author

sahinf commented Sep 23, 2024

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

@sahinf
Copy link
Contributor Author

sahinf commented Sep 24, 2024

@kennylevinsen what do you think of this approach? It's been working without issues for me so far.

@sahinf
Copy link
Contributor Author

sahinf commented Sep 25, 2024

@emersion Any concerns with this approach?

@kennylevinsen
Copy link
Member

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.

@sahinf sahinf force-pushed the bindsym-tocode-dup-children branch from 55bea8e to e812139 Compare October 3, 2024 20:51
@sahinf
Copy link
Contributor Author

sahinf commented Oct 8, 2024

@kennylevinsen me waiting for review : 👁️👄👁️

@sahinf sahinf force-pushed the bindsym-tocode-dup-children branch from e812139 to 7ded6e4 Compare October 12, 2024 22:04
@sahinf
Copy link
Contributor Author

sahinf commented Oct 17, 2024

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.
@sahinf sahinf force-pushed the bindsym-tocode-dup-children branch from 7ded6e4 to 4d0d553 Compare November 7, 2024 21:56
@sahinf
Copy link
Contributor Author

sahinf commented Nov 7, 2024

@emersion Any chance we can get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants