-
Notifications
You must be signed in to change notification settings - Fork 124
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
Modern rules #362
Modern rules #362
Conversation
88f33f9
to
8654d22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @wismill. Now with X starting to go the way of the dodo, the fact that we're still stuck on max 4 layouts is a bit embarrassing. And the repetition in the rules format is even more embarrassing :)
I've read through the code, it looks good (I will write some nits later), but let's finalize the design first.
Regarding first
, later
, any
.
I already forgot why the format insists on distinguishing foo
(matches first only if single layout given) and foo[1]
(matches first only if multiple layouts given). Is there an honest semantic reason for this, or just some historic weirdness?
I think what would help me quite a bit is to see rules/evdev
before/after (if it's not too much effort). Then I can see more directly why each new addition is needed.
Idle thought: maybe instead of first
, later
, any
we can use python slice syntax, i.e. layout[2:]
, layout[:]
. I realize the first
case is complicated (see previous question).
%i
SGTM, I think we can agree on this design.
:all
SGTM, I think we can agree on this design. I left some nits on the commit.
docs/rules-format.md
will need an update, can do it later though.
In order to maintain consistent rules, we now disallow layout and
variant to have different indexes.
This part LGTM, you can split & cherry-pick it to master already if you'd like unless you want to wait for libxkbfile to agree to this as well.
8654d22
to
248965c
Compare
@bluetech Thanks! I refactored based on your review. I also introduced
I think this is due to some config model/layouts adding a second group, e.g:
Now I think it makes sense to add e.g.
I think this transformation would make sense even without this implementation, in order to simplify the rules. Let me take time to propose a MR in
I thought exactly about that! But then: what does it bring to us? Do we need e.g.
Yes, it should be done in this MR. Let’s add a TODO.
I do not think we need to wait for libxkbfile. |
248965c
to
d462cff
Compare
Rebased, added |
This will make their semantics explicit.
d462cff
to
715b386
Compare
715b386
to
1b17ddb
Compare
Fixed some edge cases and ensure we are prepared to raise the group limit. I am now fairly confident in this PR. I will give another review tomorrow and probably merge it soon after, so we can start to work on a modern set of rules in To myself: do not forget the TODO list 😄 |
91da8b1
to
7cdfe09
Compare
There is a lot of repetition in the current rules files provided by xkeyboard-config, because the MLVO mappings need to match on the exact layout/variant index. This also prevents to increase the number of maximum groups, because it does not scale. We introduces the following new special layout/variant indexes: - “single”: matches a single layout; same as with no index. - “first”: matches the first layout/variant, no matter how many layouts are in the RMLVO configuration. It allows to merge `layout` and `layout[1]` patterns. - “later”: matches all but the first layout. This is an index range. - “any”: matches layout at any position. This is an index range. We also introduces the new `%i` expansion, which correspond to the index of the matched layout in a mapping with an index range. Example: layout[later] = symbols my_layout = +my_symbols:%i * = +%l[%i]:%i Let’s have a look at concrete examples from xkeyboard-config: ! model layout = symbols * * = pc+%l%(v) ! model layout[1] = symbols * * = pc+%l[1]%(v[1]) ! model layout[2] = symbols * * = +%l[2]%(v[2]) ! model layout[3] = symbols * * = +%l[3]%(v[3]) ! model layout[4] = symbols * * = +%l[4]%(v[4]) ! layout option = symbols * grp:toggle = +group(toggle) ! layout[1] option = symbols * grp:toggle = +group(toggle):1 ! layout[2] option = symbols * grp:toggle = +group(toggle):2 ! layout[3] option = symbols * grp:toggle = +group(toggle):3 ! layout[4] option = symbols * grp:toggle = +group(toggle):4 With this commit we can now simplify it into: ! model layout[first] = symbols * * = pc+%l[%i]%(v[%i]) ! model layout[later] = symbols * * = +%l[%i]%(v[%i]):%i ! layout[any] option = symbols * grp:toggle = +group(toggle):%i The latter rule will work even if we increase XKB_MAX_GROUPS, whereas the former would require to add the missing entries for the new groups. In order to maintain consistent rules, we now disallow layout and variant to have different indexes. For example, the following mapping are now invalid: - layout variant[1] - layout[1] variant[2] - layout[1] variant - layout[first] variant[1] - layout[first] variant - layout variant[any] - etc.
Some layout options require to be applied to every group to maintain consistency (e.g. a group switcher). Currently this must be done manually for all layout indexes. This is error prone and prevents the increase of the maximum group count. This commit introduces the `:all` qualifier for KcCGST values. When a rule with this qualifier is matched, it will expands the qualified value (and its optional merge mode) for every layout, e.g. `+group(toggle):all` (respectively `|group(toggle)`) would expand to `+group(toggle):1+group(toggle):2` (respectively `|group(toggle):1|group(toggle):2`) if there are 2 layouts, etc. If there is no merge mode, it defaults to *override* `+`, e.g. `x:all` expands to `x:1+x:2+x:3` for 3 layouts. Note that only the qualified *value* is expanded, e.g. `x+y:all` expands to `x+y:1+y:2` for 2 layouts. `:all` can be used in combination with special layout indexes. Since this can lead to an unexpected behaviour, a warning will be raised.
7cdfe09
to
d0635da
Compare
This is a replacement of #334.
There is a lot of repetition in the current rules files, because the MLVO mappings need to match on the exact layout/variant index. This also prevents to increase the number of maximum groups.
We introduces new special layout/variant indexes:
We also introduces the new
%i
expansion, which correspond to the index of the matched layout in a mapping with an index range. Example:Let’s have a look at concrete examples from xkeyboard-config:
With this commit we can now simplify it into:
The latter rule will work even if we increase XKB_MAX_GROUPS, whereas
the former would require to add the missing entries for the new groups.
In order to maintain consistent rules, we now disallow layout and variant to have different indexes. For example, the following mapping are now invalid:
layout variant[1]
layout[1] variant[2]
layout[1] variant
layout[first] variant[1]
layout[first] variant
layout variant[any]
Some layout options require to be applied to every group to maintain consistency (e.g. a group switcher). Currently this must be done manually for all layout indexes. This is error prone and prevents the increase of the maximum group count.
We introduces the
:all
qualifier forkccgst
values. When a rule with this qualifier applies, it will expands for every layout, e.g.+group(toggle):all
would expand to+group(toggle):1+group(toggle):2
if there are 2 layouts, etc.TODO:
docs/rules-format.md
xkeyboard-config
Related: #37 and #311