Skip to content

Commit 93982b8

Browse files
committed
symbols: Add doc for multiple actions
1 parent e510c5c commit 93982b8

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
symbols: Added support for *multiple actions per levels:*
2+
- *1 keysym == 1 action* now holds for every keysym count.
3+
- When no action is specified, `interpret` statements are used to find an action corresponding for *each* keysym, as expected.
4+
- When both keysyms and actions are specified, they should have the exact same count for each level.
5+
- For now, at most one action of each following categories is allowed per level:
6+
- modifier actions: `SetMods`, `LatchMods`, `LockMods`;
7+
- group actions: `SetGroup`, `LatchGroup`, `LockGroup`.
8+
Some examples:
9+
- `SetMods` + `SetGroup`: ok
10+
- `SetMods` + `SetMods`: error
11+
- `SetMods` + `LockMods`: error
12+
- `SetMods` + `LockGroup`: ok

doc/keymap-format-text-v1.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ _case-sensitive_.
582582
| `hidden` | <span class="todo">TODO</span> |
583583
| `include` | [Include statement][include] |
584584
| `indicator` | <span class="todo">TODO</span> |
585-
| `interpret` | <span class="todo">TODO</span> |
585+
| `interpret` | [Interpret statement][interpret] |
586586
| `key` | <span class="todo">TODO</span> |
587587
| `keypad_keys` | <span class="todo">TODO</span> |
588588
| `keys` | <span class="todo">TODO</span> |
@@ -617,6 +617,8 @@ _case-sensitive_.
617617
| `xkb_types` | Declare a [key types section ][xkb_types] |
618618

619619
[include]: @ref xkb-include
620+
[interpret]: @ref interpret-statements
621+
[interpretations]: @ref interpret-statements
620622

621623
### Built-in settings
622624

@@ -1539,7 +1541,7 @@ One can use a **merge mode** *prefix* to specify the merge mode of the file:
15391541

15401542
@todo dedicated section for merge mode
15411543

1542-
### Key statement
1544+
### Key statement {#key-statement}
15431545

15441546
Statements of the form:
15451547

@@ -1600,14 +1602,49 @@ level 1 and `XKB_KEY_Q` for level 2. These levels are configured by the
16001602
@remark Remember that @ref keysym-transformations may affect the resulting
16011603
keysym when some modifiers are not [consumed](@ref consumed-modifiers).
16021604
1603-
As an extension to the XKB format, libxkbcommon supports multiple key symbols
1604-
per level.
1605+
As an extension to the XKB legacy format, libxkbcommon supports multiple key
1606+
symbols and actions per level (the latter since version 1.8.0):
16051607
16061608
key <AD01> { [ {a, b}, Q ] };
16071609
16081610
In this example, the keycode `<AD01>` produces two symbols on level 1
16091611
(`XKB_KEY_a` and `XKB_KEY_b`) and one symbol (`XKB_KEY_Q`) on level 2.
16101612
1613+
When no actions are explicitly given, they are automatically filled
1614+
thanks to [interpretations] from the [compat section][xkb_compat].
1615+
In the following example,
1616+
1617+
key <LCTL> { [ { Control_L, ISO_Group_Shift } ] };
1618+
1619+
is equivalent to (given standard definitions from `xkeyboard-config`):
1620+
1621+
key <LCTL> {
1622+
symbols[1] = [ { Control_L, ISO_Group_Shift } ],
1623+
actions[1] = [ { SetMods(modifiers=Control), SetGroup(group=+1) } ]
1624+
};
1625+
1626+
When using this example with e.g. two layouts `fr,us` (respectively Azerty and
1627+
Qwerty layouts), typing `Control + A` in the first layout `fr` will in fact
1628+
result in `Control + Q`, because the actions are run sequentially: first set the
1629+
base modifiers to Control, then switch to the second layout while `Control` is
1630+
pressed.
1631+
1632+
@note
1633+
There are some *limitations* with this extension:
1634+
- When both keysyms and actions are specified, they should have the exact
1635+
*same count* for each level.
1636+
- For now, *at most one* action of each following categories is allowed per
1637+
level:
1638+
- [modifier actions][]: `SetMods`, `LatchMods`, `LockMods`;
1639+
- [group actions][]: `SetGroup`, `LatchGroup`, `LockGroup`.
1640+
1641+
Some examples of actions combination:
1642+
- `SetMods` + `SetGroup`: ok
1643+
- `SetMods` + `SetMods`: *error*
1644+
- `SetMods` + `LockMods`: *error*
1645+
- `SetMods` + `LockGroup`: ok
1646+
- Multiple actions are only supported from version 1.8.0.
1647+
16111648
@warning Keymaps containing multiple key symbols per level are not supported
16121649
by the various X11-related tools (`setxkbmap`, `xkbcomp`, etc.).
16131650
@@ -2018,6 +2055,7 @@ Common syntax:
20182055
### Modifiers actions {#modifiers-actions}
20192056

20202057
[modifier action]: @ref modifiers-actions
2058+
[modifier actions]: @ref modifiers-actions
20212059

20222060
@todo default values
20232061

@@ -2149,6 +2187,7 @@ These actions perform different tasks on key press and on key release:
21492187
### Group actions {#group-actions}
21502188

21512189
[group action]: @ref group-actions
2190+
[group actions]: @ref group-actions
21522191

21532192
There are 3 group actions:
21542193

0 commit comments

Comments
 (0)