* Add predefined (AKA real, core, X11) modifiers.
* The order is important!
*/
- darray_append_items(keymap->mods, builtin_mods, ARRAY_SIZE(builtin_mods));
+ darray_append_items(keymap->mods.mods,
+ builtin_mods, ARRAY_SIZE(builtin_mods));
}
struct xkb_keymap *
xkb_mod_index_t i;
const struct xkb_mod *mod;
- darray_enumerate(i, mod, keymap->mods)
+ darray_enumerate(i, mod, keymap->mods.mods)
if ((mod->type & type) && name == mod->name)
return i;
free(keymap->sym_interprets);
free(keymap->key_aliases);
free(keymap->group_names);
- darray_free(keymap->mods);
+ darray_free(keymap->mods.mods);
darray_free(keymap->leds);
free(keymap->keycodes_section_name);
free(keymap->symbols_section_name);
XKB_EXPORT xkb_mod_index_t
xkb_keymap_num_mods(struct xkb_keymap *keymap)
{
- return darray_size(keymap->mods);
+ return darray_size(keymap->mods.mods);
}
/**
XKB_EXPORT const char *
xkb_keymap_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx)
{
- if (idx >= darray_size(keymap->mods))
+ if (idx >= darray_size(keymap->mods.mods))
return NULL;
- return xkb_atom_text(keymap->ctx, darray_item(keymap->mods, idx).name);
+ return xkb_atom_text(keymap->ctx,
+ darray_item(keymap->mods.mods, idx).name);
}
/**
xkb_mod_mask_t mapping; /* vmod -> real mod mapping */
};
+struct xkb_mod_set {
+ darray(struct xkb_mod) mods;
+};
+
/* Common keyboard description structure */
struct xkb_keymap {
struct xkb_context *ctx;
unsigned int num_sym_interprets;
struct xkb_sym_interpret *sym_interprets;
- darray(struct xkb_mod) mods;
+ struct xkb_mod_set mods;
/* Number of groups in the key with the most groups. */
xkb_layout_index_t num_groups;
if (ndx == XKB_MOD_INVALID)
return "none";
- if (ndx >= darray_size(keymap->mods))
+ if (ndx >= darray_size(keymap->mods.mods))
return NULL;
- return xkb_atom_text(keymap->ctx, darray_item(keymap->mods, ndx).name);
+ return xkb_atom_text(keymap->ctx,
+ darray_item(keymap->mods.mods, ndx).name);
}
const char *
if (mask == MOD_REAL_MASK_ALL)
return "all";
- darray_enumerate(i, mod, keymap->mods) {
+ darray_enumerate(i, mod, keymap->mods.mods) {
int ret;
if (!(mask & (1u << i)))
{
uint8_t *iter = xcb_xkb_get_map_map_vmods_rtrn(map);
- darray_resize0(keymap->mods,
+ darray_resize0(keymap->mods.mods,
NUM_REAL_MODS + msb_pos(reply->virtualMods));
for (unsigned i = 0; i < NUM_VMODS; i++) {
if (reply->virtualMods & (1u << i)) {
uint8_t wire = *iter;
- struct xkb_mod *mod = &darray_item(keymap->mods, NUM_REAL_MODS + i);
+ struct xkb_mod *mod = &darray_item(keymap->mods.mods,
+ NUM_REAL_MODS + i);
mod->type = MOD_VIRT;
mod->mapping = translate_mods(wire, 0, 0);
* tells us which vmods exist (a vmod must have a name), so we fix
* up the size here.
*/
- darray_resize0(keymap->mods, NUM_REAL_MODS + msb_pos(reply->virtualMods));
+ darray_resize0(keymap->mods.mods,
+ NUM_REAL_MODS + msb_pos(reply->virtualMods));
for (unsigned i = 0; i < NUM_VMODS; i++) {
if (reply->virtualMods & (1u << i)) {
xcb_atom_t wire = *iter;
- struct xkb_mod *mod = &darray_item(keymap->mods, NUM_REAL_MODS + i);
+ struct xkb_mod *mod = &darray_item(keymap->mods.mods,
+ NUM_REAL_MODS + i);
if (!adopt_atom(keymap->ctx, conn, wire, &mod->name))
return false;
const struct xkb_mod *mod;
xkb_mod_index_t num_vmods = 0;
- darray_foreach(mod, keymap->mods) {
+ darray_foreach(mod, keymap->mods.mods) {
if (mod->type != MOD_VIRT)
continue;
if (key->modmap == 0)
continue;
- darray_enumerate(i, mod, keymap->mods)
+ darray_enumerate(i, mod, keymap->mods.mods)
if (key->modmap & (1u << i))
write_buf(buf, "\tmodifier_map %s { %s };\n",
xkb_atom_text(keymap->ctx, mod->name),
/* The effective mask is only real mods for now. */
mods->mask = mods->mods & MOD_REAL_MASK_ALL;
- darray_enumerate(i, mod, keymap->mods)
+ darray_enumerate(i, mod, keymap->mods.mods)
if (mods->mods & (1u << i))
mods->mask |= mod->mapping;
}
/* Update keymap->mods, the virtual -> real mod mapping. */
xkb_foreach_key(key, keymap)
- darray_enumerate(i, mod, keymap->mods)
+ darray_enumerate(i, mod, keymap->mods.mods)
if (key->vmodmap & (1u << i))
mod->mapping |= key->modmap;
mapping = 0;
}
- darray_enumerate(i, mod, keymap->mods) {
+ darray_enumerate(i, mod, keymap->mods.mods) {
if (mod->name == stmt->name) {
if (mod->type != MOD_VIRT) {
log_err(keymap->ctx,
}
}
- if (darray_size(keymap->mods) >= XKB_MAX_MODS) {
+ if (darray_size(keymap->mods.mods) >= XKB_MAX_MODS) {
log_err(keymap->ctx,
"Too many modifiers defined (maximum %d)\n",
XKB_MAX_MODS);
new.name = stmt->name;
new.mapping = mapping;
new.type = MOD_VIRT;
- darray_append(keymap->mods, new);
+ darray_append(keymap->mods.mods, new);
return true;
}