summaryrefslogtreecommitdiff
path: root/src/xkbcomp/compat.c
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-09-02 11:29:31 +0300
committerRan Benita <ran234@gmail.com>2012-09-03 10:25:20 +0300
commit87bfd973331491f7ab54626b61eb3a1ff46f8dcd (patch)
tree867cdd0102c48aff40d2b76e11863f2abf736150 /src/xkbcomp/compat.c
parent4ca85c7b3b46fb8d54d884a13c29cc78967f2313 (diff)
downloadlibxkbcommon-87bfd973331491f7ab54626b61eb3a1ff46f8dcd.tar.gz
libxkbcommon-87bfd973331491f7ab54626b61eb3a1ff46f8dcd.tar.bz2
libxkbcommon-87bfd973331491f7ab54626b61eb3a1ff46f8dcd.zip
action: keep array of default actions, instead of list of changes
The implementation of changing the default properties of actions, e.g. a statements such as (from test/data/compat/basic): setMods.clearLocks= True; latchMods.clearLocks= True; latchMods.latchToLock= True; works by keeping a list of ActionInfo's, each containing the neccesary info from each statement, and then when some action comes up (e.g. in an interpret statment) it goes through the list, and applies the relevent ActionInfo's to the newly-constructed xkb_action. Instead of doing this, we add a struct ActionsInfo, which contains an array of xkb_actions, one for each type. When a default changing statement appears, we change the action in the array; when a new action comes up, we just copy from the array. This is simpler to figure out, and pretty straightforward. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/xkbcomp/compat.c')
-rw-r--r--src/xkbcomp/compat.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index b6d15d7..1919a97 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -178,7 +178,7 @@ typedef struct _CompatInfo {
LEDInfo ledDflt;
darray(LEDInfo) leds;
VModInfo vmods;
- ActionInfo *act;
+ ActionsInfo *actions;
struct xkb_keymap *keymap;
} CompatInfo;
@@ -240,14 +240,15 @@ ClearIndicatorMapInfo(struct xkb_context *ctx, LEDInfo *info)
}
static void
-InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id)
+InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id,
+ ActionsInfo *actions)
{
info->keymap = keymap;
info->name = NULL;
info->file_id = file_id;
info->errorCount = 0;
darray_init(info->interps);
- info->act = NULL;
+ info->actions = actions;
info->dflt.file_id = file_id;
info->dflt.defined = 0;
info->dflt.merge = MERGE_OVERRIDE;
@@ -279,8 +280,7 @@ ClearCompatInfo(CompatInfo *info)
ClearIndicatorMapInfo(keymap->ctx, &info->ledDflt);
darray_free(info->interps);
darray_free(info->leds);
- FreeActionInfo(info->act);
- info->act = NULL;
+ info->actions = NULL;
info->keymap = NULL;
ClearVModInfo(&info->vmods);
}
@@ -551,7 +551,7 @@ HandleIncludeCompatMap(CompatInfo *info, IncludeStmt *stmt)
XkbFile *rtrn;
CompatInfo included, next_incl;
- InitCompatInfo(&included, info->keymap, info->file_id);
+ InitCompatInfo(&included, info->keymap, info->file_id, info->actions);
if (stmt->stmt) {
free(included.name);
included.name = stmt->stmt;
@@ -566,20 +566,17 @@ HandleIncludeCompatMap(CompatInfo *info, IncludeStmt *stmt)
return false;
}
- InitCompatInfo(&next_incl, info->keymap, rtrn->id);
+ InitCompatInfo(&next_incl, info->keymap, rtrn->id, info->actions);
next_incl.file_id = rtrn->id;
next_incl.dflt = info->dflt;
next_incl.dflt.file_id = rtrn->id;
next_incl.dflt.merge = merge;
next_incl.ledDflt.file_id = rtrn->id;
next_incl.ledDflt.merge = merge;
- next_incl.act = info->act;
HandleCompatMapFile(&next_incl, rtrn, MERGE_OVERRIDE);
MergeIncludedCompatMaps(&included, &next_incl, merge);
- if (info->act)
- next_incl.act = NULL;
ClearCompatInfo(&next_incl);
FreeXkbFile(rtrn);
@@ -610,7 +607,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
if (arrayNdx)
return ReportSINotArray(info, si, field);
- if (!HandleActionDef(value, keymap, &si->interp.act, info->act))
+ if (!HandleActionDef(value, keymap, &si->interp.act, info->actions))
return false;
si->defined |= SI_FIELD_ACTION;
@@ -821,7 +818,7 @@ HandleGlobalVar(CompatInfo *info, VarDef *stmt)
stmt->value);
else
ret = SetActionField(info->keymap, elem, field, ndx, stmt->value,
- &info->act);
+ info->actions);
return ret;
}
@@ -1095,8 +1092,13 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge)
{
CompatInfo info;
+ ActionsInfo *actions;
- InitCompatInfo(&info, keymap, file->id);
+ actions = NewActionsInfo();
+ if (!actions)
+ return false;
+
+ InitCompatInfo(&info, keymap, file->id, actions);
info.dflt.merge = merge;
info.ledDflt.merge = merge;
@@ -1108,9 +1110,11 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
goto err_info;
ClearCompatInfo(&info);
+ FreeActionsInfo(actions);
return true;
err_info:
ClearCompatInfo(&info);
+ FreeActionsInfo(actions);
return false;
}