}
int
-XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI)
-{
- if (!keymap)
- return BadMatch;
-
- if (!keymap->compat) {
- keymap->compat = calloc(1, sizeof(*keymap->compat));
- if (!keymap->compat)
- return BadAlloc;
- darray_init(keymap->compat->sym_interpret);
- }
-
- darray_growalloc(keymap->compat->sym_interpret, nSI);
- darray_resize(keymap->compat->sym_interpret, 0);
-
- memset(keymap->compat->groups, 0,
- XkbNumKbdGroups * sizeof(*keymap->compat->groups));
-
- return Success;
-}
-
-static void
-XkbcFreeCompatMap(struct xkb_keymap *keymap)
-{
- if (!keymap || !keymap->compat)
- return;
-
- darray_free(keymap->compat->sym_interpret);
- free(keymap->compat);
- keymap->compat = NULL;
-}
-
-int
XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
size_t nTotalAliases)
{
darray_free(keymap->acts);
free(keymap->behaviors);
free(keymap->vmodmap);
- XkbcFreeCompatMap(keymap);
+ darray_free(keymap->sym_interpret);
XkbcFreeIndicatorMaps(keymap);
XkbcFreeNames(keymap);
XkbcFreeControls(keymap);
write_buf(keymap, buf, size, offset, "\t\tinterpret.repeat= False;\n");
write_buf(keymap, buf, size, offset, "\t\tinterpret.locking= False;\n");
- darray_foreach(interp, keymap->compat->sym_interpret) {
+ darray_foreach(interp, keymap->sym_interpret) {
char keysym_name[64];
if (interp->sym == XKB_KEY_NoSymbol)
for (i = 0; i < XkbNumKbdGroups; i++) {
struct xkb_mods *gc;
- gc = &keymap->compat->groups[i];
+ gc = &keymap->groups[i];
if (gc->real_mods == 0 && gc->vmods == 0)
continue;
write_buf(keymap, buf, size, offset,
union xkb_action act;
};
-struct xkb_compat_map {
- darray(struct xkb_sym_interpret) sym_interpret;
- struct xkb_mods groups[XkbNumKbdGroups];
-};
-
struct xkb_sym_map {
unsigned char kt_index[XkbNumKbdGroups];
unsigned char group_info;
struct xkb_controls * ctrls;
struct xkb_indicator * indicators;
struct xkb_names * names;
- struct xkb_compat_map * compat;
/* key -> explicit flags mapping */
unsigned char *explicit;
darray(struct xkb_key_type) types;
+ /* key -> symbols mapping */
darray(struct xkb_sym_map) key_sym_map;
+ darray(struct xkb_sym_interpret) sym_interpret;
+
/* key -> mod mapping */
unsigned char *modmap;
/* vmod -> mod mapping */
/* key -> vmod mapping */
uint32_t *vmodmap;
- /* acts[key_acts[keycode]] */
+ struct xkb_mods groups[XkbNumKbdGroups];
+
+ /* key -> actions mapping: acts[key_acts[keycode]] */
darray(union xkb_action) acts;
- darray(size_t ) key_acts;
+ darray(size_t) key_acts;
+ /* key -> behavior mapping */
struct xkb_behavior *behaviors;
};
}
static void
-CopyInterps(CompatInfo * info,
- struct xkb_compat_map * compat, bool needSymbol, unsigned pred)
+CopyInterps(CompatInfo *info, struct xkb_keymap *keymap,
+ bool needSymbol, unsigned pred)
{
SymInterpInfo *si;
(needSymbol && (si->interp.sym == XKB_KEY_NoSymbol)) ||
((!needSymbol) && (si->interp.sym != XKB_KEY_NoSymbol)))
continue;
- darray_append(compat->sym_interpret, si->interp);
+ darray_append(keymap->sym_interpret, si->interp);
}
}
if (info.errorCount != 0)
goto err_info;
- if (XkbcAllocCompatMap(keymap, info.nInterps) != Success) {
- WSGO("Couldn't allocate compatibility map\n");
- goto err_info;
- }
+ darray_init(keymap->sym_interpret);
+ darray_growalloc(keymap->sym_interpret, info.nInterps);
if (info.name) {
if (XkbcAllocNames(keymap, 0, 0) != Success)
}
if (info.nInterps > 0) {
- CopyInterps(&info, keymap->compat, true, XkbSI_Exactly);
- CopyInterps(&info, keymap->compat, true, XkbSI_AllOf | XkbSI_NoneOf);
- CopyInterps(&info, keymap->compat, true, XkbSI_AnyOf);
- CopyInterps(&info, keymap->compat, true, XkbSI_AnyOfOrNone);
- CopyInterps(&info, keymap->compat, false, XkbSI_Exactly);
- CopyInterps(&info, keymap->compat, false, XkbSI_AllOf | XkbSI_NoneOf);
- CopyInterps(&info, keymap->compat, false, XkbSI_AnyOf);
- CopyInterps(&info, keymap->compat, false, XkbSI_AnyOfOrNone);
+ CopyInterps(&info, keymap, true, XkbSI_Exactly);
+ CopyInterps(&info, keymap, true, XkbSI_AllOf | XkbSI_NoneOf);
+ CopyInterps(&info, keymap, true, XkbSI_AnyOf);
+ CopyInterps(&info, keymap, true, XkbSI_AnyOfOrNone);
+ CopyInterps(&info, keymap, false, XkbSI_Exactly);
+ CopyInterps(&info, keymap, false, XkbSI_AllOf | XkbSI_NoneOf);
+ CopyInterps(&info, keymap, false, XkbSI_AnyOf);
+ CopyInterps(&info, keymap, false, XkbSI_AnyOfOrNone);
}
- for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++,
- gcm++) {
- if ((gcm->file_id != 0) || (gcm->real_mods != 0) ||
- (gcm->vmods != 0)) {
- keymap->compat->groups[i].mask = gcm->real_mods;
- keymap->compat->groups[i].real_mods = gcm->real_mods;
- keymap->compat->groups[i].vmods = gcm->vmods;
+ for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups;
+ i++, gcm++) {
+ if (gcm->file_id != 0 || gcm->real_mods != 0 || gcm->vmods != 0) {
+ keymap->groups[i].mask = gcm->real_mods;
+ keymap->groups[i].real_mods = gcm->real_mods;
+ keymap->groups[i].vmods = gcm->vmods;
}
}
if (num_syms == 0)
return NULL;
- darray_foreach(interp, keymap->compat->sym_interpret) {
+ darray_foreach(interp, keymap->sym_interpret) {
uint32_t mods;
bool found;
/* Update group modifiers. */
for (i = 0; i < XkbNumKbdGroups; i++) {
- struct xkb_mods *group = &keymap->compat->groups[i];
+ struct xkb_mods *group = &keymap->groups[i];
group->mask = group->real_mods | VModsToReal(keymap, group->vmods);
}