darray_free(keymap->key_sym_map);
}
-int
-XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
- size_t nTotalAliases)
-{
- if (!keymap)
- return BadMatch;
-
- if (!keymap->names) {
- keymap->names = calloc(1, sizeof(*keymap->names));
- if (!keymap->names)
- return BadAlloc;
-
- darray_init(keymap->names->keys);
- darray_init(keymap->names->key_aliases);
- }
-
- if ((which & XkbKTLevelNamesMask) && keymap) {
- struct xkb_key_type * type;
-
- darray_foreach(type, keymap->types) {
- if (!type->level_names) {
- type->level_names = calloc(type->num_levels,
- sizeof(*type->level_names));
- if (!type->level_names)
- return BadAlloc;
- }
- }
- }
-
- if (which & XkbKeyNamesMask)
- darray_resize0(keymap->names->keys, keymap->max_key_code + 1);
-
- if (which & XkbKeyAliasesMask)
- darray_resize0(keymap->names->key_aliases, nTotalAliases);
-
- return Success;
-}
-
static void
-XkbcFreeNames(struct xkb_keymap *keymap)
+free_names(struct xkb_keymap *keymap)
{
- struct xkb_names * names;
- struct xkb_key_type *type;
int i;
- if (!keymap || !keymap->names)
- return;
-
- names = keymap->names;
-
- darray_foreach(type, keymap->types) {
- int j;
- for (j = 0; j < type->num_levels; j++)
- free(type->level_names[j]);
- free(type->level_names);
- type->level_names = NULL;
- }
-
- free(names->keycodes);
- free(names->symbols);
- free(names->keytypes);
- free(names->compat);
-
for (i = 0; i < XkbNumVirtualMods; i++)
- free(names->vmods[i]);
+ free(keymap->vmod_names[i]);
+
for (i = 0; i < XkbNumIndicators; i++)
- free(names->indicators[i]);
+ free(keymap->indicator_names[i]);
+
for (i = 0; i < XkbNumKbdGroups; i++)
- free(names->groups[i]);
+ free(keymap->group_names[i]);
+
+ darray_free(keymap->key_names);
+ darray_free(keymap->key_aliases);
- darray_free(names->keys);
- darray_free(names->key_aliases);
- free(names);
- keymap->names = NULL;
+ free(keymap->keycodes_section_name);
+ free(keymap->symbols_section_name);
+ free(keymap->types_section_name);
+ free(keymap->compat_section_name);
}
int
free(keymap->behaviors);
free(keymap->vmodmap);
darray_free(keymap->sym_interpret);
- XkbcFreeNames(keymap);
+ free_names(keymap);
XkbcFreeControls(keymap);
xkb_context_unref(keymap->ctx);
free(keymap);
#include "xkb-priv.h"
extern int
-XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
- size_t nTotalAliases);
-
-extern int
XkbcAllocControls(struct xkb_keymap *keymap);
extern struct xkb_keymap *
int i;
for (i = 0; i < XkbNumVirtualMods; i++) {
- if (!keymap->names->vmods[i])
+ if (!keymap->vmod_names[i])
continue;
if (num_vmods == 0)
write_buf(keymap, buf, size, offset, "\t\tvirtual_modifiers ");
else
write_buf(keymap, buf, size, offset, ",");
- write_buf(keymap, buf, size, offset, "%s", keymap->names->vmods[i]);
+ write_buf(keymap, buf, size, offset, "%s", keymap->vmod_names[i]);
num_vmods++;
}
continue;
if (ret[0] != '\0') {
strcpy(ret2, ret);
- append_get_text("%s+%s", ret2, keymap->names->vmods[i]);
+ append_get_text("%s+%s", ret2, keymap->vmod_names[i]);
}
else {
- append_get_text("%s", keymap->names->vmods[i]);
+ append_get_text("%s", keymap->vmod_names[i]);
}
}
struct xkb_key_alias *alias;
int i;
- if (keymap->names->keycodes)
+ if (keymap->keycodes_section_name)
write_buf(keymap, buf, size, offset, "\txkb_keycodes \"%s\" {\n",
- keymap->names->keycodes);
+ keymap->keycodes_section_name);
else
write_buf(keymap, buf, size, offset, "\txkb_keycodes {\n");
keymap->max_key_code);
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
- if (darray_item(keymap->names->keys, key).name[0] == '\0')
+ if (darray_item(keymap->key_names, key).name[0] == '\0')
continue;
write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
- XkbcKeyNameText(darray_item(keymap->names->keys, key).name),
+ XkbcKeyNameText(darray_item(keymap->key_names, key).name),
key);
}
for (i = 0; i < XkbNumIndicators; i++) {
- if (!keymap->names->indicators[i])
+ if (!keymap->indicator_names[i])
continue;
write_buf(keymap, buf, size, offset, "\t\tindicator %d = \"%s\";\n",
- i + 1, keymap->names->indicators[i]);
+ i + 1, keymap->indicator_names[i]);
}
- darray_foreach(alias, keymap->names->key_aliases)
- write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n",
- XkbcKeyNameText(alias->alias),
- XkbcKeyNameText(alias->real));
+
+ darray_foreach(alias, keymap->key_aliases)
+ write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n",
+ XkbcKeyNameText(alias->alias),
+ XkbcKeyNameText(alias->real));
write_buf(keymap, buf, size, offset, "\t};\n\n");
return true;
int n;
struct xkb_key_type *type;
- if (keymap->names->keytypes)
+ if (keymap->types_section_name)
write_buf(keymap, buf, size, offset, "\txkb_types \"%s\" {\n\n",
- keymap->names->keytypes);
+ keymap->types_section_name);
else
write_buf(keymap, buf, size, offset, "\txkb_types {\n\n");
struct xkb_indicator_map *led = &keymap->indicators[num];
write_buf(keymap, buf, size, offset, "\t\tindicator \"%s\" {\n",
- keymap->names->indicators[num]);
+ keymap->indicator_names[num]);
if (led->which_groups) {
if (led->which_groups != XkbIM_UseEffective) {
int i;
struct xkb_sym_interpret *interp;
- if (keymap->names->compat)
+ if (keymap->compat_section_name)
write_buf(keymap, buf, size, offset,
"\txkb_compatibility \"%s\" {\n\n",
- keymap->names->compat);
+ keymap->compat_section_name);
else
write_buf(keymap, buf, size, offset, "\txkb_compatibility {\n\n");
if (interp->virtual_mod != XkbNoModifier) {
write_buf(keymap, buf, size, offset,
"\t\t\tvirtualModifier= %s;\n",
- keymap->names->vmods[interp->virtual_mod]);
+ keymap->vmod_names[interp->virtual_mod]);
}
if (interp->match & XkbSI_LevelOneOnly)
int group, tmp;
bool showActions;
- if (keymap->names->symbols)
+ if (keymap->symbols_section_name)
write_buf(keymap, buf, size, offset, "\txkb_symbols \"%s\" {\n\n",
- keymap->names->symbols);
+ keymap->symbols_section_name);
else
write_buf(keymap, buf, size, offset, "\txkb_symbols {\n\n");
for (tmp = group = 0; group < XkbNumKbdGroups; group++) {
- if (!keymap->names->groups[group])
+ if (!keymap->group_names[group])
continue;
write_buf(keymap, buf, size, offset,
"\t\tname[group%d]=\"%s\";\n", group + 1,
- keymap->names->groups[group]);
+ keymap->group_names[group]);
tmp++;
}
if (tmp > 0)
continue;
write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
- XkbcKeyNameText(darray_item(keymap->names->keys, key).name));
+ XkbcKeyNameText(darray_item(keymap->key_names, key).name));
if (keymap->explicit) {
if ((keymap->explicit[key] & XkbExplicitKeyTypesMask)) {
bool multi_type = false;
write_buf(keymap, buf, size, offset,
"\t\tmodifier_map %s { %s };\n",
get_mod_index_text(mod),
- XkbcKeyNameText(darray_item(keymap->names->keys,
+ XkbcKeyNameText(darray_item(keymap->key_names,
key).name));
}
}
xkb_mod_index_t i;
for (i = 0; i < XkbNumVirtualMods; i++)
- if (!keymap->names->vmods[i])
+ if (!keymap->vmod_names[i])
break;
/* We always have all the core modifiers (for now), plus any virtual
}
/* If that fails, try to find a virtual mod name. */
- return keymap->names->vmods[idx - Mod5MapIndex];
+ return keymap->vmod_names[idx - Mod5MapIndex];
}
/**
if (strcasecmp(name, "Mod5") == 0)
return Mod5MapIndex;
- for (i = 0; i < XkbNumVirtualMods && keymap->names->vmods[i]; i++) {
- if (strcasecmp(name, keymap->names->vmods[i]) == 0)
+ for (i = 0; i < XkbNumVirtualMods && keymap->vmod_names[i]; i++) {
+ if (strcasecmp(name, keymap->vmod_names[i]) == 0)
return i + Mod5MapIndex;
}
if (idx >= xkb_map_num_groups(keymap))
return NULL;
- return keymap->names->groups[idx];
+ return keymap->group_names[idx];
}
/**
xkb_group_index_t i;
for (i = 0; i < num_groups; i++) {
- if (strcasecmp(keymap->names->groups[i], name) == 0)
+ if (strcasecmp(keymap->group_names[i], name) == 0)
return i;
}
if (idx >= xkb_map_num_leds(keymap))
return NULL;
- return keymap->names->indicators[idx];
+ return keymap->indicator_names[idx];
}
/**
xkb_led_index_t i;
for (i = 0; i < num_leds; i++) {
- if (strcasecmp(keymap->names->indicators[i], name) == 0)
+ if (strcasecmp(keymap->indicator_names[i], name) == 0)
return i;
}
char buf[20];
if (ndx >= XkbNumVirtualMods)
- tmp = "illegal";
- else if (keymap && keymap->names)
- tmp = keymap->names->vmods[ndx];
+ tmp = "illegal";
+ else
+ tmp = keymap->vmod_names[ndx];
if (!tmp) {
snprintf(buf, sizeof(buf) - 1, "%d", ndx);
char alias[XkbKeyNameLength];
};
-struct xkb_names {
- char *keycodes;
- char *symbols;
- char *keytypes;
- char *compat;
-
- char *vmods[XkbNumVirtualMods];
- char *indicators[XkbNumIndicators];
- char *groups[XkbNumKbdGroups];
-
- darray(struct xkb_key_name) keys;
- darray(struct xkb_key_alias) key_aliases;
-};
-
struct xkb_controls {
/* unsigned char groups_wrap; */
/* struct xkb_mods internal; */
xkb_keycode_t max_key_code;
struct xkb_controls * ctrls;
- struct xkb_names * names;
+
+ /* key -> key name mapping */
+ darray(struct xkb_key_name) key_names;
+ /* aliases in no particular order */
+ darray(struct xkb_key_alias) key_aliases;
/* key -> explicit flags mapping */
unsigned char *explicit;
/* key -> mod mapping */
unsigned char *modmap;
- /* vmod -> mod mapping */
- uint32_t vmods[XkbNumVirtualMods];
/* key -> vmod mapping */
uint32_t *vmodmap;
+ /* vmod -> mod mapping */
+ uint32_t vmods[XkbNumVirtualMods];
+ char *vmod_names[XkbNumVirtualMods];
struct xkb_mods groups[XkbNumKbdGroups];
+ char *group_names[XkbNumKbdGroups];
/* key -> actions mapping: acts[key_acts[keycode]] */
darray(union xkb_action) acts;
struct xkb_behavior *behaviors;
struct xkb_indicator_map indicators[XkbNumIndicators];
+ char *indicator_names[XkbNumIndicators];
+
+ char *keycodes_section_name;
+ char *symbols_section_name;
+ char *types_section_name;
+ char *compat_section_name;
};
#define XkbNumGroups(g) ((g) & 0x0f)
struct xkb_key_alias *old, *a;
AliasInfo *info;
int nNew, nOld;
- int status;
if (*info_in == NULL)
return true;
- nOld = (keymap->names ? darray_size(keymap->names->key_aliases) : 0);
- old = (keymap->names ? &darray_item(keymap->names->key_aliases, 0) : NULL);
+ nOld = (keymap ? darray_size(keymap->key_aliases) : 0);
+ old = (keymap ? &darray_item(keymap->key_aliases, 0) : NULL);
for (nNew = 0, info = *info_in; info != NULL;
info = (AliasInfo *) info->def.next) {
unsigned long lname;
return true;
}
- status = XkbcAllocNames(keymap, XkbKeyAliasesMask, nOld + nNew);
- if (status != Success) {
- WSGO("Allocation failure in ApplyAliases\n");
- return false;
- }
- a = keymap->names ? &darray_item(keymap->names->key_aliases, nOld) : NULL;
- for (info = *info_in; info != NULL; info =
- (AliasInfo *) info->def.next) {
+ darray_resize0(keymap->key_aliases, nOld + nNew);
+
+ a = keymap ? &darray_item(keymap->key_aliases, nOld) : NULL;
+ for (info = *info_in; info != NULL; info = (AliasInfo *) info->def.next) {
if (info->alias[0] != '\0') {
strncpy(a->alias, info->alias, XkbKeyNameLength);
strncpy(a->real, info->real, XkbKeyNameLength);
darray_init(keymap->sym_interpret);
darray_growalloc(keymap->sym_interpret, info.nInterps);
- if (info.name) {
- if (XkbcAllocNames(keymap, 0, 0) != Success)
- goto err_info;
- keymap->names->compat = strdup(info.name);
- }
+ if (info.name)
+ keymap->compat_section_name = strdup(info.name);
if (info.nInterps > 0) {
CopyInterps(&info, keymap, true, XkbSI_Exactly);
int i;
LEDInfo *led, *next, *last;
- if (keymap->names != NULL) {
- for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
- if (led->indicator == _LED_NotBound) {
- for (i = 0; i < XkbNumIndicators; i++) {
- if (keymap->names->indicators[i] &&
- strcmp(keymap->names->indicators[i],
- xkb_atom_text(keymap->ctx, led->name)) == 0) {
- led->indicator = i + 1;
- break;
- }
+ for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
+ if (led->indicator == _LED_NotBound) {
+ for (i = 0; i < XkbNumIndicators; i++) {
+ if (keymap->indicator_names[i] &&
+ strcmp(keymap->indicator_names[i],
+ xkb_atom_text(keymap->ctx, led->name)) == 0) {
+ led->indicator = i + 1;
+ break;
}
}
}
- for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
- if (led->indicator == _LED_NotBound) {
- for (i = 0; i < XkbNumIndicators; i++) {
- if (keymap->names->indicators[i] == NULL) {
- keymap->names->indicators[i] =
- xkb_atom_strdup(keymap->ctx, led->name);
- led->indicator = i + 1;
- break;
- }
- }
- if (led->indicator == _LED_NotBound) {
- ERROR("No unnamed indicators found\n");
- ACTION
- ("Virtual indicator map \"%s\" not bound\n",
- xkb_atom_text(keymap->ctx, led->name));
- continue;
+ }
+
+ for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
+ if (led->indicator == _LED_NotBound) {
+ for (i = 0; i < XkbNumIndicators; i++) {
+ if (keymap->indicator_names[i] == NULL) {
+ keymap->indicator_names[i] =
+ xkb_atom_strdup(keymap->ctx, led->name);
+ led->indicator = i + 1;
+ break;
}
}
+ if (led->indicator == _LED_NotBound) {
+ ERROR("No unnamed indicators found\n");
+ ACTION("Virtual indicator map \"%s\" not bound\n",
+ xkb_atom_text(keymap->ctx, led->name));
+ continue;
+ }
}
}
for (last = NULL, led = unbound; led != NULL; led = next) {
free(led);
}
else {
- if ((keymap->names != NULL) &&
- (strcmp(keymap->names->indicators[led->indicator - 1],
- xkb_atom_text(keymap->ctx, led->name)) != 0)) {
- const char *old =
- keymap->names->indicators[led->indicator - 1];
+ if (strcmp(keymap->indicator_names[led->indicator - 1],
+ xkb_atom_text(keymap->ctx, led->name)) != 0) {
+ const char *old = keymap->indicator_names[led->indicator - 1];
ERROR("Multiple names bound to indicator %d\n",
(unsigned int) led->indicator);
ACTION("Using %s, ignoring %s\n", old,
LEDInfo *led, *next;
LEDInfo *unbound = NULL, *last = NULL;
- if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success) {
- WSGO("Couldn't allocate names\n");
- ACTION("Indicator names may be incorrect\n");
- }
-
for (led = leds; led != NULL; led = next) {
next = (LEDInfo *) led->defs.next;
if ((led->groups != 0) && (led->which_groups == 0))
im->mods.real_mods = led->real_mods;
im->mods.vmods = led->vmods;
im->ctrls = led->ctrls;
- if (keymap->names != NULL) {
- free(keymap->names->indicators[led->indicator - 1]);
- keymap->names->indicators[led->indicator - 1] =
- xkb_atom_strdup(keymap->ctx, led->name);
- }
+ free(keymap->indicator_names[led->indicator - 1]);
+ keymap->indicator_names[led->indicator - 1] =
+ xkb_atom_strdup(keymap->ctx, led->name);
free(led);
}
}
CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge)
{
+ xkb_keycode_t i;
KeyNamesInfo info; /* contains all the info after parsing */
InitKeyNamesInfo(&info, file->id);
else
keymap->max_key_code = info.computedMax;
- if (XkbcAllocNames(keymap, XkbKeyNamesMask | XkbIndicatorNamesMask, 0)
- == Success) {
- uint64_t i;
- for (i = info.computedMin; i <= info.computedMax; i++)
- LongToKeyName(darray_item(info.names, i),
- darray_item(keymap->names->keys, i).name);
- if (info.name)
- keymap->names->keycodes = strdup(info.name);
- }
- else {
- WSGO("Cannot create struct xkb_names in CompileKeycodes\n");
- goto err_info;
- }
+ darray_resize0(keymap->key_names, keymap->max_key_code + 1);
+ for (i = info.computedMin; i <= info.computedMax; i++)
+ LongToKeyName(darray_item(info.names, i),
+ darray_item(keymap->key_names, i).name);
+
+ if (info.name)
+ keymap->keycodes_section_name = strdup(info.name);
if (info.leds) {
IndicatorNameInfo *ii;
for (ii = info.leds; ii; ii = (IndicatorNameInfo *) ii->defs.next) {
- free(keymap->names->indicators[ii->ndx - 1]);
- keymap->names->indicators[ii->ndx - 1] =
+ free(keymap->indicator_names[ii->ndx - 1]);
+ keymap->indicator_names[ii->ndx - 1] =
xkb_atom_strdup(keymap->ctx, ii->name);
}
}
if (info.errorCount != 0)
goto err_info;
- if (info.name) {
- if (XkbcAllocNames(keymap, 0, 0) != Success)
- goto err_info;
- keymap->names->keytypes = strdup(info.name);
- }
+ if (info.name)
+ keymap->types_section_name = strdup(info.name);
i = info.nTypes;
if ((info.stdPresent & XkbOneLevelMask) == 0)
{
unsigned n;
- if (start_from < keymap->min_key_code) {
+ if (start_from < keymap->min_key_code)
start_from = keymap->min_key_code;
- }
- else if (start_from > keymap->max_key_code) {
+ else if (start_from > keymap->max_key_code)
return false;
- }
*kc_rtrn = 0; /* some callers rely on this */
- if (keymap && keymap->names && !darray_empty(keymap->names->keys)) {
+
+ if (!darray_empty(keymap->key_names)) {
for (n = start_from; n <= keymap->max_key_code; n++) {
unsigned long tmp;
- tmp = KeyNameToLong(darray_item(keymap->names->keys, n).name);
+ tmp = KeyNameToLong(darray_item(keymap->key_names, n).name);
if (tmp == name) {
*kc_rtrn = n;
return true;
create, 0);
}
}
+
if (create) {
- if ((!keymap->names) || darray_empty(keymap->names->keys)) {
- if (XkbcAllocNames(keymap, XkbKeyNamesMask, 0) != Success) {
- if (warningLevel > 0) {
- WARN("Couldn't allocate key names in FindNamedKey\n");
- ACTION("Key \"%s\" not automatically created\n",
- longText(name));
- }
- return false;
- }
- }
+ darray_resize0(keymap->key_names, keymap->max_key_code + 1);
+
/* Find first unused keycode and store our key here */
for (n = keymap->min_key_code; n <= keymap->max_key_code; n++) {
- if (darray_item(keymap->names->keys, n).name[0] == '\0') {
+ if (darray_item(keymap->key_names, n).name[0] == '\0') {
char buf[XkbKeyNameLength + 1];
LongToKeyName(name, buf);
- memcpy(darray_item(keymap->names->keys, n).name, buf,
+ memcpy(darray_item(keymap->key_names, n).name, buf,
XkbKeyNameLength);
*kc_rtrn = n;
return true;
char name[XkbKeyNameLength + 1];
struct xkb_key_alias *a;
- if (keymap && keymap->names) {
- LongToKeyName(lname, name);
- name[XkbKeyNameLength] = '\0';
- darray_foreach(a, keymap->names->key_aliases) {
- if (strncmp(name, a->alias, XkbKeyNameLength) == 0) {
- *real_name = KeyNameToLong(a->real);
- return true;
- }
+ LongToKeyName(lname, name);
+ name[XkbKeyNameLength] = '\0';
+ darray_foreach(a, keymap->key_aliases) {
+ if (strncmp(name, a->alias, XkbKeyNameLength) == 0) {
+ *real_name = KeyNameToLong(a->real);
+ return true;
}
}
+
return false;
}
if (info.errorCount != 0)
goto err_info;
- /* alloc memory in the xkb struct */
- if (XkbcAllocNames(keymap, XkbGroupNamesMask, 0) != Success) {
- WSGO("Can not allocate names in CompileSymbols\n");
- ACTION("Symbols not added\n");
- goto err_info;
- }
-
darray_resize0(keymap->key_sym_map, keymap->max_key_code + 1);
keymap->modmap = calloc(keymap->max_key_code + 1,
sizeof(*keymap->modmap));
}
if (info.name)
- keymap->names->symbols = strdup(info.name);
+ keymap->symbols_section_name = strdup(info.name);
/* now copy info into xkb. */
ApplyAliases(keymap, &info.aliases);
for (i = 0; i < XkbNumKbdGroups; i++) {
if (info.groupNames[i] != XKB_ATOM_NONE) {
- free(keymap->names->groups[i]);
- keymap->names->groups[i] = xkb_atom_strdup(keymap->ctx,
- info.groupNames[i]);
+ free(keymap->group_names[i]);
+ keymap->group_names[i] = xkb_atom_strdup(keymap->ctx,
+ info.groupNames[i]);
}
}
if (warningLevel > 3) {
for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) {
- if (darray_item(keymap->names->keys, i).name[0] == '\0')
+ if (darray_item(keymap->key_names, i).name[0] == '\0')
continue;
if (XkbKeyNumGroups(keymap, i) < 1) {
char buf[5];
- memcpy(buf, darray_item(keymap->names->keys, i).name, 4);
+ memcpy(buf, darray_item(keymap->key_names, i).name, 4);
buf[4] = '\0';
WARN("No symbols defined for <%s> (keycode %d)\n", buf, i);
}
void
ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
{
- int i;
+ int i, bit;
info->newlyDefined = info->defined = info->available = 0;
- if (XkbcAllocNames(keymap, 0, 0) != Success)
- return;
-
for (i = 0; i < XkbNumVirtualMods; i++)
keymap->vmods[i] = XkbNoModifierMask;
info->keymap = keymap;
- if (keymap && keymap->names) {
- int bit;
- for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
- if (keymap->names->vmods[i] != NULL)
- info->defined |= bit;
- }
- }
+ for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
+ if (keymap->vmod_names[i])
+ info->defined |= bit;
}
/***====================================================================***/
{
int i, bit, nextFree;
ExprResult mod;
- struct xkb_names *names = keymap->names;
for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<=
1) {
if (info->defined & bit) {
- if (names->vmods[i] &&
- strcmp(names->vmods[i],
+ if (keymap->vmod_names[i] &&
+ strcmp(keymap->vmod_names[i],
xkb_atom_text(keymap->ctx, stmt->name)) == 0) { /* already defined */
info->available |= bit;
if (stmt->value == NULL)
info->defined |= (1 << nextFree);
info->newlyDefined |= (1 << nextFree);
info->available |= (1 << nextFree);
- names->vmods[nextFree] = xkb_atom_strdup(keymap->ctx, stmt->name);
+ keymap->vmod_names[nextFree] = xkb_atom_strdup(keymap->ctx, stmt->name);
if (stmt->value == NULL)
return true;
if (ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
}
/**
- * Returns the index of the given modifier in the keymap->names->vmods array.
+ * Returns the index of the given modifier in the keymap->vmod_names array.
*
* @param keymap Pointer to the xkb data structure.
* @param field The Atom of the modifier's name (e.g. Atom for LAlt)
int i;
const char *name = xkb_atom_text(keymap->ctx, field);
- if ((keymap == NULL) || (keymap->names == NULL) || (type != TypeInt)) {
+ if (type != TypeInt)
return false;
- }
+
/* For each named modifier, get the name and compare it to the one passed
* in. If we get a match, return the index of the modifier.
* The order of modifiers is the same as in the virtual_modifiers line in
* the xkb_types section.
*/
- for (i = 0; i < XkbNumVirtualMods; i++) {
- if (keymap->names->vmods[i] &&
- strcmp(keymap->names->vmods[i], name) == 0) {
+ for (i = 0; i < XkbNumVirtualMods; i++)
+ if (keymap->vmod_names[i] &&
+ strcmp(keymap->vmod_names[i], name) == 0) {
val_rtrn->uval = i;
return true;
}
- }
+
return false;
}
ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
ExprResult *val_rtrn, VModInfo *info)
{
- struct xkb_names *names = keymap->names;
-
if (def->op == ExprIdent) {
int i, bit;
const char *name = xkb_atom_text(keymap->ctx, def->value.str);
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
- if ((info->available & bit) && names->vmods[i] &&
- strcmp(names->vmods[i], name) == 0) {
+ if ((info->available & bit) && keymap->vmod_names[i] &&
+ strcmp(keymap->vmod_names[i], name) == 0) {
val_rtrn->uval = i;
return true;
}