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.
52 #include "xkbcomp-priv.h"
60 SI_FIELD_VIRTUAL_MOD = (1 << 0),
61 SI_FIELD_ACTION = (1 << 1),
62 SI_FIELD_AUTO_REPEAT = (1 << 2),
63 SI_FIELD_LEVEL_ONE_ONLY = (1 << 3),
67 enum si_field defined;
68 enum merge_mode merge;
70 struct xkb_sym_interpret interp;
74 LED_FIELD_MODS = (1 << 0),
75 LED_FIELD_GROUPS = (1 << 1),
76 LED_FIELD_CTRLS = (1 << 2),
80 enum led_field defined;
81 enum merge_mode merge;
89 SymInterpInfo default_interp;
90 darray(SymInterpInfo) interps;
92 LedInfo leds[XKB_MAX_LEDS];
93 unsigned int num_leds;
95 struct xkb_mod_set mods;
97 struct xkb_context *ctx;
101 siText(SymInterpInfo *si, CompatInfo *info)
103 char *buf = xkb_context_get_buffer(info->ctx, 128);
105 if (si == &info->default_interp)
108 snprintf(buf, 128, "%s+%s(%s)",
109 KeysymText(info->ctx, si->interp.sym),
110 SIMatchText(si->interp.match),
111 ModMaskText(info->ctx, &info->mods, si->interp.mods));
117 ReportSINotArray(CompatInfo *info, SymInterpInfo *si, const char *field)
119 return ReportNotArray(info->ctx, "symbol interpretation", field,
124 ReportSIBadType(CompatInfo *info, SymInterpInfo *si, const char *field,
127 return ReportBadType(info->ctx, XKB_ERROR_WRONG_FIELD_TYPE,
128 "symbol interpretation", field,
129 siText(si, info), wanted);
133 ReportLedBadType(CompatInfo *info, LedInfo *ledi, const char *field,
136 return ReportBadType(info->ctx, XKB_ERROR_WRONG_FIELD_TYPE,
137 "indicator map", field,
138 xkb_atom_text(info->ctx, ledi->led.name),
143 ReportLedNotArray(CompatInfo *info, LedInfo *ledi, const char *field)
145 return ReportNotArray(info->ctx, "indicator map", field,
146 xkb_atom_text(info->ctx, ledi->led.name));
150 InitCompatInfo(CompatInfo *info, struct xkb_context *ctx,
151 ActionsInfo *actions, const struct xkb_mod_set *mods)
153 memset(info, 0, sizeof(*info));
155 info->actions = actions;
157 info->default_interp.merge = MERGE_OVERRIDE;
158 info->default_interp.interp.virtual_mod = XKB_MOD_INVALID;
159 info->default_led.merge = MERGE_OVERRIDE;
163 ClearCompatInfo(CompatInfo *info)
166 darray_free(info->interps);
169 static SymInterpInfo *
170 FindMatchingInterp(CompatInfo *info, SymInterpInfo *new)
174 darray_foreach(old, info->interps)
175 if (old->interp.sym == new->interp.sym &&
176 old->interp.mods == new->interp.mods &&
177 old->interp.match == new->interp.match)
184 UseNewInterpField(enum si_field field, SymInterpInfo *old, SymInterpInfo *new,
185 bool report, enum si_field *collide)
187 if (!(old->defined & field))
190 if (new->defined & field) {
194 if (new->merge != MERGE_AUGMENT)
202 AddInterp(CompatInfo *info, SymInterpInfo *new, bool same_file)
204 SymInterpInfo *old = FindMatchingInterp(info, new);
206 const int verbosity = xkb_context_get_log_verbosity(info->ctx);
207 const bool report = (same_file && verbosity > 0) || verbosity > 9;
208 enum si_field collide = 0;
210 if (new->merge == MERGE_REPLACE) {
212 log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID,
213 "Multiple definitions for \"%s\"; "
214 "Earlier interpretation ignored\n",
220 if (UseNewInterpField(SI_FIELD_VIRTUAL_MOD, old, new, report,
222 old->interp.virtual_mod = new->interp.virtual_mod;
223 old->defined |= SI_FIELD_VIRTUAL_MOD;
225 if (UseNewInterpField(SI_FIELD_ACTION, old, new, report,
227 old->interp.action = new->interp.action;
228 old->defined |= SI_FIELD_ACTION;
230 if (UseNewInterpField(SI_FIELD_AUTO_REPEAT, old, new, report,
232 old->interp.repeat = new->interp.repeat;
233 old->defined |= SI_FIELD_AUTO_REPEAT;
235 if (UseNewInterpField(SI_FIELD_LEVEL_ONE_ONLY, old, new, report,
237 old->interp.level_one_only = new->interp.level_one_only;
238 old->defined |= SI_FIELD_LEVEL_ONE_ONLY;
242 log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID,
243 "Multiple interpretations of \"%s\"; "
244 "Using %s definition for duplicate fields\n",
246 (new->merge != MERGE_AUGMENT ? "last" : "first"));
252 darray_append(info->interps, *new);
256 /***====================================================================***/
259 ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn,
260 xkb_mod_mask_t *mods_rtrn, CompatInfo *info)
263 *pred_rtrn = MATCH_ANY_OR_NONE;
264 *mods_rtrn = MOD_REAL_MASK_ALL;
268 *pred_rtrn = MATCH_EXACTLY;
269 if (expr->expr.op == EXPR_ACTION_DECL) {
270 const char *pred_txt = xkb_atom_text(info->ctx, expr->action.name);
271 if (!LookupString(symInterpretMatchMaskNames, pred_txt, pred_rtrn) ||
272 !expr->action.args || expr->action.args->common.next) {
273 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
274 "Illegal modifier predicate \"%s\"; Ignored\n", pred_txt);
277 expr = expr->action.args;
279 else if (expr->expr.op == EXPR_IDENT) {
280 const char *pred_txt = xkb_atom_text(info->ctx, expr->ident.ident);
281 if (pred_txt && istreq(pred_txt, "any")) {
282 *pred_rtrn = MATCH_ANY;
283 *mods_rtrn = MOD_REAL_MASK_ALL;
288 return ExprResolveModMask(info->ctx, expr, MOD_REAL, &info->mods,
292 /***====================================================================***/
295 UseNewLEDField(enum led_field field, LedInfo *old, LedInfo *new,
296 bool report, enum led_field *collide)
298 if (!(old->defined & field))
301 if (new->defined & field) {
305 if (new->merge != MERGE_AUGMENT)
313 AddLedMap(CompatInfo *info, LedInfo *new, bool same_file)
315 enum led_field collide;
316 const int verbosity = xkb_context_get_log_verbosity(info->ctx);
317 const bool report = (same_file && verbosity > 0) || verbosity > 9;
319 for (xkb_led_index_t i = 0; i < info->num_leds; i++) {
320 LedInfo *old = &info->leds[i];
322 if (old->led.name != new->led.name)
325 if (old->led.mods.mods == new->led.mods.mods &&
326 old->led.groups == new->led.groups &&
327 old->led.ctrls == new->led.ctrls &&
328 old->led.which_mods == new->led.which_mods &&
329 old->led.which_groups == new->led.which_groups) {
330 old->defined |= new->defined;
334 if (new->merge == MERGE_REPLACE) {
336 log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID,
337 "Map for indicator %s redefined; "
338 "Earlier definition ignored\n",
339 xkb_atom_text(info->ctx, old->led.name));
345 if (UseNewLEDField(LED_FIELD_MODS, old, new, report, &collide)) {
346 old->led.which_mods = new->led.which_mods;
347 old->led.mods = new->led.mods;
348 old->defined |= LED_FIELD_MODS;
350 if (UseNewLEDField(LED_FIELD_GROUPS, old, new, report, &collide)) {
351 old->led.which_groups = new->led.which_groups;
352 old->led.groups = new->led.groups;
353 old->defined |= LED_FIELD_GROUPS;
355 if (UseNewLEDField(LED_FIELD_CTRLS, old, new, report, &collide)) {
356 old->led.ctrls = new->led.ctrls;
357 old->defined |= LED_FIELD_CTRLS;
361 log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID,
362 "Map for indicator %s redefined; "
363 "Using %s definition for duplicate fields\n",
364 xkb_atom_text(info->ctx, old->led.name),
365 (new->merge == MERGE_AUGMENT ? "first" : "last"));
371 if (info->num_leds >= XKB_MAX_LEDS) {
372 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
373 "Too many LEDs defined (maximum %d)\n",
377 info->leds[info->num_leds++] = *new;
382 MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
383 enum merge_mode merge)
385 if (from->errorCount > 0) {
386 into->errorCount += from->errorCount;
390 into->mods = from->mods;
392 if (into->name == NULL) {
393 into->name = from->name;
397 if (darray_empty(into->interps)) {
398 into->interps = from->interps;
399 darray_init(from->interps);
403 darray_foreach(si, from->interps) {
404 si->merge = (merge == MERGE_DEFAULT ? si->merge : merge);
405 if (!AddInterp(into, si, false))
410 if (into->num_leds == 0) {
411 memcpy(into->leds, from->leds, sizeof(*from->leds) * from->num_leds);
412 into->num_leds = from->num_leds;
416 for (xkb_led_index_t i = 0; i < from->num_leds; i++) {
417 LedInfo *ledi = &from->leds[i];
418 ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge);
419 if (!AddLedMap(into, ledi, false))
426 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge);
429 HandleIncludeCompatMap(CompatInfo *info, IncludeStmt *include)
433 InitCompatInfo(&included, info->ctx, info->actions, &info->mods);
434 included.name = include->stmt;
435 include->stmt = NULL;
437 for (IncludeStmt *stmt = include; stmt; stmt = stmt->next_incl) {
438 CompatInfo next_incl;
441 file = ProcessIncludeFile(info->ctx, stmt, FILE_TYPE_COMPAT);
443 info->errorCount += 10;
444 ClearCompatInfo(&included);
448 InitCompatInfo(&next_incl, info->ctx, info->actions, &included.mods);
449 next_incl.default_interp = info->default_interp;
450 next_incl.default_interp.merge = stmt->merge;
451 next_incl.default_led = info->default_led;
452 next_incl.default_led.merge = stmt->merge;
454 HandleCompatMapFile(&next_incl, file, MERGE_OVERRIDE);
456 MergeIncludedCompatMaps(&included, &next_incl, stmt->merge);
458 ClearCompatInfo(&next_incl);
462 MergeIncludedCompatMaps(info, &included, include->merge);
463 ClearCompatInfo(&included);
465 return (info->errorCount == 0);
469 SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
470 ExprDef *arrayNdx, ExprDef *value)
474 if (istreq(field, "action")) {
476 return ReportSINotArray(info, si, field);
478 if (!HandleActionDef(info->ctx, info->actions, &info->mods,
479 value, &si->interp.action))
482 si->defined |= SI_FIELD_ACTION;
484 else if (istreq(field, "virtualmodifier") ||
485 istreq(field, "virtualmod")) {
487 return ReportSINotArray(info, si, field);
489 if (!ExprResolveMod(info->ctx, value, MOD_VIRT, &info->mods, &ndx))
490 return ReportSIBadType(info, si, field, "virtual modifier");
492 si->interp.virtual_mod = ndx;
493 si->defined |= SI_FIELD_VIRTUAL_MOD;
495 else if (istreq(field, "repeat")) {
499 return ReportSINotArray(info, si, field);
501 if (!ExprResolveBoolean(info->ctx, value, &set))
502 return ReportSIBadType(info, si, field, "boolean");
504 si->interp.repeat = set;
506 si->defined |= SI_FIELD_AUTO_REPEAT;
508 else if (istreq(field, "locking")) {
509 log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID,
510 "The \"locking\" field in symbol interpretation is unsupported; "
513 else if (istreq(field, "usemodmap") ||
514 istreq(field, "usemodmapmods")) {
518 return ReportSINotArray(info, si, field);
520 if (!ExprResolveEnum(info->ctx, value, &val, useModMapValueNames))
521 return ReportSIBadType(info, si, field, "level specification");
523 si->interp.level_one_only = val;
524 si->defined |= SI_FIELD_LEVEL_ONE_ONLY;
527 return ReportBadField(info->ctx, "symbol interpretation", field,
535 SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field,
536 ExprDef *arrayNdx, ExprDef *value)
540 if (istreq(field, "modifiers") || istreq(field, "mods")) {
542 return ReportLedNotArray(info, ledi, field);
544 if (!ExprResolveModMask(info->ctx, value, MOD_BOTH,
545 &info->mods, &ledi->led.mods.mods))
546 return ReportLedBadType(info, ledi, field, "modifier mask");
548 ledi->defined |= LED_FIELD_MODS;
550 else if (istreq(field, "groups")) {
554 return ReportLedNotArray(info, ledi, field);
556 if (!ExprResolveMask(info->ctx, value, &mask, groupMaskNames))
557 return ReportLedBadType(info, ledi, field, "group mask");
559 ledi->led.groups = mask;
560 ledi->defined |= LED_FIELD_GROUPS;
562 else if (istreq(field, "controls") || istreq(field, "ctrls")) {
566 return ReportLedNotArray(info, ledi, field);
568 if (!ExprResolveMask(info->ctx, value, &mask, ctrlMaskNames))
569 return ReportLedBadType(info, ledi, field, "controls mask");
571 ledi->led.ctrls = mask;
572 ledi->defined |= LED_FIELD_CTRLS;
574 else if (istreq(field, "allowexplicit")) {
575 log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID,
576 "The \"allowExplicit\" field in indicator statements is unsupported; "
579 else if (istreq(field, "whichmodstate") ||
580 istreq(field, "whichmodifierstate")) {
584 return ReportLedNotArray(info, ledi, field);
586 if (!ExprResolveMask(info->ctx, value, &mask,
587 modComponentMaskNames))
588 return ReportLedBadType(info, ledi, field,
589 "mask of modifier state components");
591 ledi->led.which_mods = mask;
593 else if (istreq(field, "whichgroupstate")) {
597 return ReportLedNotArray(info, ledi, field);
599 if (!ExprResolveMask(info->ctx, value, &mask,
600 groupComponentMaskNames))
601 return ReportLedBadType(info, ledi, field,
602 "mask of group state components");
604 ledi->led.which_groups = mask;
606 else if (istreq(field, "driveskbd") ||
607 istreq(field, "driveskeyboard") ||
608 istreq(field, "leddriveskbd") ||
609 istreq(field, "leddriveskeyboard") ||
610 istreq(field, "indicatordriveskbd") ||
611 istreq(field, "indicatordriveskeyboard")) {
612 log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID,
613 "The \"%s\" field in indicator statements is unsupported; "
616 else if (istreq(field, "index")) {
617 /* Users should see this, it might cause unexpected behavior. */
618 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
619 "The \"index\" field in indicator statements is unsupported; "
623 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
624 "Unknown field %s in map for %s indicator; "
625 "Definition ignored\n",
626 field, xkb_atom_text(info->ctx, ledi->led.name));
634 HandleGlobalVar(CompatInfo *info, VarDef *stmt)
636 const char *elem, *field;
640 if (!ExprResolveLhs(info->ctx, stmt->name, &elem, &field, &ndx))
642 else if (elem && istreq(elem, "interpret"))
643 ret = SetInterpField(info, &info->default_interp, field, ndx,
645 else if (elem && istreq(elem, "indicator"))
646 ret = SetLedMapField(info, &info->default_led, field, ndx,
649 ret = SetActionField(info->ctx, info->actions, &info->mods,
650 elem, field, ndx, stmt->value);
655 HandleInterpBody(CompatInfo *info, VarDef *def, SymInterpInfo *si)
658 const char *elem, *field;
661 for (; def; def = (VarDef *) def->common.next) {
662 if (def->name && def->name->expr.op == EXPR_FIELD_REF) {
663 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
664 "Cannot set a global default value from within an interpret statement; "
665 "Move statements to the global file scope\n");
670 ok = ExprResolveLhs(info->ctx, def->name, &elem, &field, &arrayNdx);
674 ok = SetInterpField(info, si, field, arrayNdx, def->value);
681 HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
683 enum xkb_match_operation pred;
687 if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) {
688 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
689 "Couldn't determine matching modifiers; "
690 "Symbol interpretation ignored\n");
694 si = info->default_interp;
695 si.merge = (def->merge == MERGE_DEFAULT ? merge : def->merge);
696 si.interp.sym = def->sym;
697 si.interp.match = pred;
698 si.interp.mods = mods;
700 if (!HandleInterpBody(info, def->def, &si)) {
705 if (!AddInterp(info, &si, true)) {
714 HandleLedMapDef(CompatInfo *info, LedMapDef *def, enum merge_mode merge)
720 if (def->merge != MERGE_DEFAULT)
723 ledi = info->default_led;
725 ledi.led.name = def->name;
728 for (var = def->body; var != NULL; var = (VarDef *) var->common.next) {
729 const char *elem, *field;
731 if (!ExprResolveLhs(info->ctx, var->name, &elem, &field, &arrayNdx)) {
737 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
738 "Cannot set defaults for \"%s\" element in indicator map; "
739 "Assignment to %s.%s ignored\n", elem, elem, field);
743 ok = SetLedMapField(info, &ledi, field, arrayNdx, var->value) && ok;
748 return AddLedMap(info, &ledi, true);
754 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
758 merge = (merge == MERGE_DEFAULT ? MERGE_AUGMENT : merge);
761 info->name = strdup_safe(file->name);
763 for (ParseCommon *stmt = file->defs; stmt; stmt = stmt->next) {
764 switch (stmt->type) {
766 ok = HandleIncludeCompatMap(info, (IncludeStmt *) stmt);
769 ok = HandleInterpDef(info, (InterpDef *) stmt, merge);
771 case STMT_GROUP_COMPAT:
772 log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID,
773 "The \"group\" statement in compat is unsupported; "
778 ok = HandleLedMapDef(info, (LedMapDef *) stmt, merge);
781 ok = HandleGlobalVar(info, (VarDef *) stmt);
784 ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge);
787 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
788 "Compat files may not include other types; "
789 "Ignoring %s\n", stmt_type_to_string(stmt->type));
797 if (info->errorCount > 10) {
798 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
799 "Abandoning compatibility map \"%s\"\n", file->name);
805 /* Temporary struct for CopyInterps. */
807 darray(struct xkb_sym_interpret) sym_interprets;
811 CopyInterps(CompatInfo *info, bool needSymbol, enum xkb_match_operation pred,
812 struct collect *collect)
816 darray_foreach(si, info->interps)
817 if (si->interp.match == pred &&
818 (si->interp.sym != XKB_KEY_NoSymbol) == needSymbol)
819 darray_append(collect->sym_interprets, si->interp);
823 CopyLedMapDefsToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
825 for (xkb_led_index_t idx = 0; idx < info->num_leds; idx++) {
826 LedInfo *ledi = &info->leds[idx];
831 * Find the LED with the given name, if it was already declared
834 xkb_leds_enumerate(i, led, keymap)
835 if (led->name == ledi->led.name)
838 /* Not previously declared; create it with next free index. */
839 if (i >= keymap->num_leds) {
840 log_dbg(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
841 "Indicator name \"%s\" was not declared in the keycodes section; "
842 "Adding new indicator\n",
843 xkb_atom_text(keymap->ctx, ledi->led.name));
845 xkb_leds_enumerate(i, led, keymap)
846 if (led->name == XKB_ATOM_NONE)
849 if (i >= keymap->num_leds) {
850 /* Not place to put it; ignore. */
851 if (i >= XKB_MAX_LEDS) {
852 log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
853 "Too many indicators (maximum is %d); "
854 "Indicator name \"%s\" ignored\n",
856 xkb_atom_text(keymap->ctx, ledi->led.name));
861 led = &keymap->leds[keymap->num_leds++];
866 if (led->groups != 0 && led->which_groups == 0)
867 led->which_groups = XKB_STATE_LAYOUT_EFFECTIVE;
868 if (led->mods.mods != 0 && led->which_mods == 0)
869 led->which_mods = XKB_STATE_MODS_EFFECTIVE;
874 CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
876 keymap->compat_section_name = strdup_safe(info->name);
877 XkbEscapeMapName(keymap->compat_section_name);
879 keymap->mods = info->mods;
881 if (!darray_empty(info->interps)) {
882 struct collect collect;
883 darray_init(collect.sym_interprets);
885 /* Most specific to least specific. */
886 CopyInterps(info, true, MATCH_EXACTLY, &collect);
887 CopyInterps(info, true, MATCH_ALL, &collect);
888 CopyInterps(info, true, MATCH_NONE, &collect);
889 CopyInterps(info, true, MATCH_ANY, &collect);
890 CopyInterps(info, true, MATCH_ANY_OR_NONE, &collect);
891 CopyInterps(info, false, MATCH_EXACTLY, &collect);
892 CopyInterps(info, false, MATCH_ALL, &collect);
893 CopyInterps(info, false, MATCH_NONE, &collect);
894 CopyInterps(info, false, MATCH_ANY, &collect);
895 CopyInterps(info, false, MATCH_ANY_OR_NONE, &collect);
897 darray_steal(collect.sym_interprets,
898 &keymap->sym_interprets, &keymap->num_sym_interprets);
901 CopyLedMapDefsToKeymap(keymap, info);
907 CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
908 enum merge_mode merge)
911 ActionsInfo *actions;
913 actions = NewActionsInfo();
917 InitCompatInfo(&info, keymap->ctx, actions, &keymap->mods);
918 info.default_interp.merge = merge;
919 info.default_led.merge = merge;
921 HandleCompatMapFile(&info, file, merge);
922 if (info.errorCount != 0)
925 if (!CopyCompatToKeymap(keymap, &info))
928 ClearCompatInfo(&info);
929 FreeActionsInfo(actions);
933 ClearCompatInfo(&info);
934 FreeActionsInfo(actions);