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)
436 InitCompatInfo(&included, info->ctx, info->actions, &info->mods);
437 included.name = include->stmt;
438 include->stmt = NULL;
440 for (IncludeStmt *stmt = include; stmt; stmt = stmt->next_incl) {
441 CompatInfo next_incl;
444 file = ProcessIncludeFile(info->ctx, stmt, FILE_TYPE_COMPAT);
446 info->errorCount += 10;
447 ClearCompatInfo(&included);
451 InitCompatInfo(&next_incl, info->ctx, info->actions, &included.mods);
452 next_incl.default_interp = info->default_interp;
453 next_incl.default_interp.merge = stmt->merge;
454 next_incl.default_led = info->default_led;
455 next_incl.default_led.merge = stmt->merge;
457 HandleCompatMapFile(&next_incl, file, MERGE_OVERRIDE);
459 MergeIncludedCompatMaps(&included, &next_incl, stmt->merge);
461 ClearCompatInfo(&next_incl);
465 MergeIncludedCompatMaps(info, &included, include->merge);
466 ClearCompatInfo(&included);
468 return (info->errorCount == 0);
472 SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
473 ExprDef *arrayNdx, ExprDef *value)
477 if (istreq(field, "action")) {
479 return ReportSINotArray(info, si, field);
481 if (!HandleActionDef(info->ctx, info->actions, &info->mods,
482 value, &si->interp.action))
485 si->defined |= SI_FIELD_ACTION;
487 else if (istreq(field, "virtualmodifier") ||
488 istreq(field, "virtualmod")) {
490 return ReportSINotArray(info, si, field);
492 if (!ExprResolveMod(info->ctx, value, MOD_VIRT, &info->mods, &ndx))
493 return ReportSIBadType(info, si, field, "virtual modifier");
495 si->interp.virtual_mod = ndx;
496 si->defined |= SI_FIELD_VIRTUAL_MOD;
498 else if (istreq(field, "repeat")) {
502 return ReportSINotArray(info, si, field);
504 if (!ExprResolveBoolean(info->ctx, value, &set))
505 return ReportSIBadType(info, si, field, "boolean");
507 si->interp.repeat = set;
509 si->defined |= SI_FIELD_AUTO_REPEAT;
511 else if (istreq(field, "locking")) {
512 log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID,
513 "The \"locking\" field in symbol interpretation is unsupported; "
516 else if (istreq(field, "usemodmap") ||
517 istreq(field, "usemodmapmods")) {
521 return ReportSINotArray(info, si, field);
523 if (!ExprResolveEnum(info->ctx, value, &val, useModMapValueNames))
524 return ReportSIBadType(info, si, field, "level specification");
526 si->interp.level_one_only = val;
527 si->defined |= SI_FIELD_LEVEL_ONE_ONLY;
530 return ReportBadField(info->ctx, "symbol interpretation", field,
538 SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field,
539 ExprDef *arrayNdx, ExprDef *value)
543 if (istreq(field, "modifiers") || istreq(field, "mods")) {
545 return ReportLedNotArray(info, ledi, field);
547 if (!ExprResolveModMask(info->ctx, value, MOD_BOTH,
548 &info->mods, &ledi->led.mods.mods))
549 return ReportLedBadType(info, ledi, field, "modifier mask");
551 ledi->defined |= LED_FIELD_MODS;
553 else if (istreq(field, "groups")) {
557 return ReportLedNotArray(info, ledi, field);
559 if (!ExprResolveMask(info->ctx, value, &mask, groupMaskNames))
560 return ReportLedBadType(info, ledi, field, "group mask");
562 ledi->led.groups = mask;
563 ledi->defined |= LED_FIELD_GROUPS;
565 else if (istreq(field, "controls") || istreq(field, "ctrls")) {
569 return ReportLedNotArray(info, ledi, field);
571 if (!ExprResolveMask(info->ctx, value, &mask, ctrlMaskNames))
572 return ReportLedBadType(info, ledi, field, "controls mask");
574 ledi->led.ctrls = mask;
575 ledi->defined |= LED_FIELD_CTRLS;
577 else if (istreq(field, "allowexplicit")) {
578 log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID,
579 "The \"allowExplicit\" field in indicator statements is unsupported; "
582 else if (istreq(field, "whichmodstate") ||
583 istreq(field, "whichmodifierstate")) {
587 return ReportLedNotArray(info, ledi, field);
589 if (!ExprResolveMask(info->ctx, value, &mask,
590 modComponentMaskNames))
591 return ReportLedBadType(info, ledi, field,
592 "mask of modifier state components");
594 ledi->led.which_mods = mask;
596 else if (istreq(field, "whichgroupstate")) {
600 return ReportLedNotArray(info, ledi, field);
602 if (!ExprResolveMask(info->ctx, value, &mask,
603 groupComponentMaskNames))
604 return ReportLedBadType(info, ledi, field,
605 "mask of group state components");
607 ledi->led.which_groups = mask;
609 else if (istreq(field, "driveskbd") ||
610 istreq(field, "driveskeyboard") ||
611 istreq(field, "leddriveskbd") ||
612 istreq(field, "leddriveskeyboard") ||
613 istreq(field, "indicatordriveskbd") ||
614 istreq(field, "indicatordriveskeyboard")) {
615 log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID,
616 "The \"%s\" field in indicator statements is unsupported; "
619 else if (istreq(field, "index")) {
620 /* Users should see this, it might cause unexpected behavior. */
621 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
622 "The \"index\" field in indicator statements is unsupported; "
626 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
627 "Unknown field %s in map for %s indicator; "
628 "Definition ignored\n",
629 field, xkb_atom_text(info->ctx, ledi->led.name));
637 HandleGlobalVar(CompatInfo *info, VarDef *stmt)
639 const char *elem, *field;
643 if (!ExprResolveLhs(info->ctx, stmt->name, &elem, &field, &ndx))
645 else if (elem && istreq(elem, "interpret"))
646 ret = SetInterpField(info, &info->default_interp, field, ndx,
648 else if (elem && istreq(elem, "indicator"))
649 ret = SetLedMapField(info, &info->default_led, field, ndx,
652 ret = SetActionField(info->ctx, info->actions, &info->mods,
653 elem, field, ndx, stmt->value);
658 HandleInterpBody(CompatInfo *info, VarDef *def, SymInterpInfo *si)
661 const char *elem, *field;
664 for (; def; def = (VarDef *) def->common.next) {
665 if (def->name && def->name->expr.op == EXPR_FIELD_REF) {
666 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
667 "Cannot set a global default value from within an interpret statement; "
668 "Move statements to the global file scope\n");
673 ok = ExprResolveLhs(info->ctx, def->name, &elem, &field, &arrayNdx);
677 ok = SetInterpField(info, si, field, arrayNdx, def->value);
684 HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
686 enum xkb_match_operation pred;
690 if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) {
691 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
692 "Couldn't determine matching modifiers; "
693 "Symbol interpretation ignored\n");
697 si = info->default_interp;
698 si.merge = (def->merge == MERGE_DEFAULT ? merge : def->merge);
699 si.interp.sym = def->sym;
700 si.interp.match = pred;
701 si.interp.mods = mods;
703 if (!HandleInterpBody(info, def->def, &si)) {
708 if (!AddInterp(info, &si, true)) {
717 HandleLedMapDef(CompatInfo *info, LedMapDef *def, enum merge_mode merge)
723 if (def->merge != MERGE_DEFAULT)
726 ledi = info->default_led;
728 ledi.led.name = def->name;
731 for (var = def->body; var != NULL; var = (VarDef *) var->common.next) {
732 const char *elem, *field;
734 if (!ExprResolveLhs(info->ctx, var->name, &elem, &field, &arrayNdx)) {
740 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
741 "Cannot set defaults for \"%s\" element in indicator map; "
742 "Assignment to %s.%s ignored\n", elem, elem, field);
746 ok = SetLedMapField(info, &ledi, field, arrayNdx, var->value) && ok;
751 return AddLedMap(info, &ledi, true);
757 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
761 merge = (merge == MERGE_DEFAULT ? MERGE_AUGMENT : merge);
764 info->name = strdup_safe(file->name);
766 for (ParseCommon *stmt = file->defs; stmt; stmt = stmt->next) {
767 switch (stmt->type) {
769 ok = HandleIncludeCompatMap(info, (IncludeStmt *) stmt);
772 ok = HandleInterpDef(info, (InterpDef *) stmt, merge);
774 case STMT_GROUP_COMPAT:
775 log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID,
776 "The \"group\" statement in compat is unsupported; "
781 ok = HandleLedMapDef(info, (LedMapDef *) stmt, merge);
784 ok = HandleGlobalVar(info, (VarDef *) stmt);
787 ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge);
790 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
791 "Compat files may not include other types; "
792 "Ignoring %s\n", stmt_type_to_string(stmt->type));
800 if (info->errorCount > 10) {
801 log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID,
802 "Abandoning compatibility map \"%s\"\n", file->name);
808 /* Temporary struct for CopyInterps. */
810 darray(struct xkb_sym_interpret) sym_interprets;
814 CopyInterps(CompatInfo *info, bool needSymbol, enum xkb_match_operation pred,
815 struct collect *collect)
819 darray_foreach(si, info->interps)
820 if (si->interp.match == pred &&
821 (si->interp.sym != XKB_KEY_NoSymbol) == needSymbol)
822 darray_append(collect->sym_interprets, si->interp);
826 CopyLedMapDefsToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
828 for (xkb_led_index_t idx = 0; idx < info->num_leds; idx++) {
829 LedInfo *ledi = &info->leds[idx];
834 * Find the LED with the given name, if it was already declared
837 xkb_leds_enumerate(i, led, keymap)
838 if (led->name == ledi->led.name)
841 /* Not previously declared; create it with next free index. */
842 if (i >= keymap->num_leds) {
843 log_dbg(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
844 "Indicator name \"%s\" was not declared in the keycodes section; "
845 "Adding new indicator\n",
846 xkb_atom_text(keymap->ctx, ledi->led.name));
848 xkb_leds_enumerate(i, led, keymap)
849 if (led->name == XKB_ATOM_NONE)
852 if (i >= keymap->num_leds) {
853 /* Not place to put it; ignore. */
854 if (i >= XKB_MAX_LEDS) {
855 log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
856 "Too many indicators (maximum is %d); "
857 "Indicator name \"%s\" ignored\n",
859 xkb_atom_text(keymap->ctx, ledi->led.name));
864 led = &keymap->leds[keymap->num_leds++];
869 if (led->groups != 0 && led->which_groups == 0)
870 led->which_groups = XKB_STATE_LAYOUT_EFFECTIVE;
871 if (led->mods.mods != 0 && led->which_mods == 0)
872 led->which_mods = XKB_STATE_MODS_EFFECTIVE;
877 CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
879 keymap->compat_section_name = strdup_safe(info->name);
880 XkbEscapeMapName(keymap->compat_section_name);
882 keymap->mods = info->mods;
884 if (!darray_empty(info->interps)) {
885 struct collect collect;
886 darray_init(collect.sym_interprets);
888 /* Most specific to least specific. */
889 CopyInterps(info, true, MATCH_EXACTLY, &collect);
890 CopyInterps(info, true, MATCH_ALL, &collect);
891 CopyInterps(info, true, MATCH_NONE, &collect);
892 CopyInterps(info, true, MATCH_ANY, &collect);
893 CopyInterps(info, true, MATCH_ANY_OR_NONE, &collect);
894 CopyInterps(info, false, MATCH_EXACTLY, &collect);
895 CopyInterps(info, false, MATCH_ALL, &collect);
896 CopyInterps(info, false, MATCH_NONE, &collect);
897 CopyInterps(info, false, MATCH_ANY, &collect);
898 CopyInterps(info, false, MATCH_ANY_OR_NONE, &collect);
900 darray_steal(collect.sym_interprets,
901 &keymap->sym_interprets, &keymap->num_sym_interprets);
904 CopyLedMapDefsToKeymap(keymap, info);
910 CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
911 enum merge_mode merge)
914 ActionsInfo *actions;
916 actions = NewActionsInfo();
920 InitCompatInfo(&info, keymap->ctx, actions, &keymap->mods);
921 info.default_interp.merge = merge;
922 info.default_led.merge = merge;
924 HandleCompatMapFile(&info, file, merge);
925 if (info.errorCount != 0)
928 if (!CopyCompatToKeymap(keymap, &info))
931 ClearCompatInfo(&info);
932 FreeActionsInfo(actions);
936 ClearCompatInfo(&info);
937 FreeActionsInfo(actions);