write_buf(buf, "\t\tvirtual_modifiers ");
else
write_buf(buf, ",");
- write_buf(buf, "%s", keymap->vmod_names[i]);
+ write_buf(buf, "%s",
+ xkb_atom_text(keymap->ctx, keymap->vmod_names[i]));
num_vmods++;
}
for (i = 0; i < XkbNumIndicators; i++) {
if (!keymap->indicator_names[i])
continue;
- write_buf(buf, "\t\tindicator %d = \"%s\";\n",
- i + 1, keymap->indicator_names[i]);
+ write_buf(buf, "\t\tindicator %d = \"%s\";\n", i + 1,
+ xkb_atom_text(keymap->ctx, keymap->indicator_names[i]));
}
struct xkb_indicator_map *led = &keymap->indicators[num];
write_buf(buf, "\t\tindicator \"%s\" {\n",
- keymap->indicator_names[num]);
+ xkb_atom_text(keymap->ctx, keymap->indicator_names[num]));
if (led->which_groups) {
if (led->which_groups != XkbIM_UseEffective) {
if (interp->virtual_mod != XKB_MOD_INVALID) {
write_buf(buf, "\t\t\tvirtualModifier= %s;\n",
- keymap->vmod_names[interp->virtual_mod]);
+ xkb_atom_text(keymap->ctx,
+ keymap->vmod_names[interp->virtual_mod]));
}
if (interp->match & XkbSI_LevelOneOnly)
continue;
write_buf(buf,
"\t\tname[group%d]=\"%s\";\n", group + 1,
- keymap->group_names[group]);
+ xkb_atom_text(keymap->ctx, keymap->group_names[group]));
tmp++;
}
if (tmp > 0)
* find a virtual mod name. */
name = ModIndexToName(idx);
if (!name)
- name = keymap->vmod_names[idx - XkbNumModifiers];
+ name = xkb_atom_text(keymap->ctx,
+ keymap->vmod_names[idx - XkbNumModifiers]);
return name;
}
xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_mod_index_t i;
+ xkb_atom_t atom;
i = ModNameToIndex(name);
if (i != XKB_MOD_INVALID)
return i;
- for (i = 0; i < XkbNumVirtualMods && keymap->vmod_names[i]; i++) {
- if (istreq(name, keymap->vmod_names[i]))
+ atom = xkb_atom_lookup(keymap->ctx, name);
+ if (atom == XKB_ATOM_NONE)
+ return XKB_MOD_INVALID;
+
+ for (i = 0; i < XkbNumVirtualMods; i++) {
+ if (keymap->vmod_names[i] == XKB_ATOM_NONE)
+ break;
+ if (keymap->vmod_names[i] == atom)
return i + XkbNumModifiers;
}
if (idx >= xkb_map_num_groups(keymap))
return NULL;
- return keymap->group_names[idx];
+ return xkb_atom_text(keymap->ctx, keymap->group_names[idx]);
}
/**
xkb_map_group_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_group_index_t num_groups = xkb_map_num_groups(keymap);
+ xkb_atom_t atom = xkb_atom_lookup(keymap->ctx, name);
xkb_group_index_t i;
+ if (atom == XKB_ATOM_NONE)
+ return XKB_GROUP_INVALID;
+
for (i = 0; i < num_groups; i++)
- if (istreq(keymap->group_names[i], name))
+ if (keymap->group_names[i] == atom)
return i;
return XKB_GROUP_INVALID;
if (idx >= xkb_map_num_leds(keymap))
return NULL;
- return keymap->indicator_names[idx];
+ return xkb_atom_text(keymap->ctx, keymap->indicator_names[idx]);
}
/**
xkb_map_led_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_led_index_t num_leds = xkb_map_num_leds(keymap);
+ xkb_atom_t atom = xkb_atom_lookup(keymap->ctx, name);
xkb_led_index_t i;
+ if (atom == XKB_ATOM_NONE)
+ return XKB_LED_INVALID;
+
for (i = 0; i < num_leds; i++)
- if (istreq(keymap->indicator_names[i], name))
+ if (keymap->indicator_names[i] == atom)
return i;
return XKB_LED_INVALID;
if (ndx >= XkbNumVirtualMods)
tmp = "illegal";
else
- tmp = keymap->vmod_names[ndx];
+ tmp = xkb_atom_text(keymap->ctx, keymap->vmod_names[ndx]);
if (!tmp) {
snprintf(buf, sizeof(buf) - 1, "%d", ndx);
/* vmod -> mod mapping */
xkb_mod_mask_t vmods[XkbNumVirtualMods];
- const char *vmod_names[XkbNumVirtualMods];
+ xkb_atom_t vmod_names[XkbNumVirtualMods];
/* Number of groups in the key with the most groups. */
xkb_group_index_t num_groups;
- const char *group_names[XkbNumKbdGroups];
+ xkb_atom_t group_names[XkbNumKbdGroups];
struct xkb_indicator_map indicators[XkbNumIndicators];
- const char *indicator_names[XkbNumIndicators];
+ xkb_atom_t indicator_names[XkbNumIndicators];
char *keycodes_section_name;
char *symbols_section_name;
struct xkb_keymap *keymap = info->keymap;
darray_foreach(led, info->leds) {
- const char *name = xkb_atom_text(keymap->ctx, led->name);
-
/*
* Find the indicator with the given name, if it was already
* declared in keycodes.
*/
im = NULL;
for (i = 0; i < XkbNumIndicators; i++) {
- if (streq_not_null(keymap->indicator_names[i], name)) {
+ if (keymap->indicator_names[i] == led->name) {
im = &keymap->indicators[i];
break;
}
if (!im) {
log_dbg(keymap->ctx,
"Indicator name \"%s\" was not declared in the keycodes section; "
- "Adding new indicator\n", name);
+ "Adding new indicator\n",
+ xkb_atom_text(keymap->ctx, led->name));
for (i = 0; i < XkbNumIndicators; i++) {
- if (keymap->indicator_names[i])
+ if (keymap->indicator_names[i] != XKB_ATOM_NONE)
continue;
- keymap->indicator_names[i] = name;
+ keymap->indicator_names[i] = led->name;
im = &keymap->indicators[i];
break;
}
log_err(keymap->ctx,
"Too many indicators (maximum is %d); "
"Indicator name \"%s\" ignored\n",
- XkbNumIndicators, name);
+ XkbNumIndicators,
+ xkb_atom_text(keymap->ctx, led->name));
continue;
}
}
if (led->name == XKB_ATOM_NONE)
continue;
- keymap->indicator_names[idx] =
- xkb_atom_text(keymap->ctx, led->name);
+ keymap->indicator_names[idx] = led->name;
}
ApplyAliases(info, keymap);
if (info.name)
keymap->symbols_section_name = strdup(info.name);
- for (i = 0; i < XkbNumKbdGroups; i++) {
- if (info.groupNames[i] != XKB_ATOM_NONE) {
- keymap->group_names[i] = xkb_atom_text(keymap->ctx,
- info.groupNames[i]);
- }
- }
+ for (i = 0; i < XkbNumKbdGroups; i++)
+ if (info.groupNames[i] != XKB_ATOM_NONE)
+ keymap->group_names[i] = info.groupNames[i];
/* sanitize keys */
darray_foreach(keyi, info.keys)
if (!keymap->vmod_names[i])
continue;
- if (!streq(keymap->vmod_names[i],
- xkb_atom_text(keymap->ctx, stmt->name)))
+ if (keymap->vmod_names[i] != stmt->name)
continue;
info->available |= bit;
info->defined |= (1 << nextFree);
info->available |= (1 << nextFree);
- keymap->vmod_names[nextFree] = xkb_atom_text(keymap->ctx, stmt->name);
+ keymap->vmod_names[nextFree] = stmt->name;
return true;
}
enum expr_value_type type, xkb_mod_index_t *val_rtrn)
{
xkb_mod_index_t i;
- const char *name = xkb_atom_text(keymap->ctx, field);
if (type != EXPR_TYPE_INT)
return false;
for (i = 0; i < XkbNumVirtualMods; i++) {
- if (keymap->vmod_names[i] && streq(keymap->vmod_names[i], name)) {
+ if (keymap->vmod_names[i] == field) {
*val_rtrn = i;
return true;
}
xkb_mod_index_t *ndx_rtrn, VModInfo *info)
{
xkb_mod_index_t i;
- const char *name;
+ xkb_atom_t name = def->value.str;
if (def->op != EXPR_IDENT) {
log_err(keymap->ctx,
return false;
}
- name = xkb_atom_text(keymap->ctx, def->value.str);
-
for (i = 0; i < XkbNumVirtualMods; i++) {
- if ((info->available & (1 << i)) &&
- streq_not_null(keymap->vmod_names[i], name)) {
+ if ((info->available & (1 << i)) && keymap->vmod_names[i] == name) {
*ndx_rtrn = i;
return true;
}
log_err(keymap->ctx,
"Cannot resolve virtual modifier: "
- "\"%s\" was not previously declared\n", name);
+ "\"%s\" was not previously declared\n",
+ xkb_atom_text(keymap->ctx, name));
return false;
}