diff options
author | Ran Benita <ran234@gmail.com> | 2013-02-08 14:39:38 +0200 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2014-04-19 16:23:48 +0300 |
commit | b5655b3d67c10ccd621261bcade8b60a4775dd7f (patch) | |
tree | 2244e8093ce43ac4badce842d0c851d4ff1fbc4e /src/xkbcomp | |
parent | 0b7c8d619889b7c04a6dd9936c163e0b7c801025 (diff) | |
download | libxkbcommon-b5655b3d67c10ccd621261bcade8b60a4775dd7f.tar.gz libxkbcommon-b5655b3d67c10ccd621261bcade8b60a4775dd7f.tar.bz2 libxkbcommon-b5655b3d67c10ccd621261bcade8b60a4775dd7f.zip |
vmod: take xkb_mod_set instead of the entire keymap
This is the only place where the modifier information is modified. We
will make it local to a given XKB file (after which it will be merged
into the keymap). Currently it changes the keymap directly, which
sidesteps the abstraction and leaves side-effects even if the XkbFile's
compilation fails.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/xkbcomp')
-rw-r--r-- | src/xkbcomp/compat.c | 3 | ||||
-rw-r--r-- | src/xkbcomp/symbols.c | 3 | ||||
-rw-r--r-- | src/xkbcomp/types.c | 3 | ||||
-rw-r--r-- | src/xkbcomp/vmod.c | 31 | ||||
-rw-r--r-- | src/xkbcomp/vmod.h | 4 |
5 files changed, 23 insertions, 21 deletions
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 772e3f3..7555f41 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -768,7 +768,8 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleGlobalVar(info, (VarDef *) stmt); break; case STMT_VMOD: - ok = HandleVModDef(info->keymap, (VModDef *) stmt, merge); + ok = HandleVModDef(info->ctx, &info->keymap->mods, + (VModDef *) stmt, merge); break; default: log_err(info->ctx, diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 310fc0c..f259c74 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -1199,7 +1199,8 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleGlobalVar(info, (VarDef *) stmt); break; case STMT_VMOD: - ok = HandleVModDef(info->keymap, (VModDef *) stmt, merge); + ok = HandleVModDef(info->ctx, &info->keymap->mods, + (VModDef *) stmt, merge); break; case STMT_MODMAP: ok = HandleModMapDef(info, (ModMapDef *) stmt); diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c index d022999..521a3d6 100644 --- a/src/xkbcomp/types.c +++ b/src/xkbcomp/types.c @@ -645,7 +645,8 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge) ok = true; break; case STMT_VMOD: - ok = HandleVModDef(info->keymap, (VModDef *) stmt, merge); + ok = HandleVModDef(info->ctx, &info->keymap->mods, + (VModDef *) stmt, merge); break; default: log_err(info->ctx, diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c index 363752e..9273a10 100644 --- a/src/xkbcomp/vmod.c +++ b/src/xkbcomp/vmod.c @@ -30,8 +30,8 @@ #include "vmod.h" bool -HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, - enum merge_mode merge) +HandleVModDef(struct xkb_context *ctx, struct xkb_mod_set *mods, + VModDef *stmt, enum merge_mode merge) { xkb_mod_index_t i; struct xkb_mod *mod; @@ -46,11 +46,10 @@ HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, * it sets the vmod-to-real-mod[s] mapping directly instead of going * through modifier_map or some such. */ - if (!ExprResolveModMask(keymap->ctx, stmt->value, MOD_REAL, - &keymap->mods, &mapping)) { - log_err(keymap->ctx, + if (!ExprResolveModMask(ctx, stmt->value, MOD_REAL, mods, &mapping)) { + log_err(ctx, "Declaration of %s ignored\n", - xkb_atom_text(keymap->ctx, stmt->name)); + xkb_atom_text(ctx, stmt->name)); return false; } } @@ -58,13 +57,13 @@ HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, mapping = 0; } - darray_enumerate(i, mod, keymap->mods.mods) { + darray_enumerate(i, mod, mods->mods) { if (mod->name == stmt->name) { if (mod->type != MOD_VIRT) { - log_err(keymap->ctx, + log_err(ctx, "Can't add a virtual modifier named \"%s\"; " "there is already a non-virtual modifier with this name! Ignored\n", - xkb_atom_text(keymap->ctx, mod->name)); + xkb_atom_text(ctx, mod->name)); return false; } @@ -77,12 +76,12 @@ HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, use = (merge == MERGE_OVERRIDE ? mapping : mod->mapping); ignore = (merge == MERGE_OVERRIDE ? mod->mapping : mapping); - log_warn(keymap->ctx, + log_warn(ctx, "Virtual modifier %s defined multiple times; " "Using %s, ignoring %s\n", - xkb_atom_text(keymap->ctx, stmt->name), - ModMaskText(keymap->ctx, &keymap->mods, use), - ModMaskText(keymap->ctx, &keymap->mods, ignore)); + xkb_atom_text(ctx, stmt->name), + ModMaskText(ctx, mods, use), + ModMaskText(ctx, mods, ignore)); mapping = use; } @@ -92,8 +91,8 @@ HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, } } - if (darray_size(keymap->mods.mods) >= XKB_MAX_MODS) { - log_err(keymap->ctx, + if (darray_size(mods->mods) >= XKB_MAX_MODS) { + log_err(ctx, "Too many modifiers defined (maximum %d)\n", XKB_MAX_MODS); return false; @@ -102,6 +101,6 @@ HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, new.name = stmt->name; new.mapping = mapping; new.type = MOD_VIRT; - darray_append(keymap->mods.mods, new); + darray_append(mods->mods, new); return true; } diff --git a/src/xkbcomp/vmod.h b/src/xkbcomp/vmod.h index 1ba59f7..546cf7e 100644 --- a/src/xkbcomp/vmod.h +++ b/src/xkbcomp/vmod.h @@ -28,7 +28,7 @@ #define XKBCOMP_VMOD_H bool -HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, - enum merge_mode merge); +HandleVModDef(struct xkb_context *ctx, struct xkb_mod_set *mods, + VModDef *stmt, enum merge_mode merge); #endif |