pub(crate) fn layouts_in_keymap_text(text: &str) -> Vec<String>Expand description
The layout names a keymap declares, in group order.
From the name[N]="..." lines inside the compiled xkb_symbols section,
which is the one place in a keymap that names layouts unambiguously and in
the language a person reads: "Ukrainian", "English (Dvorak)".
Two wrong turns are worth recording, because both looked right.
The section’s own name is a recipe – pc_ua_us_2_inet(evdev)_group(alt_shift_toggle)
– and parsing it is a trap: the separator is _, the options’ arguments
contain _ themselves, the group index arrives as a bare token because
us:2 is written us_2, and a layout with a variant (us(dvorak)) cannot
be told from an option (inet(evdev)) without a list of every option group
xkb has, which would rot.
The second was name[Group1]=, which is what xkbcomp writes and what
every example online shows. libxkbcommon writes name[1]=. The difference
is invisible until you read a keymap this compositor actually sent, which
is what WL_PROBE_KEYMAP is for.
Confined to the symbols section on purpose: xkb_types is full of
level_name[1]= "Any", and a looser match reports the modifier levels as
keyboard layouts.