VModMaskText(keymap, interp->mods));
if (interp->virtual_mod != XKB_MOD_INVALID) {
+ xkb_mod_index_t idx = interp->virtual_mod - XKB_NUM_CORE_MODS;
write_buf(buf, "\t\t\tvirtualModifier= %s;\n",
xkb_atom_text(keymap->ctx,
- darray_item(keymap->vmods,
- interp->virtual_mod).name));
+ darray_item(keymap->vmods, idx).name));
}
if (interp->match & MATCH_LEVEL_ONE_ONLY)
simple = false;
}
- if (key->vmodmap && (key->explicit & EXPLICIT_VMODMAP)) {
- /* XXX: vmodmap cmask? */
+ if (key->vmodmap && (key->explicit & EXPLICIT_VMODMAP))
write_buf(buf, "\n\t\t\tvirtualMods= %s,",
- VModMaskText(keymap, key->vmodmap << XKB_NUM_CORE_MODS));
- }
+ VModMaskText(keymap, key->vmodmap));
switch (key->out_of_range_group_action) {
case RANGE_SATURATE:
return rtrn;
}
-/* Get a vmod name's text, where the vmod index is zero based. */
-static const char *
-VModIndexText(struct xkb_keymap *keymap, xkb_mod_index_t ndx)
-{
- if (ndx >= darray_size(keymap->vmods))
- return "illegal";
- return xkb_atom_text(keymap->ctx,
- darray_item(keymap->vmods, ndx).name);
-}
-
/* Get a mod mask's text, where the mask is in rmods+vmods format. */
const char *
VModMaskText(struct xkb_keymap *keymap, xkb_mod_mask_t cmask)
char buf[BUFFER_SIZE];
rmask = cmask & 0xff;
- vmask = cmask >> XKB_NUM_CORE_MODS;
+ vmask = cmask & (~0xff);
if (rmask == 0 && vmask == 0)
return "none";
if (rmask != 0)
mm = ModMaskText(rmask);
+ if (vmask == 0)
+ return mm;
+
str = buf;
buf[0] = '\0';
rem = BUFFER_SIZE;
- if (vmask != 0) {
- for (i = 0; i < darray_size(keymap->vmods) && rem > 1; i++) {
- if (!(vmask & (1 << i)))
- continue;
+ for (i = 0; i < darray_size(keymap->vmods) && rem > 1; i++) {
+ const char *name;
- len = snprintf(str, rem, "%s%s",
- (str != buf) ? "+" : "",
- VModIndexText(keymap, i));
- rem -= len;
- str += len;
- }
+ if (!(vmask & (1 << (i + XKB_NUM_CORE_MODS))))
+ continue;
- str = buf;
+ name = xkb_atom_text(keymap->ctx, darray_item(keymap->vmods, i).name);
+ len = snprintf(str, rem, "%s%s", (str != buf) ? "+" : "", name);
+ rem -= len;
+ str += len;
}
- else
- str = NULL;
+
+ str = buf;
len = (str ? strlen(str) : 0) + (mm ? strlen(mm) : 0) +
(str && mm ? 1 : 0);
darray_enumerate(i, vmod, keymap->vmods) {
if (vmod->name == field) {
- *val_rtrn = i;
+ *val_rtrn = XKB_NUM_CORE_MODS + i;
return true;
}
}
return true;
}
else if (LookupVModIndex(priv, field, type, &ndx)) {
- *val_rtrn = (1 << (XKB_NUM_CORE_MODS + ndx));
+ *val_rtrn = (1 << ndx);
return true;
}
darray_enumerate(i, vmod, keymap->vmods) {
if (vmod->name == name) {
- *ndx_rtrn = i;
+ *ndx_rtrn = XKB_NUM_CORE_MODS + i;
return true;
}
}
{
const struct xkb_vmod *vmod;
xkb_mod_index_t i;
- xkb_mod_mask_t vmask = mods->mods >> XKB_NUM_CORE_MODS;
/* The effective mask is only real mods for now. */
mods->mask = mods->mods & 0xff;
darray_enumerate(i, vmod, keymap->vmods)
- if (vmask & (1 << i))
+ if (mods->mods & (1 << (i + XKB_NUM_CORE_MODS)))
mods->mask |= vmod->mapping;
}
static bool
ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
{
- xkb_mod_mask_t vmodmask = 0;
+ xkb_mod_mask_t vmodmap = 0;
xkb_layout_index_t group;
xkb_level_index_t level;
if ((group == 0 && level == 0) ||
!(interp->match & MATCH_LEVEL_ONE_ONLY)) {
if (interp->virtual_mod != XKB_MOD_INVALID)
- vmodmask |= (1 << interp->virtual_mod);
+ vmodmap |= (1 << interp->virtual_mod);
}
if (interp->act.type != ACTION_TYPE_NONE)
}
if (!(key->explicit & EXPLICIT_VMODMAP))
- key->vmodmap = vmodmask;
+ key->vmodmap = vmodmap;
return true;
}
/* Update keymap->vmods, the virtual -> real mod mapping. */
xkb_foreach_key(key, keymap)
darray_enumerate(i, vmod, keymap->vmods)
- if (key->vmodmap & (1 << i))
+ if (key->vmodmap & (1 << (XKB_NUM_CORE_MODS + i)))
vmod->mapping |= key->modmap;
/* Now update the level masks for all the types to reflect the vmods. */
ok = ExprResolveVModMask(info->keymap, value, &mask);
if (ok) {
- keyi->vmodmap = (mask >> XKB_NUM_CORE_MODS) & 0xffff;
+ keyi->vmodmap = mask & (~0xff);
keyi->defined |= KEY_FIELD_VMODMAP;
}
else {