1 /************************************************************
2 * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
4 * Permission to use, copy, modify, and distribute this
5 * software and its documentation for any purpose and without
6 * fee is hereby granted, provided that the above copyright
7 * notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting
9 * documentation, and that the name of Silicon Graphics not be
10 * used in advertising or publicity pertaining to distribution
11 * of the software without specific prior written permission.
12 * Silicon Graphics makes no representation about the suitability
13 * of this software for any purpose. It is provided "as is"
14 * without any express or implied warranty.
16 * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23 * THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 ********************************************************/
28 * Copyright © 2012 Ran Benita <ran234@gmail.com>
30 * Permission is hereby granted, free of charge, to any person obtaining a
31 * copy of this software and associated documentation files (the "Software"),
32 * to deal in the Software without restriction, including without limitation
33 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
34 * and/or sell copies of the Software, and to permit persons to whom the
35 * Software is furnished to do so, subject to the following conditions:
37 * The above copyright notice and this permission notice (including the next
38 * paragraph) shall be included in all copies or substantial portions of the
41 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
44 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
46 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
47 * DEALINGS IN THE SOFTWARE.
50 #include "xkbcomp-priv.h"
58 * The xkb_compat section
59 * =====================
60 * This section is the third to be processesed, after xkb_keycodes and
63 * Interpret statements
64 * --------------------
65 * Statements of the form:
66 * interpret Num_Lock+Any { ... }
68 * The body of the statment may include statements of the following
72 * action = LockMods(modifiers=NumLock);
74 * - virtual modifier statement:
75 * virtualModifier = NumLock;
80 * - useModMapMods statement:
81 * useModMapMods = level1;
83 * Indicator map statements
84 * ------------------------
85 * Statements of the form:
86 * indicator "Shift Lock" { ... }
88 * This statement specifies the behavior and binding of the indicator
89 * with the given name ("Shift Lock" above). The name should have been
90 * declared previously in the xkb_keycodes section (see Indicator name
91 * statement), and given an index there. If it wasn't, it is created
92 * with the next free index.
93 * The body of the statement describes the conditions of the keyboard
94 * state which will cause the indicator to be lit. It may include the
95 * following statements:
97 * - modifiers statment:
98 * modifiers = ScrollLock;
100 * If the given modifiers are in the required state (see below), the
103 * - whichModifierState statment:
104 * whichModState = Latched + Locked;
106 * Can be any combination of:
107 * base, latched, locked, effective
108 * any (i.e. all of the above)
109 * none (i.e. none of the above)
110 * compat (this is legal, but unused)
111 * This will cause the respective portion of the modifer state (see
112 * struct xkb_state) to be matched against the modifiers given in the
113 * "modifiers" statement.
115 * Here's a simple example:
116 * indicator "Num Lock" {
117 * modifiers = NumLock;
118 * whichModState = Locked;
120 * Whenever the NumLock modifier is locked, the Num Lock indicator
124 * groups = All - group1;
126 * If the given groups are in the required state (see below), the led
129 * - whichGroupState statment:
130 * whichGroupState = Effective;
132 * Can be any combination of:
133 * base, latched, locked, effective
134 * any (i.e. all of the above)
135 * none (i.e. none of the above)
136 * This will cause the respective portion of the group state (see
137 * struct xkb_state) to be matched against the groups given in the
138 * "groups" statement.
140 * Note: the above conditions are disjunctive, i.e. if any of them are
141 * satisfied the led is lit.
143 * Virtual modifier statements
144 * ---------------------------
145 * Statements of the form:
146 * virtual_modifiers LControl;
148 * Can appear in the xkb_types, xkb_compat, xkb_symbols sections.
153 * After all of the xkb_compat sections have been compiled, the following
154 * members of struct xkb_keymap are finalized:
155 * darray(struct xkb_sym_interpret) sym_interpret;
156 * struct xkb_indicator_map indicators[XKB_NUM_INDICATORS];
157 * char *compat_section_name;
158 * TODO: virtual modifiers.
162 SI_FIELD_VIRTUAL_MOD = (1 << 0),
163 SI_FIELD_ACTION = (1 << 1),
164 SI_FIELD_AUTO_REPEAT = (1 << 2),
165 SI_FIELD_LEVEL_ONE_ONLY = (1 << 3),
169 enum si_field defined;
171 enum merge_mode merge;
173 struct xkb_sym_interpret interp;
177 LED_FIELD_MODS = (1 << 0),
178 LED_FIELD_GROUPS = (1 << 1),
179 LED_FIELD_CTRLS = (1 << 2),
183 enum led_field defined;
185 enum merge_mode merge;
187 struct xkb_indicator_map im;
195 darray(SymInterpInfo) interps;
197 darray(LEDInfo) leds;
198 ActionsInfo *actions;
199 struct xkb_keymap *keymap;
203 siText(SymInterpInfo *si, CompatInfo *info)
205 static char buf[128];
207 if (si == &info->dflt)
210 snprintf(buf, sizeof(buf), "%s+%s(%s)",
211 KeysymText(si->interp.sym),
212 SIMatchText(si->interp.match),
213 ModMaskText(info->keymap, si->interp.mods, MOD_REAL));
218 ReportSINotArray(CompatInfo *info, SymInterpInfo *si, const char *field)
220 return ReportNotArray(info->keymap, "symbol interpretation", field,
225 ReportSIBadType(CompatInfo *info, SymInterpInfo *si, const char *field,
228 return ReportBadType(info->keymap->ctx, "symbol interpretation", field,
229 siText(si, info), wanted);
233 ReportIndicatorBadType(CompatInfo *info, LEDInfo *led,
234 const char *field, const char *wanted)
236 return ReportBadType(info->keymap->ctx, "indicator map", field,
237 xkb_atom_text(info->keymap->ctx, led->im.name),
242 ReportIndicatorNotArray(CompatInfo *info, LEDInfo *led,
245 return ReportNotArray(info->keymap, "indicator map", field,
246 xkb_atom_text(info->keymap->ctx, led->im.name));
250 InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id,
251 ActionsInfo *actions)
253 memset(info, 0, sizeof(*info));
254 info->keymap = keymap;
255 info->file_id = file_id;
256 info->actions = actions;
257 info->dflt.file_id = file_id;
258 info->dflt.merge = MERGE_OVERRIDE;
259 info->dflt.interp.virtual_mod = XKB_MOD_INVALID;
260 info->ledDflt.file_id = file_id;
261 info->ledDflt.merge = MERGE_OVERRIDE;
265 ClearCompatInfo(CompatInfo *info)
268 darray_free(info->interps);
269 darray_free(info->leds);
272 static SymInterpInfo *
273 FindMatchingInterp(CompatInfo *info, SymInterpInfo *new)
277 darray_foreach(old, info->interps)
278 if (old->interp.sym == new->interp.sym &&
279 old->interp.mods == new->interp.mods &&
280 old->interp.match == new->interp.match)
287 UseNewInterpField(enum si_field field, SymInterpInfo *old, SymInterpInfo *new,
288 bool report, enum si_field *collide)
290 if (!(old->defined & field))
293 if (new->defined & field) {
297 if (new->merge != MERGE_AUGMENT)
305 AddInterp(CompatInfo *info, SymInterpInfo *new)
307 enum si_field collide = 0;
310 old = FindMatchingInterp(info, new);
312 int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
313 bool report = ((old->file_id == new->file_id && verbosity > 0) ||
316 if (new->merge == MERGE_REPLACE) {
318 log_warn(info->keymap->ctx,
319 "Multiple definitions for \"%s\"; "
320 "Earlier interpretation ignored\n",
326 if (UseNewInterpField(SI_FIELD_VIRTUAL_MOD, old, new, report,
328 old->interp.virtual_mod = new->interp.virtual_mod;
329 old->defined |= SI_FIELD_VIRTUAL_MOD;
331 if (UseNewInterpField(SI_FIELD_ACTION, old, new, report,
333 old->interp.act = new->interp.act;
334 old->defined |= SI_FIELD_ACTION;
336 if (UseNewInterpField(SI_FIELD_AUTO_REPEAT, old, new, report,
338 old->interp.repeat = new->interp.repeat;
339 old->defined |= SI_FIELD_AUTO_REPEAT;
341 if (UseNewInterpField(SI_FIELD_LEVEL_ONE_ONLY, old, new, report,
343 old->interp.match &= ~MATCH_LEVEL_ONE_ONLY;
344 old->interp.match |= (new->interp.match & MATCH_LEVEL_ONE_ONLY);
345 old->defined |= SI_FIELD_LEVEL_ONE_ONLY;
349 log_warn(info->keymap->ctx,
350 "Multiple interpretations of \"%s\"; "
351 "Using %s definition for duplicate fields\n",
353 (new->merge != MERGE_AUGMENT ? "last" : "first"));
359 darray_append(info->interps, *new);
364 /***====================================================================***/
367 ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn,
368 xkb_mod_mask_t *mods_rtrn, CompatInfo *info)
371 *pred_rtrn = MATCH_ANY_OR_NONE;
376 *pred_rtrn = MATCH_EXACTLY;
377 if (expr->op == EXPR_ACTION_DECL) {
378 const char *pred_txt = xkb_atom_text(info->keymap->ctx,
379 expr->value.action.name);
380 if (!LookupString(symInterpretMatchMaskNames, pred_txt, pred_rtrn)) {
381 log_err(info->keymap->ctx,
382 "Illegal modifier predicate \"%s\"; Ignored\n", pred_txt);
385 expr = expr->value.action.args;
387 else if (expr->op == EXPR_IDENT) {
388 const char *pred_txt = xkb_atom_text(info->keymap->ctx,
390 if (pred_txt && istreq(pred_txt, "any")) {
391 *pred_rtrn = MATCH_ANY;
397 return ExprResolveModMask(info->keymap, expr, mods_rtrn);
400 /***====================================================================***/
403 UseNewLEDField(enum led_field field, LEDInfo *old, LEDInfo *new,
404 bool report, enum led_field *collide)
406 if (!(old->defined & field))
409 if (new->defined & field) {
413 if (new->merge != MERGE_AUGMENT)
421 AddIndicatorMap(CompatInfo *info, LEDInfo *new)
424 enum led_field collide;
425 struct xkb_context *ctx = info->keymap->ctx;
426 int verbosity = xkb_context_get_log_verbosity(ctx);
428 darray_foreach(old, info->leds) {
431 if (old->im.name != new->im.name)
434 if (old->im.mods.mods == new->im.mods.mods &&
435 old->im.groups == new->im.groups &&
436 old->im.ctrls == new->im.ctrls &&
437 old->im.which_mods == new->im.which_mods &&
438 old->im.which_groups == new->im.which_groups) {
439 old->defined |= new->defined;
443 report = ((old->file_id == new->file_id && verbosity > 0) ||
446 if (new->merge == MERGE_REPLACE) {
448 log_warn(info->keymap->ctx,
449 "Map for indicator %s redefined; "
450 "Earlier definition ignored\n",
451 xkb_atom_text(ctx, old->im.name));
457 if (UseNewLEDField(LED_FIELD_MODS, old, new, report, &collide)) {
458 old->im.which_mods = new->im.which_mods;
459 old->im.mods = new->im.mods;
460 old->defined |= LED_FIELD_MODS;
462 if (UseNewLEDField(LED_FIELD_GROUPS, old, new, report, &collide)) {
463 old->im.which_groups = new->im.which_groups;
464 old->im.groups = new->im.groups;
465 old->defined |= LED_FIELD_GROUPS;
467 if (UseNewLEDField(LED_FIELD_CTRLS, old, new, report, &collide)) {
468 old->im.ctrls = new->im.ctrls;
469 old->defined |= LED_FIELD_CTRLS;
473 log_warn(info->keymap->ctx,
474 "Map for indicator %s redefined; "
475 "Using %s definition for duplicate fields\n",
476 xkb_atom_text(ctx, old->im.name),
477 (new->merge == MERGE_AUGMENT ? "first" : "last"));
483 darray_append(info->leds, *new);
488 MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
489 enum merge_mode merge)
494 if (from->errorCount > 0) {
495 into->errorCount += from->errorCount;
499 if (into->name == NULL) {
500 into->name = from->name;
504 darray_foreach(si, from->interps) {
505 si->merge = (merge == MERGE_DEFAULT ? si->merge : merge);
506 if (!AddInterp(into, si))
510 darray_foreach(led, from->leds) {
511 led->merge = (merge == MERGE_DEFAULT ? led->merge : merge);
512 if (!AddIndicatorMap(into, led))
518 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge);
521 HandleIncludeCompatMap(CompatInfo *info, IncludeStmt *stmt)
523 enum merge_mode merge = MERGE_DEFAULT;
525 CompatInfo included, next_incl;
527 InitCompatInfo(&included, info->keymap, info->file_id, info->actions);
530 included.name = stmt->stmt;
534 for (; stmt; stmt = stmt->next_incl) {
535 if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_COMPAT,
537 info->errorCount += 10;
538 ClearCompatInfo(&included);
542 InitCompatInfo(&next_incl, info->keymap, rtrn->id, info->actions);
543 next_incl.file_id = rtrn->id;
544 next_incl.dflt = info->dflt;
545 next_incl.dflt.file_id = rtrn->id;
546 next_incl.dflt.merge = merge;
547 next_incl.ledDflt.file_id = rtrn->id;
548 next_incl.ledDflt.merge = merge;
550 HandleCompatMapFile(&next_incl, rtrn, MERGE_OVERRIDE);
552 MergeIncludedCompatMaps(&included, &next_incl, merge);
554 ClearCompatInfo(&next_incl);
558 MergeIncludedCompatMaps(info, &included, merge);
559 ClearCompatInfo(&included);
561 return (info->errorCount == 0);
565 SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
566 ExprDef *arrayNdx, ExprDef *value)
568 struct xkb_keymap *keymap = info->keymap;
571 if (istreq(field, "action")) {
573 return ReportSINotArray(info, si, field);
575 if (!HandleActionDef(value, keymap, &si->interp.act, info->actions))
578 si->defined |= SI_FIELD_ACTION;
580 else if (istreq(field, "virtualmodifier") ||
581 istreq(field, "virtualmod")) {
583 return ReportSINotArray(info, si, field);
585 if (!ExprResolveVMod(keymap, value, &ndx))
586 return ReportSIBadType(info, si, field, "virtual modifier");
588 si->interp.virtual_mod = ndx;
589 si->defined |= SI_FIELD_VIRTUAL_MOD;
591 else if (istreq(field, "repeat")) {
595 return ReportSINotArray(info, si, field);
597 if (!ExprResolveBoolean(keymap->ctx, value, &set))
598 return ReportSIBadType(info, si, field, "boolean");
600 si->interp.repeat = set;
602 si->defined |= SI_FIELD_AUTO_REPEAT;
604 else if (istreq(field, "locking")) {
605 log_dbg(info->keymap->ctx,
606 "The \"locking\" field in symbol interpretation is unsupported; "
609 else if (istreq(field, "usemodmap") ||
610 istreq(field, "usemodmapmods")) {
614 return ReportSINotArray(info, si, field);
616 if (!ExprResolveEnum(keymap->ctx, value, &val, useModMapValueNames))
617 return ReportSIBadType(info, si, field, "level specification");
620 si->interp.match |= MATCH_LEVEL_ONE_ONLY;
622 si->interp.match &= ~MATCH_LEVEL_ONE_ONLY;
624 si->defined |= SI_FIELD_LEVEL_ONE_ONLY;
627 return ReportBadField(keymap, "symbol interpretation", field,
635 SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
636 const char *field, ExprDef *arrayNdx, ExprDef *value)
639 struct xkb_keymap *keymap = info->keymap;
641 if (istreq(field, "modifiers") || istreq(field, "mods")) {
643 return ReportIndicatorNotArray(info, led, field);
645 if (!ExprResolveVModMask(keymap, value, &led->im.mods.mods))
646 return ReportIndicatorBadType(info, led, field, "modifier mask");
648 led->defined |= LED_FIELD_MODS;
650 else if (istreq(field, "groups")) {
654 return ReportIndicatorNotArray(info, led, field);
656 if (!ExprResolveMask(keymap->ctx, value, &mask, groupMaskNames))
657 return ReportIndicatorBadType(info, led, field, "group mask");
659 led->im.groups = mask;
660 led->defined |= LED_FIELD_GROUPS;
662 else if (istreq(field, "controls") || istreq(field, "ctrls")) {
666 return ReportIndicatorNotArray(info, led, field);
668 if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
669 return ReportIndicatorBadType(info, led, field,
672 led->im.ctrls = mask;
673 led->defined |= LED_FIELD_CTRLS;
675 else if (istreq(field, "allowexplicit")) {
676 log_dbg(info->keymap->ctx,
677 "The \"allowExplicit\" field in indicator statements is unsupported; "
680 else if (istreq(field, "whichmodstate") ||
681 istreq(field, "whichmodifierstate")) {
685 return ReportIndicatorNotArray(info, led, field);
687 if (!ExprResolveMask(keymap->ctx, value, &mask,
688 modComponentMaskNames))
689 return ReportIndicatorBadType(info, led, field,
690 "mask of modifier state components");
692 led->im.which_mods = mask;
694 else if (istreq(field, "whichgroupstate")) {
698 return ReportIndicatorNotArray(info, led, field);
700 if (!ExprResolveMask(keymap->ctx, value, &mask,
701 groupComponentMaskNames))
702 return ReportIndicatorBadType(info, led, field,
703 "mask of group state components");
705 led->im.which_groups = mask;
707 else if (istreq(field, "driveskbd") ||
708 istreq(field, "driveskeyboard") ||
709 istreq(field, "leddriveskbd") ||
710 istreq(field, "leddriveskeyboard") ||
711 istreq(field, "indicatordriveskbd") ||
712 istreq(field, "indicatordriveskeyboard")) {
713 log_dbg(info->keymap->ctx,
714 "The \"%s\" field in indicator statements is unsupported; "
717 else if (istreq(field, "index")) {
718 /* Users should see this, it might cause unexpected behavior. */
719 log_err(info->keymap->ctx,
720 "The \"index\" field in indicator statements is unsupported; "
724 log_err(info->keymap->ctx,
725 "Unknown field %s in map for %s indicator; "
726 "Definition ignored\n",
727 field, xkb_atom_text(keymap->ctx, led->im.name));
735 HandleGlobalVar(CompatInfo *info, VarDef *stmt)
737 const char *elem, *field;
741 if (!ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field, &ndx))
743 else if (elem && istreq(elem, "interpret"))
744 ret = SetInterpField(info, &info->dflt, field, ndx, stmt->value);
745 else if (elem && istreq(elem, "indicator"))
746 ret = SetIndicatorMapField(info, &info->ledDflt, field, ndx,
749 ret = SetActionField(info->keymap, elem, field, ndx, stmt->value,
755 HandleInterpBody(CompatInfo *info, VarDef *def, SymInterpInfo *si)
758 const char *elem, *field;
761 for (; def; def = (VarDef *) def->common.next) {
762 if (def->name && def->name->op == EXPR_FIELD_REF) {
763 log_err(info->keymap->ctx,
764 "Cannot set a global default value from within an interpret statement; "
765 "Move statements to the global file scope\n");
770 ok = ExprResolveLhs(info->keymap->ctx, def->name, &elem, &field,
775 ok = SetInterpField(info, si, field, arrayNdx, def->value);
782 HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
784 enum xkb_match_operation pred;
788 if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) {
789 log_err(info->keymap->ctx,
790 "Couldn't determine matching modifiers; "
791 "Symbol interpretation ignored\n");
797 si.merge = merge = (def->merge == MERGE_DEFAULT ? merge : def->merge);
799 if (!LookupKeysym(def->sym, &si.interp.sym)) {
800 log_err(info->keymap->ctx,
801 "Could not resolve keysym %s; "
802 "Symbol interpretation ignored\n",
807 si.interp.match = pred & MATCH_OP_MASK;
809 si.interp.mods = mods;
811 if (!HandleInterpBody(info, def->def, &si)) {
816 if (!AddInterp(info, &si)) {
825 HandleIndicatorMapDef(CompatInfo *info, IndicatorMapDef *def,
826 enum merge_mode merge)
832 if (def->merge != MERGE_DEFAULT)
837 led.im.name = def->name;
840 for (var = def->body; var != NULL; var = (VarDef *) var->common.next) {
841 const char *elem, *field;
843 if (!ExprResolveLhs(info->keymap->ctx, var->name, &elem, &field,
850 log_err(info->keymap->ctx,
851 "Cannot set defaults for \"%s\" element in indicator map; "
852 "Assignment to %s.%s ignored\n", elem, elem, field);
856 ok = SetIndicatorMapField(info, &led, field, arrayNdx,
862 return AddIndicatorMap(info, &led);
868 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
873 merge = (merge == MERGE_DEFAULT ? MERGE_AUGMENT : merge);
876 info->name = strdup_safe(file->name);
878 for (stmt = file->defs; stmt; stmt = stmt->next) {
879 switch (stmt->type) {
881 ok = HandleIncludeCompatMap(info, (IncludeStmt *) stmt);
884 ok = HandleInterpDef(info, (InterpDef *) stmt, merge);
886 case STMT_GROUP_COMPAT:
887 log_dbg(info->keymap->ctx,
888 "The \"group\" statement in compat is unsupported; "
892 case STMT_INDICATOR_MAP:
893 ok = HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge);
896 ok = HandleGlobalVar(info, (VarDef *) stmt);
899 ok = HandleVModDef(info->keymap, (VModDef *) stmt);
902 log_err(info->keymap->ctx,
903 "Interpretation files may not include other types; "
904 "Ignoring %s\n", stmt_type_to_string(stmt->type));
912 if (info->errorCount > 10) {
913 log_err(info->keymap->ctx,
914 "Abandoning compatibility map \"%s\"\n", file->topName);
921 CopyInterps(CompatInfo *info, bool needSymbol, enum xkb_match_operation pred)
925 darray_foreach(si, info->interps) {
926 if (((si->interp.match & MATCH_OP_MASK) != pred) ||
927 (needSymbol && si->interp.sym == XKB_KEY_NoSymbol) ||
928 (!needSymbol && si->interp.sym != XKB_KEY_NoSymbol))
931 darray_append(info->keymap->sym_interpret, si->interp);
936 CopyIndicatorMapDefs(CompatInfo *info)
940 struct xkb_indicator_map *im;
941 struct xkb_keymap *keymap = info->keymap;
943 darray_foreach(led, info->leds) {
945 * Find the indicator with the given name, if it was already
946 * declared in keycodes.
948 for (i = 0; i < XKB_NUM_INDICATORS; i++)
949 if (keymap->indicators[i].name == led->im.name)
952 /* Not previously declared; create it with next free index. */
953 if (i >= XKB_NUM_INDICATORS) {
955 "Indicator name \"%s\" was not declared in the keycodes section; "
956 "Adding new indicator\n",
957 xkb_atom_text(keymap->ctx, led->im.name));
959 for (i = 0; i < XKB_NUM_INDICATORS; i++)
960 if (keymap->indicators[i].name == XKB_ATOM_NONE)
963 /* Not place to put it; ignore. */
964 if (i >= XKB_NUM_INDICATORS) {
966 "Too many indicators (maximum is %d); "
967 "Indicator name \"%s\" ignored\n",
969 xkb_atom_text(keymap->ctx, led->im.name));
974 im = &keymap->indicators[i];
976 if (im->groups != 0 && im->which_groups == 0)
977 im->which_groups = XKB_STATE_EFFECTIVE;
978 if (im->mods.mods != 0 && im->which_mods == 0)
979 im->which_mods = XKB_STATE_EFFECTIVE;
984 CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
986 keymap->compat_section_name = strdup_safe(info->name);
988 if (!darray_empty(info->interps)) {
989 /* Most specific to least specific. */
990 CopyInterps(info, true, MATCH_EXACTLY);
991 CopyInterps(info, true, MATCH_ALL);
992 CopyInterps(info, true, MATCH_ANY);
993 CopyInterps(info, true, MATCH_ANY_OR_NONE);
994 CopyInterps(info, false, MATCH_EXACTLY);
995 CopyInterps(info, false, MATCH_ALL);
996 CopyInterps(info, false, MATCH_ANY);
997 CopyInterps(info, false, MATCH_ANY_OR_NONE);
1000 CopyIndicatorMapDefs(info);
1006 CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
1007 enum merge_mode merge)
1010 ActionsInfo *actions;
1012 actions = NewActionsInfo();
1016 InitCompatInfo(&info, keymap, file->id, actions);
1017 info.dflt.merge = merge;
1018 info.ledDflt.merge = merge;
1020 HandleCompatMapFile(&info, file, merge);
1021 if (info.errorCount != 0)
1024 if (!CopyCompatToKeymap(keymap, &info))
1027 ClearCompatInfo(&info);
1028 FreeActionsInfo(actions);
1032 ClearCompatInfo(&info);
1033 FreeActionsInfo(actions);