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 ********************************************************/
27 #include "xkbcomp-priv.h"
35 * The xkb_compat section
36 * =====================
37 * This section is the third to be processesed, after xkb_keycodes and
40 * Interpret statements
41 * --------------------
42 * Statements of the form:
43 * interpret Num_Lock+Any { ... }
45 * The body of the statment may include statements of the following
49 * action = LockMods(modifiers=NumLock);
51 * - virtual modifier statement:
52 * virtualModifier = NumLock;
57 * - useModMapMods statement:
58 * useModMapMods = level1;
60 * Indicator map statements
61 * ------------------------
62 * Statements of the form:
63 * indicator "Shift Lock" { ... }
65 * This statement specifies the behavior and binding of the indicator
66 * with the given name ("Shift Lock" above). The name should have been
67 * declared previously in the xkb_keycodes section (see Indicator name
68 * statement), and given an index there. If it wasn't, it is created
69 * with the next free index.
70 * The body of the statement describes the conditions of the keyboard
71 * state which will cause the indicator to be lit. It may include the
72 * following statements:
74 * - modifiers statment:
75 * modifiers = ScrollLock;
77 * If the given modifiers are in the required state (see below), the
80 * - whichModifierState statment:
81 * whichModState = Latched + Locked;
83 * Can be any combination of:
84 * base, latched, locked, effective
85 * any (i.e. all of the above)
86 * none (i.e. none of the above)
87 * compat (this is legal, but unused)
88 * This will cause the respective portion of the modifer state (see
89 * struct xkb_state) to be matched against the modifiers given in the
90 * "modifiers" statement.
92 * Here's a simple example:
93 * indicator "Num Lock" {
94 * modifiers = NumLock;
95 * whichModState = Locked;
97 * Whenever the NumLock modifier is locked, the Num Lock indicator
101 * groups = All - group1;
103 * If the given groups are in the required state (see below), the led
106 * - whichGroupState statment:
107 * whichGroupState = Effective;
109 * Can be any combination of:
110 * base, latched, locked, effective
111 * any (i.e. all of the above)
112 * none (i.e. none of the above)
113 * This will cause the respective portion of the group state (see
114 * struct xkb_state) to be matched against the groups given in the
115 * "groups" statement.
117 * Note: the above conditions are disjunctive, i.e. if any of them are
118 * satisfied the led is lit.
120 * Virtual modifier statements
121 * ---------------------------
122 * Statements of the form:
123 * virtual_modifiers LControl;
125 * Can appear in the xkb_types, xkb_compat, xkb_symbols sections.
130 * After all of the xkb_compat sections have been compiled, the following
131 * members of struct xkb_keymap are finalized:
132 * darray(struct xkb_sym_interpret) sym_interpret;
133 * struct xkb_indicator_map indicators[XkbNumIndicators];
134 * char *compat_section_name;
135 * TODO: virtual modifiers.
139 SI_FIELD_VIRTUAL_MOD = (1 << 0),
140 SI_FIELD_ACTION = (1 << 1),
141 SI_FIELD_AUTO_REPEAT = (1 << 2),
142 SI_FIELD_LEVEL_ONE_ONLY = (1 << 3),
145 typedef struct _SymInterpInfo {
146 enum si_field defined;
148 enum merge_mode merge;
150 struct xkb_sym_interpret interp;
154 LED_FIELD_MODS = (1 << 0),
155 LED_FIELD_GROUPS = (1 << 1),
156 LED_FIELD_CTRLS = (1 << 2),
159 typedef struct _LEDInfo {
160 enum led_field defined;
162 enum merge_mode merge;
164 struct xkb_indicator_map im;
167 typedef struct _CompatInfo {
172 darray(SymInterpInfo) interps;
174 darray(LEDInfo) leds;
176 ActionsInfo *actions;
177 struct xkb_keymap *keymap;
181 siText(SymInterpInfo *si, CompatInfo *info)
183 static char buf[128];
185 if (si == &info->dflt)
188 snprintf(buf, sizeof(buf), "%s+%s(%s)",
189 KeysymText(si->interp.sym),
190 SIMatchText(si->interp.match),
191 ModMaskText(si->interp.mods));
196 ReportSINotArray(CompatInfo *info, SymInterpInfo *si, const char *field)
198 return ReportNotArray(info->keymap, "symbol interpretation", field,
203 ReportSIBadType(CompatInfo *info, SymInterpInfo *si, const char *field,
206 return ReportBadType(info->keymap->ctx, "symbol interpretation", field,
207 siText(si, info), wanted);
211 ReportIndicatorBadType(CompatInfo *info, LEDInfo *led,
212 const char *field, const char *wanted)
214 return ReportBadType(info->keymap->ctx, "indicator map", field,
215 xkb_atom_text(info->keymap->ctx, led->im.name),
220 ReportIndicatorNotArray(CompatInfo *info, LEDInfo *led,
223 return ReportNotArray(info->keymap, "indicator map", field,
224 xkb_atom_text(info->keymap->ctx, led->im.name));
228 InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id,
229 ActionsInfo *actions)
231 info->keymap = keymap;
233 info->file_id = file_id;
234 info->errorCount = 0;
235 darray_init(info->interps);
236 info->actions = actions;
237 info->dflt.file_id = file_id;
238 info->dflt.defined = 0;
239 info->dflt.merge = MERGE_OVERRIDE;
240 info->dflt.interp.flags = 0;
241 info->dflt.interp.virtual_mod = XKB_MOD_INVALID;
242 memset(&info->dflt.interp.act, 0, sizeof(info->dflt.interp.act));
243 info->dflt.interp.act.type = XkbSA_NoAction;
244 memset(&info->ledDflt, 0, sizeof(info->ledDflt));
245 info->ledDflt.file_id = file_id;
246 info->ledDflt.merge = MERGE_OVERRIDE;
247 darray_init(info->leds);
248 InitVModInfo(&info->vmods, keymap);
252 ClearCompatInfo(CompatInfo *info)
256 info->dflt.defined = 0;
257 info->dflt.merge = MERGE_AUGMENT;
258 info->dflt.interp.flags = 0;
259 info->dflt.interp.virtual_mod = XKB_MOD_INVALID;
260 memset(&info->dflt.interp.act, 0, sizeof(info->dflt.interp.act));
261 info->dflt.interp.act.type = XkbSA_NoAction;
262 memset(&info->ledDflt, 0, sizeof(info->ledDflt));
263 darray_free(info->interps);
264 darray_free(info->leds);
265 info->actions = NULL;
267 ClearVModInfo(&info->vmods);
270 static SymInterpInfo *
271 FindMatchingInterp(CompatInfo *info, SymInterpInfo *new)
275 darray_foreach(old, info->interps)
276 if (old->interp.sym == new->interp.sym &&
277 old->interp.mods == new->interp.mods &&
278 old->interp.match == new->interp.match)
285 UseNewInterpField(enum si_field field, SymInterpInfo *old, SymInterpInfo *new,
286 bool report, enum si_field *collide)
288 if (!(old->defined & field))
291 if (new->defined & field) {
295 if (new->merge != MERGE_AUGMENT)
303 AddInterp(CompatInfo *info, SymInterpInfo *new)
305 enum si_field collide = 0;
308 old = FindMatchingInterp(info, new);
310 int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
311 bool report = ((old->file_id == new->file_id && verbosity > 0) ||
314 if (new->merge == MERGE_REPLACE) {
316 log_warn(info->keymap->ctx,
317 "Multiple definitions for \"%s\"; "
318 "Earlier interpretation ignored\n",
324 if (UseNewInterpField(SI_FIELD_VIRTUAL_MOD, old, new, report,
326 old->interp.virtual_mod = new->interp.virtual_mod;
327 old->defined |= SI_FIELD_VIRTUAL_MOD;
329 if (UseNewInterpField(SI_FIELD_ACTION, old, new, report,
331 old->interp.act = new->interp.act;
332 old->defined |= SI_FIELD_ACTION;
334 if (UseNewInterpField(SI_FIELD_AUTO_REPEAT, old, new, report,
336 old->interp.flags &= ~XkbSI_AutoRepeat;
337 old->interp.flags |= (new->interp.flags & XkbSI_AutoRepeat);
338 old->defined |= SI_FIELD_AUTO_REPEAT;
340 if (UseNewInterpField(SI_FIELD_LEVEL_ONE_ONLY, old, new, report,
342 old->interp.match &= ~XkbSI_LevelOneOnly;
343 old->interp.match |= (new->interp.match & XkbSI_LevelOneOnly);
344 old->defined |= SI_FIELD_LEVEL_ONE_ONLY;
348 log_warn(info->keymap->ctx,
349 "Multiple interpretations of \"%s\"; "
350 "Using %s definition for duplicate fields\n",
352 (new->merge != MERGE_AUGMENT ? "last" : "first"));
358 darray_append(info->interps, *new);
363 /***====================================================================***/
366 ResolveStateAndPredicate(ExprDef *expr, unsigned *pred_rtrn,
367 xkb_mod_mask_t *mods_rtrn, CompatInfo *info)
370 *pred_rtrn = XkbSI_AnyOfOrNone;
375 *pred_rtrn = XkbSI_Exactly;
376 if (expr->op == EXPR_ACTION_DECL) {
377 const char *pred_txt = xkb_atom_text(info->keymap->ctx,
378 expr->value.action.name);
379 if (!LookupString(symInterpretMatchMaskNames, pred_txt, pred_rtrn)) {
380 log_err(info->keymap->ctx,
381 "Illegal modifier predicate \"%s\"; Ignored\n", pred_txt);
384 expr = expr->value.action.args;
386 else if (expr->op == EXPR_IDENT) {
387 const char *pred_txt = xkb_atom_text(info->keymap->ctx,
389 if (pred_txt && istreq(pred_txt, "any")) {
390 *pred_rtrn = XkbSI_AnyOf;
396 return ExprResolveModMask(info->keymap->ctx, expr, mods_rtrn);
399 /***====================================================================***/
402 UseNewLEDField(enum led_field field, LEDInfo *old, LEDInfo *new,
403 bool report, enum led_field *collide)
405 if (!(old->defined & field))
408 if (new->defined & field) {
412 if (new->merge != MERGE_AUGMENT)
420 AddIndicatorMap(CompatInfo *info, LEDInfo *new)
423 enum led_field collide;
424 struct xkb_context *ctx = info->keymap->ctx;
425 int verbosity = xkb_get_log_verbosity(ctx);
427 darray_foreach(old, info->leds) {
430 if (old->im.name != new->im.name)
433 if (old->im.mods.mods == new->im.mods.mods &&
434 old->im.groups == new->im.groups &&
435 old->im.ctrls == new->im.ctrls &&
436 old->im.which_mods == new->im.which_mods &&
437 old->im.which_groups == new->im.which_groups) {
438 old->defined |= new->defined;
442 report = ((old->file_id == new->file_id && verbosity > 0) ||
445 if (new->merge == MERGE_REPLACE) {
447 log_warn(info->keymap->ctx,
448 "Map for indicator %s redefined; "
449 "Earlier definition ignored\n",
450 xkb_atom_text(ctx, old->im.name));
456 if (UseNewLEDField(LED_FIELD_MODS, old, new, report, &collide)) {
457 old->im.which_mods = new->im.which_mods;
458 old->im.mods = new->im.mods;
459 old->defined |= LED_FIELD_MODS;
461 if (UseNewLEDField(LED_FIELD_GROUPS, old, new, report, &collide)) {
462 old->im.which_groups = new->im.which_groups;
463 old->im.groups = new->im.groups;
464 old->defined |= LED_FIELD_GROUPS;
466 if (UseNewLEDField(LED_FIELD_CTRLS, old, new, report, &collide)) {
467 old->im.ctrls = new->im.ctrls;
468 old->defined |= LED_FIELD_CTRLS;
472 log_warn(info->keymap->ctx,
473 "Map for indicator %s redefined; "
474 "Using %s definition for duplicate fields\n",
475 xkb_atom_text(ctx, old->im.name),
476 (new->merge == MERGE_AUGMENT ? "first" : "last"));
482 darray_append(info->leds, *new);
487 MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
488 enum merge_mode merge)
493 if (from->errorCount > 0) {
494 into->errorCount += from->errorCount;
498 if (into->name == NULL) {
499 into->name = from->name;
503 darray_foreach(si, from->interps) {
504 si->merge = (merge == MERGE_DEFAULT ? si->merge : merge);
505 if (!AddInterp(into, si))
509 darray_foreach(led, from->leds) {
510 led->merge = (merge == MERGE_DEFAULT ? led->merge : merge);
511 if (!AddIndicatorMap(into, led))
517 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge);
520 HandleIncludeCompatMap(CompatInfo *info, IncludeStmt *stmt)
522 enum merge_mode merge = MERGE_DEFAULT;
524 CompatInfo included, next_incl;
526 InitCompatInfo(&included, info->keymap, info->file_id, info->actions);
529 included.name = stmt->stmt;
533 for (; stmt; stmt = stmt->next_incl) {
534 if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_COMPAT,
536 info->errorCount += 10;
537 ClearCompatInfo(&included);
541 InitCompatInfo(&next_incl, info->keymap, rtrn->id, info->actions);
542 next_incl.file_id = rtrn->id;
543 next_incl.dflt = info->dflt;
544 next_incl.dflt.file_id = rtrn->id;
545 next_incl.dflt.merge = merge;
546 next_incl.ledDflt.file_id = rtrn->id;
547 next_incl.ledDflt.merge = merge;
549 HandleCompatMapFile(&next_incl, rtrn, MERGE_OVERRIDE);
551 MergeIncludedCompatMaps(&included, &next_incl, merge);
553 ClearCompatInfo(&next_incl);
557 MergeIncludedCompatMaps(info, &included, merge);
558 ClearCompatInfo(&included);
560 return (info->errorCount == 0);
564 SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
565 ExprDef *arrayNdx, ExprDef *value)
567 struct xkb_keymap *keymap = info->keymap;
570 if (istreq(field, "action")) {
572 return ReportSINotArray(info, si, field);
574 if (!HandleActionDef(value, keymap, &si->interp.act, info->actions))
577 si->defined |= SI_FIELD_ACTION;
579 else if (istreq(field, "virtualmodifier") ||
580 istreq(field, "virtualmod")) {
582 return ReportSINotArray(info, si, field);
584 if (!ResolveVirtualModifier(value, keymap, &ndx, &info->vmods))
585 return ReportSIBadType(info, si, field, "virtual modifier");
587 si->interp.virtual_mod = ndx;
588 si->defined |= SI_FIELD_VIRTUAL_MOD;
590 else if (istreq(field, "repeat")) {
594 return ReportSINotArray(info, si, field);
596 if (!ExprResolveBoolean(keymap->ctx, value, &set))
597 return ReportSIBadType(info, si, field, "boolean");
600 si->interp.flags |= XkbSI_AutoRepeat;
602 si->interp.flags &= ~XkbSI_AutoRepeat;
604 si->defined |= SI_FIELD_AUTO_REPEAT;
606 else if (istreq(field, "locking")) {
607 log_dbg(info->keymap->ctx,
608 "The \"locking\" field in symbol interpretation is unsupported; "
611 else if (istreq(field, "usemodmap") ||
612 istreq(field, "usemodmapmods")) {
616 return ReportSINotArray(info, si, field);
618 if (!ExprResolveEnum(keymap->ctx, value, &val, useModMapValueNames))
619 return ReportSIBadType(info, si, field, "level specification");
622 si->interp.match |= XkbSI_LevelOneOnly;
624 si->interp.match &= ~XkbSI_LevelOneOnly;
626 si->defined |= SI_FIELD_LEVEL_ONE_ONLY;
629 return ReportBadField(keymap, "symbol interpretation", field,
637 SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
638 const char *field, ExprDef *arrayNdx, ExprDef *value)
641 struct xkb_keymap *keymap = info->keymap;
643 if (istreq(field, "modifiers") || istreq(field, "mods")) {
645 return ReportIndicatorNotArray(info, led, field);
647 if (!ExprResolveVModMask(keymap, value, &led->im.mods.mods))
648 return ReportIndicatorBadType(info, led, field, "modifier mask");
650 led->defined |= LED_FIELD_MODS;
652 else if (istreq(field, "groups")) {
656 return ReportIndicatorNotArray(info, led, field);
658 if (!ExprResolveMask(keymap->ctx, value, &mask, groupMaskNames))
659 return ReportIndicatorBadType(info, led, field, "group mask");
661 led->im.groups = mask;
662 led->defined |= LED_FIELD_GROUPS;
664 else if (istreq(field, "controls") || istreq(field, "ctrls")) {
668 return ReportIndicatorNotArray(info, led, field);
670 if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
671 return ReportIndicatorBadType(info, led, field,
674 led->im.ctrls = mask;
675 led->defined |= LED_FIELD_CTRLS;
677 else if (istreq(field, "allowexplicit")) {
678 log_dbg(info->keymap->ctx,
679 "The \"allowExplicit\" field in indicator statements is unsupported; "
682 else if (istreq(field, "whichmodstate") ||
683 istreq(field, "whichmodifierstate")) {
687 return ReportIndicatorNotArray(info, led, field);
689 if (!ExprResolveMask(keymap->ctx, value, &mask,
690 modComponentMaskNames))
691 return ReportIndicatorBadType(info, led, field,
692 "mask of modifier state components");
694 led->im.which_mods = mask;
696 else if (istreq(field, "whichgroupstate")) {
700 return ReportIndicatorNotArray(info, led, field);
702 if (!ExprResolveMask(keymap->ctx, value, &mask,
703 groupComponentMaskNames))
704 return ReportIndicatorBadType(info, led, field,
705 "mask of group state components");
707 led->im.which_groups = mask;
709 else if (istreq(field, "driveskbd") ||
710 istreq(field, "driveskeyboard") ||
711 istreq(field, "leddriveskbd") ||
712 istreq(field, "leddriveskeyboard") ||
713 istreq(field, "indicatordriveskbd") ||
714 istreq(field, "indicatordriveskeyboard")) {
715 log_dbg(info->keymap->ctx,
716 "The \"%s\" field in indicator statements is unsupported; "
719 else if (istreq(field, "index")) {
720 /* Users should see this, it might cause unexpected behavior. */
721 log_err(info->keymap->ctx,
722 "The \"index\" field in indicator statements is unsupported; "
726 log_err(info->keymap->ctx,
727 "Unknown field %s in map for %s indicator; "
728 "Definition ignored\n",
729 field, xkb_atom_text(keymap->ctx, led->im.name));
737 HandleGlobalVar(CompatInfo *info, VarDef *stmt)
739 const char *elem, *field;
743 if (!ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field, &ndx))
745 else if (elem && istreq(elem, "interpret"))
746 ret = SetInterpField(info, &info->dflt, field, ndx, stmt->value);
747 else if (elem && istreq(elem, "indicator"))
748 ret = SetIndicatorMapField(info, &info->ledDflt, field, ndx,
751 ret = SetActionField(info->keymap, elem, field, ndx, stmt->value,
757 HandleInterpBody(CompatInfo *info, VarDef *def, SymInterpInfo *si)
760 const char *elem, *field;
763 for (; def; def = (VarDef *) def->common.next) {
764 if (def->name && def->name->op == EXPR_FIELD_REF) {
765 log_err(info->keymap->ctx,
766 "Cannot set a global default value from within an interpret statement; "
767 "Move statements to the global file scope\n");
772 ok = ExprResolveLhs(info->keymap->ctx, def->name, &elem, &field,
777 ok = SetInterpField(info, si, field, arrayNdx, def->value);
784 HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
789 if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) {
790 log_err(info->keymap->ctx,
791 "Couldn't determine matching modifiers; "
792 "Symbol interpretation ignored\n");
798 si.merge = merge = (def->merge == MERGE_DEFAULT ? merge : def->merge);
800 if (!LookupKeysym(def->sym, &si.interp.sym)) {
801 log_err(info->keymap->ctx,
802 "Could not resolve keysym %s; "
803 "Symbol interpretation ignored\n",
808 si.interp.match = pred & XkbSI_OpMask;
810 si.interp.mods = mods;
812 if (!HandleInterpBody(info, def->def, &si)) {
817 if (!AddInterp(info, &si)) {
826 HandleIndicatorMapDef(CompatInfo *info, IndicatorMapDef *def,
827 enum merge_mode merge)
833 if (def->merge != MERGE_DEFAULT)
838 led.im.name = def->name;
841 for (var = def->body; var != NULL; var = (VarDef *) var->common.next) {
842 const char *elem, *field;
844 if (!ExprResolveLhs(info->keymap->ctx, var->name, &elem, &field,
851 log_err(info->keymap->ctx,
852 "Cannot set defaults for \"%s\" element in indicator map; "
853 "Assignment to %s.%s ignored\n", elem, elem, field);
857 ok = SetIndicatorMapField(info, &led, field, arrayNdx,
863 return AddIndicatorMap(info, &led);
869 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
874 merge = (merge == MERGE_DEFAULT ? MERGE_AUGMENT : merge);
877 info->name = strdup_safe(file->name);
879 for (stmt = file->defs; stmt; stmt = stmt->next) {
880 switch (stmt->type) {
882 ok = HandleIncludeCompatMap(info, (IncludeStmt *) stmt);
885 ok = HandleInterpDef(info, (InterpDef *) stmt, merge);
887 case STMT_GROUP_COMPAT:
888 log_dbg(info->keymap->ctx,
889 "The \"group\" statement in compat is unsupported; "
893 case STMT_INDICATOR_MAP:
894 ok = HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge);
897 ok = HandleGlobalVar(info, (VarDef *) stmt);
900 ok = HandleVModDef((VModDef *) stmt, info->keymap, merge,
904 log_err(info->keymap->ctx,
905 "Interpretation files may not include other types; "
906 "Ignoring %s\n", stmt_type_to_string(stmt->type));
914 if (info->errorCount > 10) {
915 log_err(info->keymap->ctx,
916 "Abandoning compatibility map \"%s\"\n", file->topName);
923 CopyInterps(CompatInfo *info, bool needSymbol, unsigned pred)
927 darray_foreach(si, info->interps) {
928 if (((si->interp.match & XkbSI_OpMask) != pred) ||
929 (needSymbol && si->interp.sym == XKB_KEY_NoSymbol) ||
930 (!needSymbol && si->interp.sym != XKB_KEY_NoSymbol))
933 darray_append(info->keymap->sym_interpret, si->interp);
938 CopyIndicatorMapDefs(CompatInfo *info)
942 struct xkb_indicator_map *im;
943 struct xkb_keymap *keymap = info->keymap;
945 darray_foreach(led, info->leds) {
947 * Find the indicator with the given name, if it was already
948 * declared in keycodes.
950 for (i = 0; i < XkbNumIndicators; i++)
951 if (keymap->indicators[i].name == led->im.name)
954 /* Not previously declared; create it with next free index. */
955 if (i >= XkbNumIndicators) {
957 "Indicator name \"%s\" was not declared in the keycodes section; "
958 "Adding new indicator\n",
959 xkb_atom_text(keymap->ctx, led->im.name));
961 for (i = 0; i < XkbNumIndicators; i++)
962 if (keymap->indicators[i].name == XKB_ATOM_NONE)
965 /* Not place to put it; ignore. */
966 if (i >= XkbNumIndicators) {
968 "Too many indicators (maximum is %d); "
969 "Indicator name \"%s\" ignored\n",
971 xkb_atom_text(keymap->ctx, led->im.name));
976 im = &keymap->indicators[i];
978 if (im->groups != 0 && im->which_groups == 0)
979 im->which_groups = XkbIM_UseEffective;
980 if (im->mods.mods != 0 && im->which_mods == 0)
981 im->which_mods = XkbIM_UseEffective;
986 CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
988 keymap->compat_section_name = strdup_safe(info->name);
990 if (!darray_empty(info->interps)) {
991 /* Most specific to least specific. */
992 CopyInterps(info, true, XkbSI_Exactly);
993 CopyInterps(info, true, XkbSI_AllOf | XkbSI_NoneOf);
994 CopyInterps(info, true, XkbSI_AnyOf);
995 CopyInterps(info, true, XkbSI_AnyOfOrNone);
996 CopyInterps(info, false, XkbSI_Exactly);
997 CopyInterps(info, false, XkbSI_AllOf | XkbSI_NoneOf);
998 CopyInterps(info, false, XkbSI_AnyOf);
999 CopyInterps(info, false, XkbSI_AnyOfOrNone);
1002 CopyIndicatorMapDefs(info);
1008 CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
1009 enum merge_mode merge)
1012 ActionsInfo *actions;
1014 actions = NewActionsInfo();
1018 InitCompatInfo(&info, keymap, file->id, actions);
1019 info.dflt.merge = merge;
1020 info.ledDflt.merge = merge;
1022 HandleCompatMapFile(&info, file, merge);
1023 if (info.errorCount != 0)
1026 if (!CopyCompatToKeymap(keymap, &info))
1029 ClearCompatInfo(&info);
1030 FreeActionsInfo(actions);
1034 ClearCompatInfo(&info);
1035 FreeActionsInfo(actions);