summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2014-04-22 11:47:23 +0300
committerRan Benita <ran234@gmail.com>2014-04-22 14:56:01 +0300
commit6b1cdee107caaf8009037763a3cc3cd51132a1dd (patch)
tree7323ed92c74c361858c019baabcf268d31c63ced /src
parent0f6bca2b37cb67e9a76acd1c3117e19fb0a115df (diff)
downloadxorg-lib-libxkbcommon-6b1cdee107caaf8009037763a3cc3cd51132a1dd.tar.gz
keymap: add and use xkb_mods_{foreach,enumerate}()
To iterate over an xkb_mod_set. Slightly nicer interface and makes transitioning from darray easier. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/keymap-priv.c2
-rw-r--r--src/keymap.h6
-rw-r--r--src/text.c2
-rw-r--r--src/xkbcomp/keymap-dump.c4
-rw-r--r--src/xkbcomp/keymap.c4
-rw-r--r--src/xkbcomp/vmod.c2
6 files changed, 13 insertions, 7 deletions
diff --git a/src/keymap-priv.c b/src/keymap-priv.c
index 4b0c6ad..f391336 100644
--- a/src/keymap-priv.c
+++ b/src/keymap-priv.c
@@ -130,7 +130,7 @@ XkbModNameToIndex(const struct xkb_mod_set *mods, xkb_atom_t name,
xkb_mod_index_t i;
const struct xkb_mod *mod;
- darray_enumerate(i, mod, mods->mods)
+ xkb_mods_enumerate(i, mod, mods)
if ((mod->type & type) && name == mod->name)
return i;
diff --git a/src/keymap.h b/src/keymap.h
index ae86f6b..ed2f8e7 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -402,6 +402,12 @@ struct xkb_keymap {
(iter) <= (keymap)->keys + (keymap)->max_key_code; \
(iter)++)
+#define xkb_mods_foreach(iter, mods_) \
+ darray_foreach((iter), (mods_)->mods)
+
+#define xkb_mods_enumerate(idx, iter, mods_) \
+ darray_enumerate((idx), (iter), (mods_)->mods)
+
static inline const struct xkb_key *
XkbKey(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
diff --git a/src/text.c b/src/text.c
index 8d26d19..133094a 100644
--- a/src/text.c
+++ b/src/text.c
@@ -265,7 +265,7 @@ ModMaskText(struct xkb_context *ctx, const struct xkb_mod_set *mods,
if (mask == MOD_REAL_MASK_ALL)
return "all";
- darray_enumerate(i, mod, mods->mods) {
+ xkb_mods_enumerate(i, mod, mods) {
int ret;
if (!(mask & (1u << i)))
diff --git a/src/xkbcomp/keymap-dump.c b/src/xkbcomp/keymap-dump.c
index 3b1573d..43f1642 100644
--- a/src/xkbcomp/keymap-dump.c
+++ b/src/xkbcomp/keymap-dump.c
@@ -126,7 +126,7 @@ write_vmods(struct xkb_keymap *keymap, struct buf *buf)
const struct xkb_mod *mod;
xkb_mod_index_t num_vmods = 0;
- darray_foreach(mod, keymap->mods.mods) {
+ xkb_mods_foreach(mod, &keymap->mods) {
if (mod->type != MOD_VIRT)
continue;
@@ -624,7 +624,7 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
if (key->modmap == 0)
continue;
- darray_enumerate(i, mod, keymap->mods.mods)
+ xkb_mods_enumerate(i, mod, &keymap->mods)
if (key->modmap & (1u << i))
write_buf(buf, "\tmodifier_map %s { %s };\n",
xkb_atom_text(keymap->ctx, mod->name),
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index 281c6c0..acba662 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -38,7 +38,7 @@ ComputeEffectiveMask(struct xkb_keymap *keymap, struct xkb_mods *mods)
/* The effective mask is only real mods for now. */
mods->mask = mods->mods & MOD_REAL_MASK_ALL;
- darray_enumerate(i, mod, keymap->mods.mods)
+ xkb_mods_enumerate(i, mod, &keymap->mods)
if (mods->mods & (1u << i))
mods->mask |= mod->mapping;
}
@@ -193,7 +193,7 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
/* Update keymap->mods, the virtual -> real mod mapping. */
xkb_keys_foreach(key, keymap)
- darray_enumerate(i, mod, keymap->mods.mods)
+ xkb_mods_enumerate(i, mod, &keymap->mods)
if (key->vmodmap & (1u << i))
mod->mapping |= key->modmap;
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 8f4221d..61f571c 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -78,7 +78,7 @@ HandleVModDef(struct xkb_context *ctx, struct xkb_mod_set *mods,
mapping = 0;
}
- darray_enumerate(i, mod, mods->mods) {
+ xkb_mods_enumerate(i, mod, mods) {
if (mod->name == stmt->name) {
if (mod->type != MOD_VIRT) {
log_err(ctx,