From 7cdfe09f7b671f36cf5b63e36aa1a6bda5553683 Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Thu, 16 Nov 2023 17:12:03 +0100 Subject: [PATCH] rules: Add support for :all qualifier 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. --- changes/api/+modern-rules.feature.md | 5 +- doc/rules-format.md | 131 +++++++++++++++++++++++---- src/scanner-utils.h | 24 +++-- src/xkbcomp/rules.c | 65 ++++++++++++- test/data/rules/all_qualifier | 59 ++++++++++++ test/data/rules/all_qualifier-limit | 18 ++++ test/data/rules/evdev-modern | 2 +- test/rules-file.c | 98 +++++++++++++++++++- 8 files changed, 367 insertions(+), 35 deletions(-) create mode 100644 test/data/rules/all_qualifier create mode 100644 test/data/rules/all_qualifier-limit diff --git a/changes/api/+modern-rules.feature.md b/changes/api/+modern-rules.feature.md index d27af48b..fb1c00a8 100644 --- a/changes/api/+modern-rules.feature.md +++ b/changes/api/+modern-rules.feature.md @@ -7,8 +7,9 @@ Rules: Added support for special layouts indexes: `layout[2]` .. `layout[4]`. - *any*: matches layout at any position. This is an index range. -Also added the special index `%i` which correspond to the index of the matched -layout. +Also added: +- the special index `%i` which correspond to the index of the matched layout. +- the `:all` qualifier: it applies the qualified item to all layouts. See the [documentation](https://xkbcommon.org/doc/current/rule-file-format.html) for further information. diff --git a/doc/rules-format.md b/doc/rules-format.md index a9e3b1d1..40435de8 100644 --- a/doc/rules-format.md +++ b/doc/rules-format.md @@ -150,7 +150,8 @@ Kccgst ::= "keycodes" | "symbols" | "types" | "compat" | "geometry" Rule ::= { MlvoValue } "=" { KccgstValue } "\n" MlvoValue ::= "*" | GroupName | -KccgstValue ::= +KccgstValue ::= [ { Qualifier } ] +Qualifier ::= ":" ({ NumericIndex } | "all") ```