Skip to content

Commit 03a7c05

Browse files
whotwismill
authored andcommitted
state: support pure virtual modifiers
Traditionally, virtual modifiers were merely name aliases for real modifiers, e.g. NumLock was usually mapped to Mod2 (see modifier_map statement). Virtual modifiers that were never mapped to a real one had no effect on the keymap state. This patch introduces the concept of pure virtual modifiers, i.e. virtual modifiers that are not mapped now show up as if the were true modifiers. Note that pure virtual modifiers cannot be used in an interpret action's AnyOf() and an interpret action for a pure 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 pure virtual modifier for keysym `a`. Interestingly, this fixes one current issue with our tests: previously the de(neo) layout level5 didn't take effect correctly, with this patch in place it now behaves.
1 parent e00a5e8 commit 03a7c05

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/xkbcomp/keymap.c

+12
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,18 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
349349
if (key->vmodmap & (UINT32_C(1) << i))
350350
mod->mapping |= key->modmap;
351351

352+
/*
353+
* Virtual modifiers that are not mapped, map to themselves. This excludes:
354+
* - Modifiers mapped *explicitly*: e.g. `virtual_modifiers VMod1 = 0x1;`.
355+
* - Modifiers mapped *implicitly* via vmodmap/modifier_map, i.e. the usual
356+
* way used in xkeyboard-config.
357+
*/
358+
xkb_vmods_enumerate(i, mod, &keymap->mods) {
359+
const xkb_mod_mask_t mask = UINT32_C(1) << i;
360+
if (mod->mapping == 0 && !(keymap->mods.explicit_vmods & mask))
361+
mod->mapping = mask;
362+
}
363+
352364
/* Update the canonical modifiers state mask */
353365
assert(keymap->canonical_state_mask == MOD_REAL_MASK_ALL);
354366
xkb_mod_mask_t extra_canonical_mods = 0;

0 commit comments

Comments
 (0)