diff options
author | Ran Benita <ran234@gmail.com> | 2014-04-19 15:56:27 +0300 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2014-04-19 16:12:26 +0300 |
commit | 51a1df2f2180f11d80c476f8b240062ae2573f7b (patch) | |
tree | 131f2c139f43cda425e80e9d0e97217d3170cb18 | |
parent | 120c5c317e5691f091664d88724413a504814de4 (diff) | |
download | libxkbcommon-51a1df2f2180f11d80c476f8b240062ae2573f7b.tar.gz libxkbcommon-51a1df2f2180f11d80c476f8b240062ae2573f7b.tar.bz2 libxkbcommon-51a1df2f2180f11d80c476f8b240062ae2573f7b.zip |
keymap: move ModNameToIndex from text.c and use it in keymap.c
Signed-off-by: Ran Benita <ran234@gmail.com>
-rw-r--r-- | src/keymap-priv.c | 14 | ||||
-rw-r--r-- | src/keymap.c | 8 | ||||
-rw-r--r-- | src/keymap.h | 4 | ||||
-rw-r--r-- | src/text.c | 14 | ||||
-rw-r--r-- | src/text.h | 4 | ||||
-rw-r--r-- | src/xkbcomp/expr.c | 4 | ||||
-rw-r--r-- | src/xkbcomp/symbols.c | 2 |
7 files changed, 22 insertions, 28 deletions
diff --git a/src/keymap-priv.c b/src/keymap-priv.c index 2b3f8cd..73d722f 100644 --- a/src/keymap-priv.c +++ b/src/keymap-priv.c @@ -121,3 +121,17 @@ XkbEscapeMapName(char *name) name++; } } + +xkb_mod_index_t +XkbModNameToIndex(const struct xkb_keymap *keymap, xkb_atom_t name, + enum mod_type type) +{ + xkb_mod_index_t i; + const struct xkb_mod *mod; + + darray_enumerate(i, mod, keymap->mods) + if ((mod->type & type) && name == mod->name) + return i; + + return XKB_MOD_INVALID; +} diff --git a/src/keymap.c b/src/keymap.c index 892b7cf..7ae0818 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -284,19 +284,13 @@ xkb_keymap_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx) XKB_EXPORT xkb_mod_index_t xkb_keymap_mod_get_index(struct xkb_keymap *keymap, const char *name) { - xkb_mod_index_t i; xkb_atom_t atom; - const struct xkb_mod *mod; atom = xkb_atom_lookup(keymap->ctx, name); if (atom == XKB_ATOM_NONE) return XKB_MOD_INVALID; - darray_enumerate(i, mod, keymap->mods) - if (mod->name == atom) - return i; - - return XKB_MOD_INVALID; + return XkbModNameToIndex(keymap, atom, MOD_BOTH); } /** diff --git a/src/keymap.h b/src/keymap.h index 39ac420..604f6c0 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -426,6 +426,10 @@ XkbResolveKeyAlias(struct xkb_keymap *keymap, xkb_atom_t name); void XkbEscapeMapName(char *name); +xkb_mod_index_t +XkbModNameToIndex(const struct xkb_keymap *keymap, xkb_atom_t name, + enum mod_type type); + xkb_layout_index_t wrap_group_into_range(int32_t group, xkb_layout_index_t num_groups, @@ -218,20 +218,6 @@ ModIndexText(const struct xkb_keymap *keymap, xkb_mod_index_t ndx) return xkb_atom_text(keymap->ctx, darray_item(keymap->mods, ndx).name); } -xkb_mod_index_t -ModNameToIndex(const struct xkb_keymap *keymap, xkb_atom_t name, - enum mod_type type) -{ - xkb_mod_index_t i; - const struct xkb_mod *mod; - - darray_enumerate(i, mod, keymap->mods) - if ((mod->type & type) && name == mod->name) - return i; - - return XKB_MOD_INVALID; -} - const char * ActionTypeText(enum xkb_action_type type) { @@ -53,10 +53,6 @@ ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask); const char * ModIndexText(const struct xkb_keymap *keymap, xkb_mod_index_t ndx); -xkb_mod_index_t -ModNameToIndex(const struct xkb_keymap *keymap, xkb_atom_t name, - enum mod_type type); - const char * ActionTypeText(enum xkb_action_type type); diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index 6d3e466..4c31205 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -112,7 +112,7 @@ LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field, return true; } - ndx = ModNameToIndex(keymap, field, mod_type); + ndx = XkbModNameToIndex(keymap, field, mod_type); if (ndx == XKB_MOD_INVALID) return false; @@ -665,7 +665,7 @@ ExprResolveMod(struct xkb_keymap *keymap, const ExprDef *def, } name = def->ident.ident; - ndx = ModNameToIndex(keymap, name, mod_type); + ndx = XkbModNameToIndex(keymap, name, mod_type); if (ndx == XKB_MOD_INVALID) { log_err(keymap->ctx, "Cannot resolve virtual modifier: " diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 940428f..541d320 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -1139,7 +1139,7 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def) bool ok; struct xkb_context *ctx = info->ctx; - ndx = ModNameToIndex(info->keymap, def->modifier, MOD_REAL); + ndx = XkbModNameToIndex(info->keymap, def->modifier, MOD_REAL); if (ndx == XKB_MOD_INVALID) { log_err(info->ctx, "Illegal modifier map definition; " |