|
b21a58d0
|
2025-07-01T14:52:11
|
|
Add support for all level indices to LevelN constants
Note that serialization must use numbers instead of names for levels > 8,
to ensure backward compatibility.
|
|
e73d1a4d
|
2025-07-01T13:05:44
|
|
Add support for all layout indices to GroupN constants
This commit enables to use the pattern `Group<INDEX>` for any valid
group index `<INDEX>`.
Note that the original code in xkbcomp allows constants up to
`Group8`, but then will fail if the resulting group is > 4.
There does not seem to be any use case for this for such “feature”;
it seems rather to be a relic from times were the 4-groups limit
was not hopelessly fixed in X.
So for consistency in our code base, starting with this commit we now
disallow `Group5`..`Group8` for keymap format v1, since it is limited
to 4 groups.
Also fixed a regression in the serialization of group action, when
the group is relative.
|
|
84914512
|
2025-07-01T18:37:22
|
|
chore: Rename indexes to indices
Before this commit there was a mix between the two forms.
While “indexes” is correct, “indices” is more usual and also
the historical form used in this project.
|
|
58373807
|
2025-06-27T18:21:19
|
|
keysym: Do not convert UTF-32 to deprecated keysyms
Before this commit, some code points could be converted to deprecated
keysym. This is incorrect, because the relevant keysyms are all
deprecated because their mapping to Unicode is uncertain!
Ensure that `xkb_utf32_to_keysym()` never returns deprecated keysyms,
because there is either another non-deprecated keysym or in last resort
we always have the correct keysym available in the Unicode keysym range.
|
|
05d13d5f
|
2025-06-26T16:58:50
|
|
include: Fix infinite loop
Fixed including an absolute path with no default map triggering an
infinite loop.
|
|
447b7739
|
2025-06-22T10:27:31
|
|
test: Add examples for breaking latches using VoidAction()
Consider the following use cases:
1. If `Caps_Lock` is on the second level of some key, and `Shift` is
latched, pressing the key locks `Caps` while also breaking the `Shift`
latch, ensuring that the next character is properly uppercase.
2. On the German E1 layout, `ISO_Level5_Latch` is on the third level
of `<AC04>`. So if a level 3 latch is used to access it, the level 5
must break the previous level 3 latch, else both latches would be
active: the effective level would be 7 instead of the intended 5.
Both uses cases can be implemented using existing features:
- multiple actions per level;
- `VoidAction()`: to break latches.
|
|
c4f4ba41
|
2025-06-23T18:15:18
|
|
state: Fix modifier and group latch
Prior to this commit, the sequences:
- 1. latch A ↓
2. latch B ↓
3. latch B ↑
4. latch A ↑
- 1. latch A ↓
2. latch B ↓
3. latch A ↑
4. latch B ↑
would result in only B being latched, because the XKB protocol specifies
that latches are triggered only if keys are *sequentially* tapped, i.e.
a strict sequence of press and release of each key.
It seems an unnecessary limitation:
- `SlowKeys` and `XkbAX_TwoKeys` are the proper accessibility features
to control accidental key presses, not latches nor `StickyKeys`.
- Latches are also used outside their original accessibility role.
A user may activate multiple latch keys simultaneously:
- same hand: two latch keys being close to each other;
- different hand: two keys being activated independently.
Changed the latching behavior so that the rules used to break a latch
are the same than those used to prevent it. Depressing and releasing two
latching keys simultaneously will now activate both latches, as expected.
Since this is a breaking change, it is enabled only by the keymap format
`XKB_KEYMAP_FORMAT_TEXT_V2`.
|
|
d192b3b6
|
2025-06-19T21:57:46
|
|
keymap: Add option `unlockOnPress` for SetMods()
It enables e.g. to deactivate `CapsLock` *on press* rather than on
release, as in other platforms such as Windows.
It fixes a [18-year old issue] inherited from the X11 ecosystem, by
extending the [XKB protocol key actions].
As it is incompatible with X11, this feature is available only using the
keymap text format v2.
[18-year old issue]: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/issues/74
[XKB protocol key actions]: https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Key_Actions
|
|
ee87f6ed
|
2025-06-21T19:28:53
|
|
state: Fix broken latch not honoring clearLocks=no
Before this commit, breaking a latch (modifier & group) would always
clear locks, even if `clearLocks=no`.
|
|
94d8e341
|
2025-06-21T13:17:16
|
|
state: Fix LatchMods mutation to SetMods or LockMods
Previously we use inlined version of the corresponding filter functions
of the `SetMods()` and `LockMods()` actions, but they were incomplete
and did not set some fields (`priv`, `refcnt`) properly. Also, it is
error-prone: it requires discipline to keep it in sync.
E.g. before this commit, converting to `LockMods()` would always try to
unlock `CapsLock` due to the wrong value of the `priv` field.
Fixed by using the corresponding filter functions directly, so that we
always mutate the filter properly, as in `xkb_filter_group_latch_func`.
|
|
d351abee
|
2025-06-19T11:24:44
|
|
test: Use explicit keymap format for test_compile_file()
|
|
7a7a3b38
|
2024-02-14T09:47:15
|
|
keymap: Canonically map unmapped virtual modifiers
Traditionally, *virtual* modifiers were merely name aliases for *real*
modifiers (X *core* modifiers), e.g. `NumLock` was usually mapped to
`Mod2` (see `modifier_map` statement). Virtual modifiers that were never
mapped to a real ones had no effect on the keymap state.
xkbcommon already supports the concept of “pure” virtual modifiers, i.e.
virtual modifiers that are *encoded* using the full 32-bit range, not
just the first 8 bits corresponding to the real modifiers.
But until this commit, one had to declare such mapping *explicitly*:
e.g. `virtual_modifiers M = 0x100;`. This has at least two drawbacks:
- Numerical values may look quite arbitrary and are not user-friendly.
It’s OK in the resulting compiled keymap, but it requires careful sync
between sections when developing KcCGST files.
- If the modifier is *also* mapped *implicitly* using the traditional
`vmodmap`/`modifier_map`, then both mappings are OR-combined.
This patch enables to automatically map unmapped virtual modifiers to
their *canonical* mapping, i.e. themselves: their corresponding virtual
and real modifier masks are identical: `1u << mod_index`.
Since this feature is incompatible with X11, this is guarded by requiring
at least keymap text format **v2**.
Note that for now, canonical virtual modifiers cannot be used in an
interpret action’s `AnyOf()`. An interpret action for a canonical virtual
modifier must be `AnyOfOrNone()` to take effect:
virtual_modifiers APureMod, …;
interpret a+AnyOfOrNone(all) {
virtualModifier= APureMod;
action= SetMods(modifiers=APureMod);
};
The above adds a virtual modifier `APureMod` for keysym `a`. It will be
canonical iff it is not mapped implicitly.
|
|
69c3d257
|
2025-06-17T16:43:05
|
|
keymap: Add parameter `latchOnPress` for LatchMods()
Some keyboard layouts use `ISO_Level3_Latch` or `ISO_Level5_Latch` to
define “built-in” dead keys:
- they do not rely on the installation of custom Compose file;
- they do not clash with other layouts.
However, layout projects usually want the exact same behavior on all OS,
but the XKB latch behavior (often misunderstood) also acts as a *set*
modifier, which is not expected.
The usual behavior of a dead key on Linux, macOS and Windows is:
- latch on press;
- deactivate as soon as another (non-modifier) key is pressed.
Added the parameter `latchOnPress` to `LatchMods()` to enable the
aforementioned behavior.
As it is incompatible with X11, this feature is available only using the
keymap text format v2.
[XKB protocol key actions]: https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Key_Actions
|
|
c58c7df1
|
2025-06-17T21:05:08
|
|
Serialize multiple actions per level to VoidAction() in v1 format
When using `XKB_KEYMAP_FORMAT_TEXT_V1`, multiple actions per level are now
serialized using `VoidAction()`, in order to maintain compatibility with X11.
|
|
ee50e0c9
|
2025-06-12T20:14:50
|
|
keymap: Add option `unlockOnPress` for LockMods()
It enables e.g. to deactivate CapsLock on press rather than
on release, as in other platforms such as Windows.
The specification of `LockMods()` is changed to:
- On key *press*:
- If `unlockOnPress` is true and some of the target modifiers were
*locked* before the key press, then unlock them if `noUnlock` false.
- Otherwise:
- add target modifiers to *depressed* modifiers;
- if `noLock` is false, add target modifiers to the *locked*
modifiers.
- On key *release*:
- If `unlockOnPress` is true and triggered unlocking on key press, do
nothing.
- Otherwise:
- remove modifiers from the *depressed* modifiers, if no
other key that affect the same modifiers is down;
- if `noUnlock` is false and if any target modifiers was locked before
the key press, *unlock* them.
It fixes a [12-year old issue] inherited from the X11 ecosystem,
by extending the [XKB protocol key actions].
As it is incompatible with X11, this feature is available only using the keymap
text format v2.
[12-year old issue]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/312
[XKB protocol key actions]: https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Key_Actions
|
|
d9d82355
|
2025-06-12T09:13:27
|
|
keymap: Add option `lockOnRelease` for LockGroup()
It enables to use e.g. the combination `Control + Shift` *alone* to
switch layouts, while keeping the use of `Control + Shift + other key`
(typically for keyboard shortcuts).
The specification of `LockGroup()` is changed to:
- On key *press*:
- If `lockOnRelease` is set, then key press has no effect.
- Otherwise:
- if the `group` is absolute, key press sets the *locked* keyboard group to
`group`;
- otherwise, key press adds `group` to the *locked* keyboard group.
In either case, the resulting *locked* and *effective* group is brought back
into range depending on the value of the `GroupsWrap` control for the keyboard.
- On key *release*:
- If `lockOnRelease` is not set, then key release has no effect.
- Otherwise, if any other key was *pressed* after the locking key, then
key release has no effect.
- Otherwise, it has the same effect than a key press *without* `lockOnRelease`
set.
This is really useful for people coming from other platforms, such as
Windows.
It fixes a [20-year old issue] inherited from the X11 ecosystem, by
extending the [XKB protocol key actions].
As it is incompatible with X11, this feature is available only using the keymap
text format v2.
[20-year old issue]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/258
[XKB protocol key actions]: https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Key_Actions
|
|
c4c531da
|
2025-06-17T11:43:50
|
|
rules: Add layout-specific options for RMLVO builder
Change the signature of `xkb_rmlvo_builder_append_layout()` to accept
an array of options.
Also add tests for layout-specific options.
|
|
52a4d9b0
|
2025-06-17T11:03:12
|
|
rules: Require layout or variant to enable %i expansion
Before this commit, the following rule would always match:
! model = symbols
* = s:%i
and set symbols to `s:1`, but the `:%i` is aimed to be used only when
the rules header specifies the layout or the variant.
Let’s be strict and disallow matching this kind of buggy rule. Emit
an error message so that we can detect it.
|
|
ef6a550f
|
2025-06-16T15:48:25
|
|
Add xkb_keymap_new_from_rmlvo()
Use the new RMLVO builder API to compile keymaps.
|
|
ac9cd053
|
2025-06-11T19:00:47
|
|
test: Check extended layout indexes
|
|
717ce258
|
2025-06-11T18:34:15
|
|
test: Refactor rules-file and state
Split into dedicated functions fo better readability.
|
|
7f39be25
|
2025-06-10T15:46:45
|
|
test: Use explicit keymap output format for test_compile_output()
|
|
0f89ad97
|
2025-06-09T19:26:13
|
|
dump: Always use numeric group indexes
The upcoming raise of the maximum groups count will require to use
numeric group indexes instead of the syntax `GroupN` if groups > 8.
Let’s not bother with handling two cases (group count ≤ 8 or > 8) and
always serialize group indexes as numeric values.
|
|
f3386743
|
2025-06-09T16:44:54
|
|
test: Use explicit keymap format in test_compile_output()
|
|
2acf5eca
|
2025-06-09T16:26:56
|
|
test: Use explicit keymap format in test_compile_buffer()
|
|
6c5ea6fc
|
2025-06-09T16:15:20
|
|
test: Use explicit keymap format in test_compile_string()
|
|
79e95509
|
2025-06-09T11:07:36
|
|
test: Use explicit keymap format in test_compile_rules()
|
|
44c8deb2
|
2025-05-07T10:20:25
|
|
Introduce keymap format v2 and make it the default for parsing
- Added `XKB_KEYMAP_FORMAT_TEXT_V2`.
- Made `xkb_keymap_new_from_names()` use the new keymap format.
- Made the tools default to the new keymap format for input.
This is in preparation for changes in the parsing & state handling.
For now it changes nothing.
|
|
08149dae
|
2025-05-06T16:23:04
|
|
Add internal API to query and parse supported keymap formats
|
|
1a10f858
|
2025-05-06T18:05:06
|
|
Add xkb_keymap_new_from_names2
This is just `xkb_keymap_new_from_names()` with an explicit keymap
format.
|
|
16c079d6
|
2025-06-06T20:27:45
|
|
chore: Rename is_absolute to is_absolute_path
|
|
39b4b670
|
2025-06-06T18:40:29
|
|
Support including keymap components using %-expansion and absolute path
Enable to use the same `include` features than *rules* files in
*keymap components*:
- *`%`-expansion*: `%H` home directory, `%S` sytem root and `%E` extra.
- absolute file paths.
This is useful if one wants to overwrite the system file with a user
config (i.e. same name, but in `~/.config/xkb`), but still include the
system file:
```
// File: ~/.config/xkb/symbols/de
xkb_symbols "basic" {
include "%S/de(basic)"
key <AB01> { [z, Z] };
key <AD06> { [y, Y] };
}
````
Without the commit, using a mere `include "de(basic)"` would result in
an include loop.
Refactored by using the same code for rules and keymap components.
|
|
324984f1
|
2025-05-17T06:49:49
|
|
xkbcomp: Fix log for unknown default field
|
|
c3744cd3
|
2025-05-16T14:10:37
|
|
test: Fix Compose log
|
|
fb9fec18
|
2025-05-10T10:18:38
|
|
xkbcomp: Checked arithmetic
Use a polyfill for C23 checked arithmetic. This is a bit paranoid, as we
expect the user to use only 32 bit integers, so the signed 64 bit integer
we use to store the result should be more than enough.
Use jtckdint v1.0:
- repository: https://github.com/jart/jtckdint
- commit: 339450d13d8636f05dcb71ba36efddb226db481e
- removed all C++-specific code
|
|
9b4fd82b
|
2025-05-13T11:46:46
|
|
test: Skip checked arithmetic if not available
|
|
7a2aa9c9
|
2024-12-20T22:53:11
|
|
Always retain later Compose sequence in case of conflict
This ensures that it is always possible to override previous definitions,
for example when `include`ing the system Compose file.
Signed-off-by: Jules Bertholet <julesbertholet@quoi.xyz>
|
|
3a8bb1a1
|
2025-05-16T13:13:55
|
|
compose: Fix sequence not fully overriden
Previously if a new sequence did not produce a keysym or a string, the
corresponding property was not overriden, possibly leaking the previous
entry.
- Fixed by always writting all the properties.
- Also try to reuse the previous string entry, if possible, so that we
avoid allocating.
|
|
af5eacea
|
2025-05-12T19:38:04
|
|
test: Fix uninitialized variable
Warning from MSVC.
|
|
72ed9104
|
2025-05-12T19:29:24
|
|
test: Use standard C rather than POSIX API
Windows does not use the same functions signatures and generates a lot
of warnings.
|
|
61d8ec67
|
2025-05-12T18:20:47
|
|
misc: Fix string format specifiers
Ensure better portability.
|
|
3031f6c3
|
2025-05-12T10:38:15
|
|
misc: Always use `unsigned` with `int`
Better semantics & facilitate search.
|
|
3bfc1bc1
|
2025-05-12T18:52:05
|
|
misc: Ensure proper type for darray size
|
|
41bb797d
|
2025-05-12T07:31:33
|
|
symbols: Ensure proper type for keysyms count
|
|
9951184e
|
2025-05-10T10:15:54
|
|
actions: Properly reset type to NoAction on error
If we do not reset the type, the action may lready have been initialized
to with a default action and thus will not be ignored.
|
|
22d27277
|
2025-05-10T10:12:31
|
|
actions: Reject arguments if they are not expected
`NoAction`, `VoidAction` and `TerminateServer` do not accept arguments.
|
|
d239a3f0
|
2025-05-11T11:42:20
|
|
actions: Improve unsupported legacy X11 actions handling
- Display a warning
- Document drawbacks of degrading to `NoAction()`
|
|
b4c89600
|
2025-05-09T15:15:10
|
|
actions: Add VoidAction(), mirroring NoSymbol/VoidSymbol.
Added `VoidAction()` action to match the keysym pair
`NoSymbol` / `VoidSymbol`.
It enables overriding a previous action and breaks latches.
This is a libxkbcommon extension. When serializing it will be converted to
`LockControls(controls=none,affect=neither)` for backward compatibility.
We cannot serialize it to `NoAction()`, as it would be dropped in e.g.
the context of multiple actions.
|
|
9191ccc9
|
2025-05-09T15:39:53
|
|
test: Added further case to xkb_state_update_latched_locked
Test group lock wrap.
|
|
551cca2a
|
2024-12-03T10:12:03
|
|
state: Add server API for updating latched and locked mods & layout
Up to now, the “server state” `xkb_state` API only offered one entry
point to update the server state – `xkb_state_update_key`, which reflects
the direct keyboard keys state. But some updates come out-of-band from
keyboard input events stream, for example, a GUI layout switcher.
The X11 XKB protocol has a request which allows for such updates,
`XkbLatchLockState`[^1], but xkbcommon does not have similar
functionality. So server applications ended up using
`xkb_state_update_state` for this, but that’s a function intended for
client applications, not servers.
Add support for updating the latched & locked state of the mods and
layout. Note that the depressed states cannot be updated in this way --
XKB does not expect them to be updated out of band.
[^1]: https://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html#Querying_and_Changing_Keyboard_State
Fixes: #310
Signed-off-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Pierre Le Marre <dev@wismill.eu>
|
|
7cd1180b
|
2025-05-06T11:07:47
|
|
modifiers: Add xkb_keymap_mod_get_mask()
Added a dedicated API to query modifier masks rather than relying on
a hack using `xkb_state_update_mask` and `xkb_state_serialize_mods`.
Furthermore, this hack may not work in the future if we remove virtual
mods resolution in `xkb_state_update_mask` to avoid corner-cases issues.
|
|
a3f1a9d3
|
2025-02-04T20:45:38
|
|
xkbcomp/parser: enable Bison detailed syntax error
It's not much, but instead of
xkbcommon: ERROR: [XKB-769] (unknown file):5:25: syntax error
we get
xkbcommon: ERROR: [XKB-769] (unknown file):5:25: syntax error, unexpected +, expecting INTEGER
which is at least a little helpful.
Signed-off-by: Ran Benita <ran@unusedvar.com>
|
|
e00a5e83
|
2025-05-07T16:10:04
|
|
Add tests for pure virtual modifiers
|
|
c2d3694b
|
2025-05-06T07:01:01
|
|
xkbcomp: Do not discard extra bits in vmod masks
Since we accept numeric values for the vmod mask in the keymap, we may
have extra bits set that encode *no* real/virtual modifier. Keep them
unchanged for consistency.
E.g. the following keymap:
xkb_keymap {
xkb_keycodes { <a> = 38; };
xkb_symbols {
virtual_modifiers X = 0xf0000000;
key <a> { [ SetMods(mods = 0x00001100) ] };
};
};
would compile to:
xkb_keymap {
xkb_keycodes { <a> = 38; };
xkb_symbols {
virtual_modifiers X = 0xf0000000;
// Internal state
key <a> { [ SetMods(mods = 0xf0001000) ] };
// Serialization
key <a> { [ SetMods(mods = 0x00001100) ] };
};
};
|
|
dddffd51
|
2025-05-05T13:22:57
|
|
state: Fix virtual modifiers with non-real mod mapping
Currently there are 2 issues with the handling of virtual modifiers
in the keyboard state:
1. We assume that the input modifiers masks encode the indexes of all
the modifiers of the keymap, but this is true only for the *real*
modifiers (at least in xkbcommon and X11). Indeed, since the virtual
modifiers *indexes* are implementation-specific, the input modifier
masks merely *encode* the modifiers via their *mapping*.
Consider the following keymap:
```c
xkb_keymap {
xkb_compat { virtual_modifiers M1 = 0x100; };
xkb_types { virtual_modifiers M2 = 0x200; };
};
```
Now to illustrate, consider the following 2 implementation variants
of libxkbcommon (assuming indexes 0-7 are the usual real modifiers):
1. Process `xkb_compat` then `xkb_types`.
M1 and M2 have the respective indexes 8 and 9 and map to
themselves (with the current assumption about mask denotation).
2. Process `xkb_types` then `xkb_compat`.
M1 and M2 have the respective indexes 9 and 8 and map to each
other.
With the current `xkb_state_update_mask`, implementation 2 will swap
M1 and M2 (compared to impl. 1) at each update! Indeed, we can see that
`xkb_state_serialize_mods` doesn’t roundtrip via `xkb_state_update_mask`.
2. We assume that modifier masks use only bits denoting modifiers in
the keymap, but when parsing the keymap we accept explicit virtual
modifiers mapping of arbitrary values.
E.g. if `M1` is the only virtual modifier and it is defined by:
```c
virtual_modifiers M1 = 0x80000000; // 1 << (32 - 1)
```
then the 32th bit of a modifier mask input does *not* denote the
32th virtual modifier of the keymap, but merely the encoding of the
mapping of `M1`.
So when calling `xkb_state_update_mask`, we may discard some bits of
the modifiers masks and end up with an incorrect state.
These 2 issues may break interoperability with other implementations of
XKB (e.g. kbvm) and make pure virtual modifiers handling fragile.
We introduce the notion of *canonical state modifier mask*: the mask
with the smallest population count that denotes all bits used to encode
the modifiers in the keyboard state. It is equal to the bitwise OR of
real modifiers mask and all the virtual modifiers mappings.
This commit fixes the 2 issues by making *weaker* assumptions about the
input modifier masks:
1. Modifiers may map to arbitrary values, not only real modifiers.
2. Input modifier masks merely encode modifiers via their *mapping*:
- *real* modifiers map to themselves;
- *virtual* modifiers map to the bitwise OR of their *explicit*
mapping (via `virtual_modifiers`) and their *implicit* mapping (via
keys’ real and virtual modmaps).
- modifiers indexes are implementation-specific.
Since the implementation before this commit also resolved virtual
modifiers to their mappings, we continue doing so, but using only the
bits that are *not* set in the canonical state modifier mask, so that
we enable roundtrip of `xkb_state_serialize_mods` via
`xkb_state_update_mask`.
3. Input modifier masks do not denote modifiers indexes (apart from real
modifiers), so it is safe to discard only the bits that are not set
in the canonical state modifier mask.
|
|
d5b779e1
|
2025-05-06T21:07:28
|
|
keymap: Fix empty compat interpretation map serialization
X11’s `xkbcomp` requires at least one compat interpretation entry.
|
|
87f9ac76
|
2025-05-06T21:02:23
|
|
keymap: Fix empty compat interpretation statement serialization
Statements such as `interpret VoidSymbol {};` can cannot be parsed by
X11’s `xkbcomp`.
Fixed by using a dummy action.
|
|
ac42ce29
|
2025-05-06T21:29:46
|
|
test: Check xkeyboard-config xkbcommon → xkbcomp chaining
|
|
230b6a6a
|
2025-05-06T14:35:26
|
|
Fix key type map entry with unbound vmod not ignored
Currently we only ignore key type map entries with non-zero mods and
with a zero modifier mask. However, the XKB protocol states ([source]):
> Map entries which specify unbound virtual modifiers are not considered.
So we currently handle `map[Unbound]` key type map entries (all modifiers
unbound) but not `map[Bound+Unbound]` entries (mix of bound and unbound
modifiers).
Fixed by properly checking unbound modifiers on each key type map entry.
This also fixes a test that was accidentally passing.
[source]: https://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html#:~:text=Map%20entries%20which%20specify%20unbound%20virtual%20modifiers,not%20considered
|
|
f8148744
|
2025-05-06T11:26:21
|
|
Define the mapping of real modifiers explicitly
When querying for a modifier mapping, we should treat all modifiers
equally. So simply store real modifier mapping as we do for the virtual
ones.
Also fixed useless boolean conversions.
|
|
cd512b8f
|
2025-05-02T19:21:09
|
|
x11: Fix capitalization transformation
|
|
4d605b70
|
2025-04-29T11:18:36
|
|
tests: Ensure random generator use an explicit seed
This enable debugging with the exact same seed.
|
|
963c062c
|
2025-04-29T11:02:16
|
|
tests: Refactor utils
Some parts relied on undefined behavior and it had duplicated tests.
|
|
0bfd097c
|
2025-04-28T08:37:31
|
|
test: Fix main() function prototype
Fix compilation error when building for Windows with clang-cl:
../subprojects/libxkbcommon-xkbcommon-1.9.0/test/keysym-unicode.c:11:1: error: return type defaults to 'int' [-Wimplicit-int]
../subprojects/libxkbcommon-xkbcommon-1.9.0/test/keysym-unicode.c:11:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
|
|
21a341f2
|
2025-03-24T09:21:40
|
|
test: Enable 3rd party compilers
|
|
9b0b8c68
|
2025-04-15T19:53:28
|
|
xkbcomp: Stricter handling of default map include
Before this commit, including a *default* map, i.e. without an explicit
section name (e.g. `include "au"` vs `include "au(basic)"`) would match
the first section of the first matching file in the XKB include paths,
even if this section is not an *explicit* default map (i.e. tagged with
`default`) but an *implicit* default map (i.e. the first map of the
file, i.e. a weak match).
It makes user configuration risky: say a user wants to create a custom
version `au(custom)` of the `au` layout:
- `./config/xkb/symbols/au`: custom layout in section “custom”.
- `/usr/share/X11/xkb/symbols/au`: system layout, with *default* section
“basic”.
In this setup *any* layout that imports the default map from `au` would
in fact import the *implicit* default map `au(custom)` instead of the
*explicit* default map `au(basic)`.
This incorrect behavior may thus break setups with multiple layouts.
This is especially true for symbols files such as: `pc`, `us` or `latin`.
Fixed by trying harder to found the exact default map, defaulting to the
old behavior (weak match) only if no *explicit* default map (exact match)
has been found in the XKB include paths.
|
|
00585c5c
|
2025-04-15T18:41:03
|
|
doc: Keymap format + misc
|
|
9ede705b
|
2025-04-13T09:50:18
|
|
state: Capitalization transformation in xkb_state_key_get_syms
Previously `xkb_state_key_get_syms()` did not perform capitalization
tranformation, while `xkb_state_key_get_one_sym()` does perform it.
This is unfortunate if we want to promote the use of multiple keysyms
per levels.
The API make it difficult to change now though: we return a pointer to
an immutable array rather than filling a buffer. While we could use an
internal buffer in `xkb_state`, this option would limit the API to
*sequential* calls of `xkb_state_key_get_syms()` or require some buffer
handling (e.g. rotation).
Instead we now store the capitalization directly in `xkb_level`. We
modified `xkb_level` like so (see below for discussion about the size):
```diff
struct xkb_level {
- unsigned int num_syms;
+ uint16_t num_syms;
- unsigned int num_actions;
+ uint16_t num_actions;
+ union {
+ /** num_syms == 1: Upper keysym */
+ xkb_keysym_t upper;
+ /** num_syms > 1: Indicate if `syms` contains the upper case
+ * keysyms after the lower ones. */
+ bool has_upper;
+ };
union {
xkb_keysym_t sym; /* num_syms == 1 */
xkb_keysym_t *syms; /* num_syms > 1 */
} s;
union {
union xkb_action action; /* num_actions == 1 */
union xkb_action *actions; /* num_actions > 1 */
} a;
};
```
- When `level.num_syms` <= 1, we store the upper keysym in `level.upper`.
- Else if there no cased syms, we set `level.has_upper` to false.
- Else if there are some cased syms, we set `level.has_upper`` to `true`
and we double the original size of `level.s.syms`, but *without*
modifying `level.num_syms`. We then append the transformed keysyms
right after the original ones, so that we can access them by a simple
pointer operation: `level.s.syms + level.num_syms`.
The memory footprint is *unchanged*, thanks to the reduced fields for
actions and keysyms counts.
|
|
636b8b97
|
2025-03-19T14:11:52
|
|
test: Add merge mode tests for all the sections
The merge modes tests C file is now only generated locally, because it
is too large. The generator Python script requires Jinja2, so the test
is optional and depends on Jinja22 availability.
The test aim to be exhaustive with various combinations of a base and
an update:
- plain base + plain update, for every mode
- plain base + include (for every mode) update (every mode)
- single include (base +| update)
|
|
216352db
|
2025-04-10T14:58:25
|
|
test: Improve xkeyboard-config script
- Enable setting the XKB root directory. By far the most important
change.
- Enable to pass registry XML files relative to the target rules
directory (with or without the `.XML` extension).
- Enable to set the rules set to use.
- Better JSON/YAML escaping.
- Better error logging.
|
|
a1e595e7
|
2025-04-11T11:13:25
|
|
rules: Fix merging KcCGST values in layout order
When using layout index ranges (e.g. special indexes “any” or “later”),
the rules still match following the order in the rules file, so layout
indexes may match without following their natural order. So the resulting
KcCGST value should not be merged with the output until reaching the end
of the rule set.
Because the rule set may also involve options, it may match multiple
times for the *same* layout index. So these multiple matches should not
be merged together either, until reaching the end of the rule set.
When reaching the end of the rule set, for each KcCGST component the
pending values are then merged: for each layout, for each KcCGST value
in the corresponding sequence, merge with the output.
---
Example:
! model = symbols
* = pc
! layout[any] option = symbols
C 1 = +c1:%i
C 2 = +c2:%i
B 3 = skip
B 4 = +b:%i
The result of RMLVO
{layout: "A,B,C", options: "4,3,2,1"}
is:
symbols = pc+b:2+c1:3+c2:3
- `skip` was dropped because it has no explicit merge mode;
- although every rule was matched in order, the resulting order of the
symbols follows the order of the layouts, so `+b` appears before `+c1`
and `+c2`.
- the relative order of the options for layout C follows the order
within the rule set, not the order of RMLVO.
Before this commit, the result would have been:
symbols = pc+c1:3+c2:3+b:2
|
|
66f71890
|
2025-03-31T08:01:29
|
|
symbols: Enable writing keysyms list as UTF-8 strings
Each Unicode code point of the string will be translated to their
respective keysym, if possible. An empty string denotes `NoSymbol`.
When such conversion is not possible, this will raise a syntax error.
This introduces the following syntax:
```c
// Empty string = `NoSymbol`
key <1> {[""]}; // NoSymbol
// Single code point = single keysym
key <2> {["é"]}; // eacute
// String = translate each code point to their respective keysym
key <3> {["sßξك🎺"]}; // {s, ssharp, Greek_xi, Arabic_kaf, U1F3BA}
// Mix string and keysyms
key <4> {[{"ξ", Greek_kappa, "β"}]}; // { Greek_xi, Greek_kappa, Greek_beta}
```
It can also be used wherever a keysym is required, e.g. in `interpret`
and `modifier_map` statements. In these cases a single keysym is expected,
so the string should contain *exactly one* Unicode code point.
|
|
ead3ce77
|
2025-03-28T21:44:27
|
|
scanner: Enable LRM and RLM marks for BiDi text
Enable displaying bidirectional text in XKB files using:
- U+200E LEFT-TO-RIGHT MARK
- U+200F RIGHT-TO-LEFT MARK
We now parse these marks as white space. As such, they are dropped;
note that a later serialization may not display correctly without
the marks, although it will parse.
References:
- https://www.w3.org/International/articles/inline-bidi-markup/uba-basics
- https://www.w3.org/International/questions/qa-bidi-unicode-controls
- https://www.unicode.org/reports/tr31/#Whitespace
- https://www.unicode.org/reports/tr55/
|
|
bc3e464b
|
2025-04-09T12:35:05
|
|
keysyms: Fix Unicode handling
- `xkb_utf32_to_keysym`: Allow [Unicode noncharacters]. There is no
requirement to drop them and this would be the only function of our
API doing so.
From the Unicode Standard 16.0, section 23.7 “Noncharacters”:
> Applications are free to use any of these noncharacter code points
> internally. They have no standard interpretation when exchanged
> outside the context of internal use. However, they are not illegal
> in interchange, nor does their presence cause Unicode text to be
> ill-formed.
> If a noncharacter is received in open interchange, an application is
> not required to interpret it in any way. It is good practice,
> however, to recognize it as a noncharacter and to take appropriate
> action, such as replacing it with `U+FFFD` REPLACEMENT CHARACTER,
> to indicate the problem in the text.
The key part is:
> an application is not required to interpret it in any way
Since we handle the reverse conversion with `xkb_keysym_to_utf32` just
fine, I do not see a good motivation to keep this asymmetry. This is
the only function with a special case for these code points.
- `xkb_keysym_from_name`:
- Unicode format `UNNNN`: allow control characters C0 and C1 and use
`xkb_utf32_to_keysym` for the conversion when `NNNN < 0x100`, for
backward compatibility.
- Numeric hexadecimal format `0xNNNN`: *unchanged*. Contrary to the
Unicode format, it does not normalize any keysym values in order to
enable roundtrip with `xkb_keysym_get_name`.
Also added tests to ensure various properties and consistency.
Note about *surrogates*: they are valid valid *code points* but invalid
Unicode *scalar values*, i.e. they cannot be encoded in any Unicode
encoding form (UTF-8, UTF-16, UTF-32). So their corresponding Unicode
keysyms are valid, but:
- cannot be used as input of `xkb_keysym_to_utf32` nor `xkb_keysym_to_utf8`
- cannot result as output of `xkb_utf32_to_keysym`.
Otherwise they are valid e.g. in the Unicode keysym notation.
[Unicode noncharacters]: https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Noncharacters
|
|
08d9a031
|
2025-04-08T06:31:33
|
|
Unicode: Make surrogate handling more explicit
|
|
5e557040
|
2025-04-09T11:17:00
|
|
xkbcomp: Fix Unicode escape sequence
While the previous code correctly rejected malformed sequences such as
`\u{` (incomplete) or `\u{123x}`, it should try to consume as much input
as possible until reaching the corresponding closing `}` within the
string. Else we can get leftovers and the error message does not
reference the whole malformed sequence.
Also added further tests with surrogates and noncharacters.
|
|
ca798d21
|
2025-04-08T16:21:46
|
|
keysyms: Pad Unicode keysyms only up to 4 digits
Previously there was a distinction between keysyms with code points in
BMP and the others: the former used a 4-padding while the latter used
a 8-padding: e.g `U0001` vs `U00010000`. This is unnecessary and makes
the reading harder.
Let’s use the same padding for all: `U0001` and `U10000`.
Parsing remains unchanged and would parse both paddings.
Also added a test to check no explicit name can clash with Unicode
notation.
|
|
47c2c820
|
2025-04-08T18:09:41
|
|
Add internal API to get all explicit names of a keysym
|
|
102f4ba1
|
2025-04-06T19:38:53
|
|
Fix integer conversion warnings
|
|
3370ead3
|
2025-04-06T06:39:31
|
|
test: Better handling of missing xkbcomp for X11 tests
- meson: Warn if missing xkbcomp for X11 tests;
- test: Better logging to spot missing Xorg executables.
|
|
36442baa
|
2025-04-03T15:01:46
|
|
xkbcomp: Support multiple actions in interpret
Before this commit we supported multiple actions per level, but not in
*interpret* statements. Let’s fix this asymmetry, so we can equivalently
assign all actions sets either implicitly or explicitly.
|
|
f348c6e9
|
2025-04-05T12:48:50
|
|
logging: Quote invalid escape sequence
|
|
6d4cc135
|
2025-04-05T13:39:30
|
|
xkbcomp: Escape ASCII control characters
|
|
3d79f459
|
2025-03-29T11:46:34
|
|
xkbcomp: Add Unicode code point escape sequence \u{NNNN}
Unicode code point escape sequences `\u{NNNN}` are replaced with the
UTF-8 encoding of their corresponding code point `U+NNNN`, if legal.
Supported Unicode code points are in the range `1‥0x10ffff`.
Note that we will reject the `U+0000` NULL code point, as we reject it
in the octal escape sequence `\0`.
This is intended mainly for the upcoming feature to write keysyms as
UTF-8 encoded strings. It can be used for various reasons:
- avoid encoding issues;
- avoid issue with font rendering (e.g. Asian scripts);
- make white space or zero-width characters more readable.
|
|
7d91a753
|
2025-03-29T12:24:39
|
|
xkbcomp: Enable xkbcomp-style octal escape sequences
Xorg xkbcomp only parses octal sequences with `\0`, while xkbcommon
does not force the `0` prefix of the numeric part. However, we only
parsed up to to 3 digits, which does not allow to parse e.g. `\0377`
while `\377` parses fine.
Fixed by parsing up to 4 octal digits, while checking the result fits
into a byte.
|
|
aa8b572e
|
2025-03-29T12:04:26
|
|
keymap serialization: Ensure escaping relevant chars
Previously we would write characters without any escaping in some
cases (e.g.: names of indicators, types and groups). E.g. the string
"new\nline"
would be serialized as:
"new
line"
which would raise a syntax error if parsed.
Fixed by escaping any string that was not escaped after parsing (e.g.
the section names are safe already).
|
|
d2f7b9cd
|
2025-04-04T17:29:35
|
|
rules: Do not use strto* parsers
|
|
d5a91fa9
|
2025-04-04T16:38:16
|
|
xkbcomp: Use custom parsers instead of strtol*
The use of `strtol*` functions was already restricted due to its
slowness and its capacity to parse other stuff than digits (e.g.
signs and spaces).
There is also another *big* limitation: it requires a NULL-terminated
string. This is incompatible with our functions that work on buffers,
because we cannot guarantee this. This may lead to a memory violation
if the last token is a number.
We now roll out our own parsers, which are more efficients and
compatible with buffers.
|
|
44480f7c
|
2025-04-01T08:28:02
|
|
xkbcomp: Enable lists of keysyms and actions {} and {a}
Motivations:
- Follow the principle of least astonishment;
- Ensure consistency;
- Enhance the use of custom defaults;
- Facilitate the tests.
There is some ambiguity because we use `{}` to denote both an empty list of
keysyms and an empty list of actions. But as soon as we get a keysym or an
action, we know whether it is a `MultiKeySymList` or a `MultiActionList`.
So we just count the `{}` at the *beginning* using `NoSymbolOrActionList`,
then replace it by the relevant count of `NoSymbol` or `NoAction()` once the
ambiguity is solved. If not, this is a list of empties of *some* type: we
drop those empties and delegate the type resolution using `ExprEmptyList()`.
|
|
e09cbe66
|
2025-04-02T10:46:06
|
|
symbols: Fix handling of empty keys
Before this commit, the following symbols:
```c
xkb_symbols {
virtual_modifiers M1, M2;
key <A> {};
key <B> { [] };
key.vmods = M1;
key <C> {};
key <D> { vmods = M2 };
};
```
would be equivalent to:
```c
xkb_symbols {
virtual_modifiers M1,M2;
key <B> { [ NoSymbol ] };
};
```
`<B>` entry could be skipped but is harmless. However, `<C>` and `<D>`
are missing, which would lead to the mapping resolution of `M1` and
`M2` failing.
After this commit, it is equivalent to:
```c
virtual_modifiers M1,M2;
key <C> { vmods = M1 };
key <D> { vmods = M2 };
```
Empty keys are skipped entirely, but any explicit field:
- is taken into account: previously they would be skipped if there
were no group;
- forces the key to be printed at serialization.
|
|
2e0245f8
|
2025-04-02T10:45:44
|
|
xkbcomp: Enable more empty lists
- Empty `interpret`
- Empty key `type`
- Empty `indicator`
Motivations:
- Follow the principle of least astonishment;
- Ensure consistency;
- Enhance the use of custom defaults;
- Facilitate the tests.
|
|
6881fb32
|
2025-04-01T08:28:02
|
|
xkbcomp: Drop trailing NoSymbol and NoAction()
This brings us closer to what `xkbcomp` outputs. One should use
the explicit `VoidSymbol` instead of `NoSymbol`, in order to avoid
dropping empty levels.
This may affect keys that rely on an *implicit* key type. Example:
- Input:
```c
key <> { [a, A, NoSymbol] };
```
- Compilation with xkbcommon \< 1.9.0:
```c
key <> {
type= "FOUR_LEVEL_SEMIALPHABETIC",
[a, A, NoSymbol, NoSymbol]
};
```
- Compilation with xkbcommon ≥ 1.9.0:
```c
key <> {
type= "ALPHABETIC",
[a, A]
};
```
|
|
fbacdd98
|
2025-03-31T07:58:04
|
|
test: Refactor test_multi_keysyms_actions
- Use less macros
- Add golden tests to check the compilation *result*
|
|
b254cc2e
|
2025-03-30T12:27:15
|
|
test: Remove empty components boilerplate
|
|
8ba5c453
|
2025-03-30T10:07:10
|
|
xkbcomp: Use section reference as default section name
Before this commit the following keymap:
```c
xkb_keymap {
xkb_keycode {};
};
```
would result in (boilerplate removed):
```c
xkb_keymap {
xkb_keycode "(unnamed)" {};
};
```
This is both useless and wasting allocation: section names are optional,
so we should just remove this default name altogether and keep it
undefined, as in the original keymap.
The situation is a bit different if there is an include, as for keymaps
created from RMLVO names. Before this commit, the following keymap:
```c
xkb_keymap {
xkb_keycode { include "evdev+aliases(qwerty)" };
};
```
would result in (boilerplate removed):
```c
xkb_keymap {
xkb_keycode "(unnamed)" { … };
};
```
With this commit we now follow the Xorg xkbcomp style by using the
section reference (the include string) as the *default* section name. So
the previous example would now result in:
```c
xkb_keymap {
xkb_keycode "evdev_aliases(qwerty)" { … };
};
```
which is useful to give a hint of the original include.
Note that if the original section had a name, it would preserve it:
```c
xkb_keymap {
xkb_keycode "test" { include "evdev+aliases(qwerty)" };
};
```
would compile to:
```c
xkb_keymap {
xkb_keycode "test" { … };
};
```
|
|
3150bca8
|
2025-03-30T09:54:02
|
|
xkbcomp: Make all components optional
We already accept *empty* components, such as: `xkb_compat {};`. Let’s
accept missing components as well, so that we can reduce the boilerplate
in our tests.
Note that we will still explicitly serialize empty components for
compatibility with previous xkbcommon versions and Xorg xkbcomp.
|
|
23598fa1
|
2025-03-25T22:52:06
|
|
Enable merge mode “replace” in include statements
Previously only the merge modes “override” and “augment” were available
in include statements, using the prefix ‘+’ and ‘|’ respectively. While
on one hand `replace` include statement can be used in keymap files, on
the other hand *rules* files have no way to express the *replace* mode.
This commit enables the merge mode “replace” using the prefix `^`. This
prefix was chosen due to its similarity with the `XOR` bit operator,
which convey *mutual exclusion*.
Other candidates:
- `!` conveys some kind of higher precedence, akin to CSS `!important`.
But it conflicts with the section header `!`, which is a token in the
current parser. It would require special handling, not worth it. It
also convey the meaning of negation, which is confusing.
- `&` has the advantage of not corresponding to a token in the rules
parser. `^` seems however to stand out more and it is less likely to
trigger erroneous comparison with `|` and `&` bit operators.
|
|
6fc6e64b
|
2025-03-26T10:35:22
|
|
rules: Added extended wild cards <none>, <some> and <any>
Added the following wild cards to the rules file syntax, in addition
to the current `*` legacy wild card:
- `<none>`: Match *empty* value.
- `<some>`: Match *non-empty* value.
- `<any>`: Match *any* (optionally empty) value. Its behavior does not
depend on the context, contrary to the legacy wild card `*`.
This will enable writing much simpler rules, see [!764] for an example
of tricky rules in the `xkeyboard-config` project, that would benefit
from the new wild cards.
[!764]: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/merge_requests/764
The verbose wild cards are preferred to single characters:
- More intuitive: self-explanatory.
- Does not steal syntax from other token.
- Extensible syntax, should we need it.
A previous proposal used the characters (`!`, `+`, `?`) for their
similarity with the corresponding syntax of regular expressions
(negative assertion & quantifiers), in line with `*`. But `!` is not
that intuitive after all and conflict with its role as section header.
Furthermore, `+` is also used as a merge mode. Finally, nothing beats
whole short words for readability.
|
|
500b260b
|
2025-03-28T09:38:58
|
|
xkbcomp: Fix parser failure on floating-point numbers
Before this commit we used `strtold`, which depends on the locale. But
the XKB syntax is fixed and uses a period as decimal separator. So ensure
the syntax is correct without relying on `strtold` and truncate the
result, as the parser does not use floating-point numbers.
|
|
d3188d33
|
2025-03-28T07:11:09
|
|
test: Enable using the user locale
This enable to test different locales easily. Note that the logging
tests requires resetting the locale back to `C`.
|