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 Intel Corporation
29 * Copyright © 2012 Ran Benita <ran234@gmail.com>
31 * Permission is hereby granted, free of charge, to any person obtaining a
32 * copy of this software and associated documentation files (the "Software"),
33 * to deal in the Software without restriction, including without limitation
34 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
35 * and/or sell copies of the Software, and to permit persons to whom the
36 * Software is furnished to do so, subject to the following conditions:
38 * The above copyright notice and this permission notice (including the next
39 * paragraph) shall be included in all copies or substantial portions of the
42 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
48 * DEALINGS IN THE SOFTWARE.
50 * Author: Daniel Stone <daniel@fooishbar.org>
51 * Ran Benita <ran234@gmail.com>
54 #include "xkbcomp-priv.h"
63 KEY_REPEAT_UNDEFINED = 0,
69 GROUP_FIELD_SYMS = (1 << 0),
70 GROUP_FIELD_ACTS = (1 << 1),
71 GROUP_FIELD_TYPE = (1 << 2),
75 KEY_FIELD_REPEAT = (1 << 0),
76 KEY_FIELD_TYPE_DFLT = (1 << 1),
77 KEY_FIELD_GROUPINFO = (1 << 2),
78 KEY_FIELD_VMODMAP = (1 << 3),
82 unsigned int num_syms;
83 unsigned int sym_index;
87 typedef darray(xkb_keysym_t) darray_xkb_keysym_t;
90 enum group_field defined;
91 darray_xkb_keysym_t syms;
92 darray(LevelInfo) levels;
96 typedef struct _KeyInfo {
97 enum key_field defined;
99 enum merge_mode merge;
101 unsigned long name; /* the 4 chars of the key name, as long */
103 GroupInfo groups[XKB_NUM_GROUPS];
105 enum key_repeat repeat;
106 xkb_mod_mask_t vmodmap;
109 enum xkb_range_exceed_type out_of_range_group_action;
110 xkb_group_index_t out_of_range_group_number;
114 InitGroupInfo(GroupInfo *groupi)
116 memset(groupi, 0, sizeof(*groupi));
120 ClearGroupInfo(GroupInfo *groupi)
122 darray_free(groupi->syms);
123 darray_free(groupi->levels);
127 InitKeyInfo(KeyInfo *keyi, unsigned file_id)
129 static const char dflt_key_name[XKB_KEY_NAME_LENGTH] = "*";
131 memset(keyi, 0, sizeof(*keyi));
132 keyi->file_id = file_id;
133 keyi->merge = MERGE_OVERRIDE;
134 keyi->name = KeyNameToLong(dflt_key_name);
135 keyi->out_of_range_group_action = RANGE_WRAP;
139 ClearKeyInfo(KeyInfo *keyi)
142 for (i = 0; i < XKB_NUM_GROUPS; i++)
143 ClearGroupInfo(&keyi->groups[i]);
146 /***====================================================================***/
148 typedef struct _ModMapEntry {
149 enum merge_mode merge;
153 unsigned long keyName;
158 typedef struct _SymbolsInfo {
159 char *name; /* e.g. pc+us+inet(evdev) */
162 enum merge_mode merge;
163 xkb_group_index_t explicit_group;
164 darray(KeyInfo) keys;
167 ActionsInfo *actions;
168 xkb_atom_t groupNames[XKB_NUM_GROUPS];
169 darray(ModMapEntry) modMaps;
171 struct xkb_keymap *keymap;
175 InitSymbolsInfo(SymbolsInfo *info, struct xkb_keymap *keymap,
176 unsigned file_id, ActionsInfo *actions)
178 memset(info, 0, sizeof(*info));
179 info->keymap = keymap;
180 info->file_id = file_id;
181 info->merge = MERGE_OVERRIDE;
182 InitKeyInfo(&info->dflt, file_id);
183 InitVModInfo(&info->vmods, keymap);
184 info->actions = actions;
188 ClearSymbolsInfo(SymbolsInfo * info)
192 darray_foreach(keyi, info->keys)
194 darray_free(info->keys);
195 darray_free(info->modMaps);
199 MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
200 bool report, xkb_group_index_t group, unsigned long key_name)
202 xkb_level_index_t i, numLevels;
203 enum { INTO = (1 << 0), FROM = (1 << 1) } using;
205 /* First find the type of the merged group. */
206 if (into->type != from->type) {
207 if (from->type == XKB_ATOM_NONE) {
209 else if (into->type == XKB_ATOM_NONE) {
210 into->type = from->type;
213 xkb_atom_t use = (clobber ? from->type : into->type);
214 xkb_atom_t ignore = (clobber ? into->type : from->type);
217 log_warn(info->keymap->ctx,
218 "Multiple definitions for group %d type of key %s; "
219 "Using %s, ignoring %s\n",
220 group + 1, LongKeyNameText(key_name),
221 xkb_atom_text(info->keymap->ctx, use),
222 xkb_atom_text(info->keymap->ctx, ignore));
227 into->defined |= (from->defined & GROUP_FIELD_TYPE);
229 /* Now look at the levels. */
231 if (darray_empty(from->levels)) {
236 if (darray_empty(into->levels)) {
237 from->type = into->type;
243 /* First we merge the actions and ensure @into has all the levels. */
244 numLevels = MAX(darray_size(into->levels), darray_size(from->levels));
245 for (i = 0; i < numLevels; i++) {
246 union xkb_action *intoAct, *fromAct;
248 if (i >= darray_size(from->levels))
251 if (i >= darray_size(into->levels)) {
252 darray_append(into->levels, darray_item(from->levels, i));
253 darray_item(into->levels, i).num_syms = 0;
254 darray_item(into->levels, i).sym_index = 0;
258 intoAct = &darray_item(into->levels, i).act;
259 fromAct = &darray_item(from->levels, i).act;
261 if (fromAct->type == ACTION_TYPE_NONE) {
263 else if (intoAct->type == ACTION_TYPE_NONE) {
267 union xkb_action *use = (clobber ? fromAct : intoAct);
268 union xkb_action *ignore = (clobber ? intoAct : fromAct);
271 log_warn(info->keymap->ctx,
272 "Multiple actions for level %d/group %u on key %s; "
273 "Using %s, ignoring %s\n",
274 i + 1, group + 1, LongKeyNameText(key_name),
275 ActionTypeText(use->type),
276 ActionTypeText(ignore->type));
281 into->defined |= (from->defined & GROUP_FIELD_ACTS);
283 /* Then merge the keysyms. */
286 * We want to avoid copying and allocating if not necessary. So
287 * here we do a pre-scan of the levels to check if we'll only use
288 * @into's or @from's keysyms, and if so we'll just assign them.
289 * However if one level uses @into's and another uses @from's, we
290 * will need to construct a new syms array.
293 for (i = 0; i < numLevels; i++) {
294 unsigned int intoSize, fromSize;
296 intoSize = darray_item(into->levels, i).num_syms;
297 if (i < darray_size(from->levels))
298 fromSize = darray_item(from->levels, i).num_syms;
302 if (intoSize == 0 && fromSize == 0)
304 else if (intoSize == 0)
306 else if (fromSize == 0)
309 using |= (clobber ? FROM : INTO);
312 if (using == 0 || using == INTO) {
314 else if (using == FROM) {
315 darray_free(into->syms);
316 into->syms = from->syms;
317 darray_init(from->syms);
318 for (i = 0; i < darray_size(from->levels); i++) {
319 darray_item(into->levels, i).num_syms =
320 darray_item(from->levels, i).num_syms;
321 darray_item(into->levels, i).sym_index =
322 darray_item(from->levels, i).sym_index;
326 darray_xkb_keysym_t syms = darray_new();
328 for (i = 0; i < numLevels; i++) {
329 unsigned int intoSize, fromSize;
331 intoSize = darray_item(into->levels, i).num_syms;
332 if (i < darray_size(from->levels))
333 fromSize = darray_item(from->levels, i).num_syms;
338 if (intoSize == 0 && fromSize == 0)
341 if (intoSize != 0 && fromSize != 0 && report)
342 log_info(info->keymap->ctx,
343 "Multiple symbols for group %u, level %d on key %s; "
344 "Using %s, ignoring %s\n",
345 group + 1, i + 1, LongKeyNameText(key_name),
346 (clobber ? "from" : "to"),
347 (clobber ? "to" : "from"));
349 if (intoSize == 0 || (fromSize != 0 && clobber)) {
350 unsigned sym_index = darray_item(from->levels, i).sym_index;
351 darray_item(into->levels, i).sym_index = darray_size(syms);
352 darray_item(into->levels, i).num_syms = fromSize;
353 darray_append_items(syms, &darray_item(from->syms, sym_index),
358 unsigned sym_index = darray_item(into->levels, i).sym_index;
359 darray_item(into->levels, i).sym_index = darray_size(syms);
360 darray_item(into->levels, i).num_syms = intoSize;
361 darray_append_items(syms, &darray_item(into->syms, sym_index),
365 darray_free(into->syms);
368 into->defined |= (from->defined & GROUP_FIELD_SYMS);
374 UseNewKeyField(enum key_field field, enum key_field old, enum key_field new,
375 bool clobber, bool report, enum key_field *collide)
378 return (new & field);
393 MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
396 enum key_field collide = 0;
397 bool clobber, report;
398 int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
400 if (from->merge == MERGE_REPLACE) {
403 InitKeyInfo(from, info->file_id);
407 clobber = (from->merge != MERGE_AUGMENT);
408 report = (verbosity > 9 ||
409 (into->file_id == from->file_id && verbosity > 0));
411 for (i = 0; i < XKB_NUM_GROUPS; i++)
412 MergeGroups(info, &into->groups[i], &from->groups[i], clobber,
413 report, i, into->name);
415 if (UseNewKeyField(KEY_FIELD_VMODMAP, into->defined, from->defined,
416 clobber, report, &collide)) {
417 into->vmodmap = from->vmodmap;
418 into->defined |= KEY_FIELD_VMODMAP;
420 if (UseNewKeyField(KEY_FIELD_REPEAT, into->defined, from->defined,
421 clobber, report, &collide)) {
422 into->repeat = from->repeat;
423 into->defined |= KEY_FIELD_REPEAT;
425 if (UseNewKeyField(KEY_FIELD_TYPE_DFLT, into->defined, from->defined,
426 clobber, report, &collide)) {
427 into->dfltType = from->dfltType;
428 into->defined |= KEY_FIELD_TYPE_DFLT;
430 if (UseNewKeyField(KEY_FIELD_GROUPINFO, into->defined, from->defined,
431 clobber, report, &collide)) {
432 into->out_of_range_group_action = from->out_of_range_group_action;
433 into->out_of_range_group_number = from->out_of_range_group_number;
434 into->defined |= KEY_FIELD_GROUPINFO;
438 log_warn(info->keymap->ctx,
439 "Symbol map for key %s redefined; "
440 "Using %s definition for conflicting fields\n",
441 LongKeyNameText(into->name),
442 (clobber ? "first" : "last"));
445 InitKeyInfo(from, info->file_id);
450 AddKeySymbols(SymbolsInfo *info, KeyInfo *keyi)
452 unsigned long real_name;
456 * Don't keep aliases in the keys array; this guarantees that
457 * searching for keys to merge with by straight comparison (see the
458 * following loop) is enough, and we won't get multiple KeyInfo's
459 * for the same key because of aliases.
461 if (FindKeyNameForAlias(info->keymap, keyi->name, &real_name))
462 keyi->name = real_name;
464 darray_foreach(iter, info->keys)
465 if (iter->name == keyi->name)
466 return MergeKeys(info, iter, keyi);
468 darray_append(info->keys, *keyi);
469 InitKeyInfo(keyi, info->file_id);
474 AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
479 clobber = (new->merge != MERGE_AUGMENT);
480 darray_foreach(mm, info->modMaps) {
481 if (new->haveSymbol && mm->haveSymbol
482 && (new->u.keySym == mm->u.keySym)) {
483 unsigned use, ignore;
484 if (mm->modifier != new->modifier) {
487 ignore = mm->modifier;
491 ignore = new->modifier;
493 log_err(info->keymap->ctx,
494 "%s added to symbol map for multiple modifiers; "
495 "Using %s, ignoring %s.\n",
496 KeysymText(new->u.keySym), ModIndexText(use),
497 ModIndexText(ignore));
502 if ((!new->haveSymbol) && (!mm->haveSymbol) &&
503 (new->u.keyName == mm->u.keyName)) {
504 unsigned use, ignore;
505 if (mm->modifier != new->modifier) {
508 ignore = mm->modifier;
512 ignore = new->modifier;
514 log_err(info->keymap->ctx,
515 "Key %s added to map for multiple modifiers; "
516 "Using %s, ignoring %s.\n",
517 LongKeyNameText(new->u.keyName), ModIndexText(use),
518 ModIndexText(ignore));
525 darray_append(info->modMaps, *new);
529 /***====================================================================***/
532 MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
533 enum merge_mode merge)
539 if (from->errorCount > 0) {
540 into->errorCount += from->errorCount;
543 if (into->name == NULL) {
544 into->name = from->name;
547 for (i = 0; i < XKB_NUM_GROUPS; i++) {
548 if (from->groupNames[i] != XKB_ATOM_NONE) {
549 if ((merge != MERGE_AUGMENT) ||
550 (into->groupNames[i] == XKB_ATOM_NONE))
551 into->groupNames[i] = from->groupNames[i];
555 darray_foreach(keyi, from->keys) {
556 merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
557 if (!AddKeySymbols(into, keyi))
561 darray_foreach(mm, from->modMaps) {
562 mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
563 if (!AddModMapEntry(into, mm))
569 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge);
572 HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *stmt)
574 enum merge_mode merge = MERGE_DEFAULT;
576 SymbolsInfo included, next_incl;
578 InitSymbolsInfo(&included, info->keymap, info->file_id, info->actions);
581 included.name = stmt->stmt;
585 for (; stmt; stmt = stmt->next_incl) {
586 if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_SYMBOLS,
588 info->errorCount += 10;
589 ClearSymbolsInfo(&included);
593 InitSymbolsInfo(&next_incl, info->keymap, rtrn->id, info->actions);
594 next_incl.merge = next_incl.dflt.merge = MERGE_OVERRIDE;
596 next_incl.explicit_group = atoi(stmt->modifier) - 1;
598 next_incl.explicit_group = info->explicit_group;
600 HandleSymbolsFile(&next_incl, rtrn, MERGE_OVERRIDE);
602 MergeIncludedSymbols(&included, &next_incl, merge);
604 ClearSymbolsInfo(&next_incl);
608 MergeIncludedSymbols(info, &included, merge);
609 ClearSymbolsInfo(&included);
611 return (info->errorCount == 0);
618 GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
619 unsigned what, xkb_group_index_t *ndx_rtrn)
621 const char *name = (what == SYMBOLS ? "symbols" : "actions");
623 if (arrayNdx == NULL) {
625 enum group_field field = (what == SYMBOLS ?
626 GROUP_FIELD_SYMS : GROUP_FIELD_ACTS);
628 for (i = 0; i < XKB_NUM_GROUPS; i++) {
629 if (!(keyi->groups[i].defined & field)) {
635 log_err(info->keymap->ctx,
636 "Too many groups of %s for key %s (max %u); "
637 "Ignoring %s defined for extra groups\n",
638 name, LongKeyNameText(keyi->name), XKB_NUM_GROUPS + 1, name);
642 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, ndx_rtrn)) {
643 log_err(info->keymap->ctx,
644 "Illegal group index for %s of key %s\n"
645 "Definition with non-integer array index ignored\n",
646 name, LongKeyNameText(keyi->name));
655 LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
659 if (!str || istreq(str, "any") || istreq(str, "nosymbol")) {
660 *sym_rtrn = XKB_KEY_NoSymbol;
664 if (istreq(str, "none") || istreq(str, "voidsymbol")) {
665 *sym_rtrn = XKB_KEY_VoidSymbol;
669 sym = xkb_keysym_from_name(str);
670 if (sym != XKB_KEY_NoSymbol) {
679 AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
682 xkb_group_index_t ndx;
685 xkb_level_index_t nLevels;
689 if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx))
692 groupi = &keyi->groups[ndx];
695 groupi->defined |= GROUP_FIELD_SYMS;
699 if (value->op != EXPR_KEYSYM_LIST) {
700 log_err(info->keymap->ctx,
701 "Expected a list of symbols, found %s; "
702 "Ignoring symbols for group %u of %s\n",
703 expr_op_type_to_string(value->op), ndx + 1,
704 LongKeyNameText(keyi->name));
708 if (groupi->defined & GROUP_FIELD_SYMS) {
709 log_err(info->keymap->ctx,
710 "Symbols for key %s, group %u already defined; "
711 "Ignoring duplicate definition\n",
712 LongKeyNameText(keyi->name), ndx + 1);
716 nSyms = darray_size(value->value.list.syms);
717 nLevels = darray_size(value->value.list.symsMapIndex);
719 if (darray_size(groupi->syms) < nSyms)
720 darray_resize0(groupi->syms, nSyms);
722 if (darray_size(groupi->levels) < nLevels)
723 darray_resize0(groupi->levels, nLevels);
725 groupi->defined |= GROUP_FIELD_SYMS;
727 for (i = 0; i < nLevels; i++) {
728 LevelInfo *leveli = &darray_item(groupi->levels, i);
730 leveli->sym_index = darray_item(value->value.list.symsMapIndex, i);
731 leveli->num_syms = darray_item(value->value.list.symsNumEntries, i);
733 for (j = 0; j < leveli->num_syms; j++) {
734 if (!LookupKeysym(darray_item(value->value.list.syms,
735 leveli->sym_index + j),
736 &darray_item(groupi->syms,
737 leveli->sym_index + j))) {
738 log_warn(info->keymap->ctx,
739 "Could not resolve keysym %s for key %s, group %u (%s), level %u\n",
740 darray_item(value->value.list.syms, i),
741 LongKeyNameText(keyi->name),
743 xkb_atom_text(info->keymap->ctx,
744 info->groupNames[ndx]),
746 leveli->sym_index = 0;
747 leveli->num_syms = 0;
751 if (leveli->num_syms == 1 &&
752 darray_item(groupi->syms,
753 leveli->sym_index + j) == XKB_KEY_NoSymbol) {
754 leveli->sym_index = 0;
755 leveli->num_syms = 0;
760 for (j = darray_size(groupi->levels) - 1;
761 j >= 0 && darray_item(groupi->levels, j).num_syms == 0; j--)
762 (void) darray_pop(groupi->levels);
768 AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
772 xkb_group_index_t ndx;
776 union xkb_action *toAct;
778 if (!GetGroupIndex(info, keyi, arrayNdx, ACTIONS, &ndx))
781 groupi = &keyi->groups[ndx];
784 groupi->defined |= GROUP_FIELD_ACTS;
788 if (value->op != EXPR_ACTION_LIST) {
789 log_wsgo(info->keymap->ctx,
790 "Bad expression type (%d) for action list value; "
791 "Ignoring actions for group %u of %s\n",
792 value->op, ndx, LongKeyNameText(keyi->name));
796 if (groupi->defined & GROUP_FIELD_ACTS) {
797 log_wsgo(info->keymap->ctx,
798 "Actions for key %s, group %u already defined\n",
799 LongKeyNameText(keyi->name), ndx);
804 for (act = value->value.child; act; act = (ExprDef *) act->common.next)
807 if (darray_size(groupi->levels) < nActs)
808 darray_resize0(groupi->levels, nActs);
810 groupi->defined |= GROUP_FIELD_ACTS;
812 act = value->value.child;
813 for (i = 0; i < nActs; i++) {
814 toAct = &darray_item(groupi->levels, i).act;
816 if (!HandleActionDef(act, info->keymap, toAct, info->actions))
817 log_err(info->keymap->ctx,
818 "Illegal action definition for %s; "
819 "Action for group %u/level %u ignored\n",
820 LongKeyNameText(keyi->name), ndx + 1, i + 1);
822 act = (ExprDef *) act->common.next;
828 static const LookupEntry repeatEntries[] = {
829 { "true", KEY_REPEAT_YES },
830 { "yes", KEY_REPEAT_YES },
831 { "on", KEY_REPEAT_YES },
832 { "false", KEY_REPEAT_NO },
833 { "no", KEY_REPEAT_NO },
834 { "off", KEY_REPEAT_NO },
835 { "default", KEY_REPEAT_UNDEFINED },
840 SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
841 ExprDef *arrayNdx, ExprDef *value)
844 struct xkb_context *ctx = info->keymap->ctx;
846 if (istreq(field, "type")) {
847 xkb_group_index_t ndx;
850 if (!ExprResolveString(ctx, value, &val))
852 "The type field of a key symbol map must be a string; "
853 "Ignoring illegal type definition\n");
855 if (arrayNdx == NULL) {
856 keyi->dfltType = val;
857 keyi->defined |= KEY_FIELD_TYPE_DFLT;
859 else if (!ExprResolveGroup(ctx, arrayNdx, &ndx)) {
861 "Illegal group index for type of key %s; "
862 "Definition with non-integer array index ignored\n",
863 LongKeyNameText(keyi->name));
868 keyi->groups[ndx].type = val;
869 keyi->groups[ndx].defined |= GROUP_FIELD_TYPE;
872 else if (istreq(field, "symbols"))
873 return AddSymbolsToKey(info, keyi, arrayNdx, value);
874 else if (istreq(field, "actions"))
875 return AddActionsToKey(info, keyi, arrayNdx, value);
876 else if (istreq(field, "vmods") ||
877 istreq(field, "virtualmods") ||
878 istreq(field, "virtualmodifiers")) {
881 ok = ExprResolveVModMask(info->keymap, value, &mask);
883 keyi->vmodmap = (mask >> XKB_NUM_CORE_MODS) & 0xffff;
884 keyi->defined |= KEY_FIELD_VMODMAP;
887 log_err(info->keymap->ctx,
888 "Expected a virtual modifier mask, found %s; "
889 "Ignoring virtual modifiers definition for key %s\n",
890 expr_op_type_to_string(value->op),
891 LongKeyNameText(keyi->name));
894 else if (istreq(field, "locking") ||
895 istreq(field, "lock") ||
896 istreq(field, "locks")) {
897 log_err(info->keymap->ctx,
898 "Key behaviors not supported; "
899 "Ignoring locking specification for key %s\n",
900 LongKeyNameText(keyi->name));
902 else if (istreq(field, "radiogroup") ||
903 istreq(field, "permanentradiogroup") ||
904 istreq(field, "allownone")) {
905 log_err(info->keymap->ctx,
906 "Radio groups not supported; "
907 "Ignoring radio group specification for key %s\n",
908 LongKeyNameText(keyi->name));
910 else if (istreq_prefix("overlay", field) ||
911 istreq_prefix("permanentoverlay", field)) {
912 log_err(info->keymap->ctx,
913 "Overlays not supported; "
914 "Ignoring overlay specification for key %s\n",
915 LongKeyNameText(keyi->name));
917 else if (istreq(field, "repeating") ||
918 istreq(field, "repeats") ||
919 istreq(field, "repeat")) {
922 ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
924 log_err(info->keymap->ctx,
925 "Illegal repeat setting for %s; "
926 "Non-boolean repeat setting ignored\n",
927 LongKeyNameText(keyi->name));
931 keyi->defined |= KEY_FIELD_REPEAT;
933 else if (istreq(field, "groupswrap") ||
934 istreq(field, "wrapgroups")) {
937 if (!ExprResolveBoolean(ctx, value, &set)) {
938 log_err(info->keymap->ctx,
939 "Illegal groupsWrap setting for %s; "
940 "Non-boolean value ignored\n",
941 LongKeyNameText(keyi->name));
946 keyi->out_of_range_group_action = RANGE_WRAP;
948 keyi->out_of_range_group_action = RANGE_SATURATE;
950 keyi->defined |= KEY_FIELD_GROUPINFO;
952 else if (istreq(field, "groupsclamp") ||
953 istreq(field, "clampgroups")) {
956 if (!ExprResolveBoolean(ctx, value, &set)) {
957 log_err(info->keymap->ctx,
958 "Illegal groupsClamp setting for %s; "
959 "Non-boolean value ignored\n",
960 LongKeyNameText(keyi->name));
965 keyi->out_of_range_group_action = RANGE_SATURATE;
967 keyi->out_of_range_group_action = RANGE_WRAP;
969 keyi->defined |= KEY_FIELD_GROUPINFO;
971 else if (istreq(field, "groupsredirect") ||
972 istreq(field, "redirectgroups")) {
973 xkb_group_index_t grp;
975 if (!ExprResolveGroup(ctx, value, &grp)) {
976 log_err(info->keymap->ctx,
977 "Illegal group index for redirect of key %s; "
978 "Definition with non-integer group ignored\n",
979 LongKeyNameText(keyi->name));
983 keyi->out_of_range_group_action = RANGE_REDIRECT;
984 keyi->out_of_range_group_number = grp - 1;
985 keyi->defined |= KEY_FIELD_GROUPINFO;
988 log_err(info->keymap->ctx,
989 "Unknown field %s in a symbol interpretation; "
990 "Definition ignored\n",
999 SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
1001 xkb_group_index_t grp;
1005 log_vrb(info->keymap->ctx, 1,
1006 "You must specify an index when specifying a group name; "
1007 "Group name definition without array subscript ignored\n");
1011 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, &grp)) {
1012 log_err(info->keymap->ctx,
1013 "Illegal index in group name definition; "
1014 "Definition with non-integer array index ignored\n");
1018 if (!ExprResolveString(info->keymap->ctx, value, &name)) {
1019 log_err(info->keymap->ctx,
1020 "Group name must be a string; "
1021 "Illegal name for group %d ignored\n", grp);
1025 info->groupNames[grp - 1 + info->explicit_group] = name;
1030 HandleSymbolsVar(SymbolsInfo *info, VarDef *stmt)
1032 const char *elem, *field;
1036 if (ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field,
1038 return 0; /* internal error, already reported */
1039 if (elem && istreq(elem, "key")) {
1040 ret = SetSymbolsField(info, &info->dflt, field, arrayNdx,
1043 else if (!elem && (istreq(field, "name") ||
1044 istreq(field, "groupname"))) {
1045 ret = SetGroupName(info, arrayNdx, stmt->value);
1047 else if (!elem && (istreq(field, "groupswrap") ||
1048 istreq(field, "wrapgroups"))) {
1049 log_err(info->keymap->ctx,
1050 "Global \"groupswrap\" not supported; Ignored\n");
1053 else if (!elem && (istreq(field, "groupsclamp") ||
1054 istreq(field, "clampgroups"))) {
1055 log_err(info->keymap->ctx,
1056 "Global \"groupsclamp\" not supported; Ignored\n");
1059 else if (!elem && (istreq(field, "groupsredirect") ||
1060 istreq(field, "redirectgroups"))) {
1061 log_err(info->keymap->ctx,
1062 "Global \"groupsredirect\" not supported; Ignored\n");
1065 else if (!elem && istreq(field, "allownone")) {
1066 log_err(info->keymap->ctx,
1067 "Radio groups not supported; "
1068 "Ignoring \"allownone\" specification\n");
1072 ret = SetActionField(info->keymap, elem, field, arrayNdx, stmt->value,
1080 HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
1083 const char *elem, *field;
1086 for (; def; def = (VarDef *) def->common.next) {
1087 if (def->name && def->name->op == EXPR_FIELD_REF) {
1088 ok = HandleSymbolsVar(info, def);
1093 if (!def->value || def->value->op == EXPR_KEYSYM_LIST)
1100 ok = ExprResolveLhs(info->keymap->ctx, def->name, &elem, &field,
1105 ok = SetSymbolsField(info, keyi, field, arrayNdx, def->value);
1112 SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
1114 xkb_group_index_t i;
1116 if (info->explicit_group == 0)
1119 for (i = 1; i < XKB_NUM_GROUPS; i++) {
1120 if (keyi->groups[i].defined) {
1121 log_warn(info->keymap->ctx,
1122 "For the map %s an explicit group specified, "
1123 "but key %s has more than one group defined; "
1124 "All groups except first one will be ignored\n",
1125 info->name, LongKeyNameText(keyi->name));
1129 if (i < XKB_NUM_GROUPS)
1130 for (i = 1; i < XKB_NUM_GROUPS; i++)
1131 ClearGroupInfo(&keyi->groups[i]);
1133 keyi->groups[info->explicit_group] = keyi->groups[0];
1134 InitGroupInfo(&keyi->groups[0]);
1139 HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt)
1142 xkb_group_index_t i;
1145 for (i = 0; i < XKB_NUM_GROUPS; i++) {
1146 darray_copy(keyi.groups[i].syms, info->dflt.groups[i].syms);
1147 darray_copy(keyi.groups[i].levels, info->dflt.groups[i].levels);
1149 keyi.merge = stmt->merge;
1150 keyi.name = KeyNameToLong(stmt->keyName);
1152 if (!HandleSymbolsBody(info, (VarDef *) stmt->symbols, &keyi)) {
1157 if (!SetExplicitGroup(info, &keyi)) {
1162 if (!AddKeySymbols(info, &keyi)) {
1171 HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
1175 xkb_mod_index_t ndx;
1177 struct xkb_context *ctx = info->keymap->ctx;
1179 if (!LookupModIndex(ctx, NULL, def->modifier, EXPR_TYPE_INT, &ndx)) {
1180 log_err(info->keymap->ctx,
1181 "Illegal modifier map definition; "
1182 "Ignoring map for non-modifier \"%s\"\n",
1183 xkb_atom_text(ctx, def->modifier));
1190 for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) {
1193 if (key->op == EXPR_VALUE && key->value_type == EXPR_TYPE_KEYNAME) {
1194 tmp.haveSymbol = false;
1195 tmp.u.keyName = KeyNameToLong(key->value.keyName);
1197 else if (ExprResolveKeySym(ctx, key, &sym)) {
1198 tmp.haveSymbol = true;
1202 log_err(info->keymap->ctx,
1203 "Modmap entries may contain only key names or keysyms; "
1204 "Illegal definition for %s modifier ignored\n",
1205 ModIndexText(tmp.modifier));
1209 ok = AddModMapEntry(info, &tmp) && ok;
1215 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
1221 info->name = strdup_safe(file->name);
1224 for (stmt = file->defs; stmt; stmt = stmt->next) {
1225 switch (stmt->type) {
1227 ok = HandleIncludeSymbols(info, (IncludeStmt *) stmt);
1230 ok = HandleSymbolsDef(info, (SymbolsDef *) stmt);
1233 ok = HandleSymbolsVar(info, (VarDef *) stmt);
1236 ok = HandleVModDef((VModDef *) stmt, info->keymap, merge,
1240 ok = HandleModMapDef(info, (ModMapDef *) stmt);
1243 log_err(info->keymap->ctx,
1244 "Interpretation files may not include other types; "
1245 "Ignoring %s\n", stmt_type_to_string(stmt->type));
1253 if (info->errorCount > 10) {
1254 log_err(info->keymap->ctx, "Abandoning symbols file \"%s\"\n",
1262 * Given a keysym @sym, return a key which generates it, or NULL.
1263 * This is used for example in a modifier map definition, such as:
1264 * modifier_map Lock { Caps_Lock };
1265 * where we want to add the Lock modifier to the modmap of the key
1266 * which matches the keysym Caps_Lock.
1267 * Since there can be many keys which generates the keysym, the key
1268 * is chosen first by lowest group in which the keysym appears, than
1269 * by lowest level and than by lowest key code.
1271 static struct xkb_key *
1272 FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
1274 struct xkb_key *key, *ret = NULL;
1275 xkb_group_index_t group, min_group = UINT32_MAX;
1276 xkb_level_index_t level, min_level = UINT16_MAX;
1278 xkb_foreach_key(key, keymap) {
1279 for (group = 0; group < key->num_groups; group++) {
1280 for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
1282 if (XkbKeyNumSyms(key, group, level) != 1 ||
1283 (XkbKeySymEntry(key, group, level))[0] != sym)
1287 * If the keysym was found in a group or level > 0, we must
1288 * keep looking since we might find a key in which the keysym
1289 * is in a lower group or level.
1291 if (group < min_group ||
1292 (group == min_group && level < min_level)) {
1294 if (group == 0 && level == 0) {
1310 FindNamedType(struct xkb_keymap *keymap, xkb_atom_t name, unsigned *type_rtrn)
1314 for (i = 0; i < keymap->num_types; i++) {
1315 if (keymap->types[i].name == name) {
1325 * Assign a type to the given sym and return the Atom for the type assigned.
1328 * - ONE_LEVEL for width 0/1
1329 * - ALPHABETIC for 2 shift levels, with lower/upercase
1330 * - KEYPAD for keypad keys.
1331 * - TWO_LEVEL for other 2 shift level keys.
1332 * and the same for four level keys.
1334 * @param width Number of sysms in syms.
1335 * @param syms The keysyms for the given key (must be size width).
1336 * @param typeNameRtrn Set to the Atom of the type name.
1338 * @returns true if a type could be found, false otherwise.
1340 * FIXME: I need to take the KeyInfo so I can look at symsMapIndex and
1341 * all that fun stuff rather than just assuming there's always one
1345 FindAutomaticType(struct xkb_context *ctx, xkb_level_index_t width,
1346 const xkb_keysym_t *syms, xkb_atom_t *typeNameRtrn,
1350 if ((width == 1) || (width == 0)) {
1351 *typeNameRtrn = xkb_atom_intern(ctx, "ONE_LEVEL");
1354 else if (width == 2) {
1355 if (syms && xkb_keysym_is_lower(syms[0]) &&
1356 xkb_keysym_is_upper(syms[1])) {
1357 *typeNameRtrn = xkb_atom_intern(ctx, "ALPHABETIC");
1359 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1360 xkb_keysym_is_keypad(syms[1]))) {
1361 *typeNameRtrn = xkb_atom_intern(ctx, "KEYPAD");
1365 *typeNameRtrn = xkb_atom_intern(ctx, "TWO_LEVEL");
1369 else if (width <= 4) {
1370 if (syms && xkb_keysym_is_lower(syms[0]) &&
1371 xkb_keysym_is_upper(syms[1]))
1372 if (xkb_keysym_is_lower(syms[2]) && xkb_keysym_is_upper(syms[3]))
1374 xkb_atom_intern(ctx, "FOUR_LEVEL_ALPHABETIC");
1376 *typeNameRtrn = xkb_atom_intern(ctx,
1377 "FOUR_LEVEL_SEMIALPHABETIC");
1379 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1380 xkb_keysym_is_keypad(syms[1])))
1381 *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL_KEYPAD");
1383 *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL");
1384 /* XXX: why not set autoType here? */
1390 * Ensure the given KeyInfo is in a coherent state, i.e. no gaps between the
1391 * groups, and reduce to one group if all groups are identical anyway.
1394 PrepareKeyDef(KeyInfo *keyi)
1396 xkb_group_index_t i, lastGroup;
1397 const GroupInfo *group0;
1400 /* get highest group number */
1401 for (i = XKB_NUM_GROUPS - 1; i > 0; i--)
1402 if (keyi->groups[i].defined)
1409 group0 = &keyi->groups[0];
1411 /* If there are empty groups between non-empty ones fill them with data */
1412 /* from the first group. */
1413 /* We can make a wrong assumption here. But leaving gaps is worse. */
1414 for (i = lastGroup; i > 0; i--) {
1415 GroupInfo *groupi = &keyi->groups[i];
1417 if (groupi->defined)
1420 groupi->type = group0->type;
1421 darray_copy(groupi->syms, group0->syms);
1422 darray_copy(groupi->levels, group0->levels);
1423 groupi->defined = group0->defined;
1426 /* If all groups are completely identical remove them all */
1427 /* exept the first one. */
1428 /* XXX: This code needs testing... or removal. */
1430 for (i = lastGroup; i > 0; i--) {
1431 GroupInfo *groupi = &keyi->groups[i];
1433 if (groupi->type != group0->type) {
1437 if (!darray_same(groupi->levels, group0->levels) &&
1438 (darray_empty(groupi->levels) || darray_empty(group0->levels) ||
1439 darray_size(groupi->levels) != darray_size(group0->levels) ||
1440 memcmp(darray_mem(groupi->levels, 0),
1441 darray_mem(group0->levels, 0),
1442 darray_size(group0->levels) * sizeof(LevelInfo)))) {
1446 if (!darray_same(groupi->syms, group0->syms) &&
1447 (darray_empty(groupi->syms) || darray_empty(group0->syms) ||
1448 darray_size(groupi->syms) != darray_size(group0->syms) ||
1449 memcmp(darray_mem(groupi->syms, 0),
1450 darray_mem(group0->syms, 0),
1451 darray_size(group0->syms) * sizeof(xkb_keysym_t)))) {
1458 for (i = lastGroup; i > 0; i--)
1459 ClearGroupInfo(&keyi->groups[i]);
1463 CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi)
1465 struct xkb_keymap *keymap = info->keymap;
1466 struct xkb_key *key;
1467 xkb_group_index_t i;
1469 unsigned int sizeSyms;
1470 unsigned int symIndex;
1473 * The name is guaranteed to be real and not an alias (see
1474 * AddKeySymbols), so 'false' is safe here.
1476 key = FindNamedKey(keymap, keyi->name, false);
1478 log_vrb(info->keymap->ctx, 5,
1479 "Key %s not found in keycodes; Symbols ignored\n",
1480 LongKeyNameText(keyi->name));
1485 * Find the range of groups we need. (There shouldn't be any gaps,
1486 * see PrepareKeyDef).
1488 key->num_groups = 0;
1489 for (i = 0; i < XKB_NUM_GROUPS; i++)
1490 if (keyi->groups[i].defined)
1491 key->num_groups = i + 1;
1493 /* See if we need to allocate an actions array. */
1494 haveActions = false;
1495 for (i = 0; i < key->num_groups; i++) {
1497 darray_foreach(leveli, keyi->groups[i].levels) {
1498 if (leveli->act.type != ACTION_TYPE_NONE) {
1507 * Find and assign the groups' types in the keymap. Also find the
1508 * key width according to the largest type.
1511 for (i = 0; i < key->num_groups; i++) {
1512 struct xkb_key_type *type;
1513 GroupInfo *groupi = &keyi->groups[i];
1514 bool autoType = false;
1516 /* Find the type of the group, if it is missing. */
1517 if (groupi->type == XKB_ATOM_NONE) {
1518 if (keyi->dfltType != XKB_ATOM_NONE)
1519 groupi->type = keyi->dfltType;
1520 else if (FindAutomaticType(keymap->ctx,
1521 darray_size(groupi->levels),
1522 darray_mem(groupi->syms, 0),
1523 &groupi->type, &autoType)) { }
1525 log_vrb(info->keymap->ctx, 5,
1526 "No automatic type for %d levels; "
1527 "Using %s for the %s key\n",
1528 darray_size(groupi->levels),
1529 xkb_atom_text(keymap->ctx, groupi->type),
1530 LongKeyNameText(keyi->name));
1533 /* Find the type in the keymap, if it was defined in xkb_types. */
1534 if (FindNamedType(keymap, groupi->type, &key->kt_index[i])) {
1535 if (!autoType || darray_size(groupi->levels) > 2)
1536 key->explicit_groups |= (1 << i);
1539 log_vrb(info->keymap->ctx, 3,
1540 "Type \"%s\" is not defined; "
1541 "Using default type for the %s key\n",
1542 xkb_atom_text(keymap->ctx, groupi->type),
1543 LongKeyNameText(keyi->name));
1545 * Index 0 is guaranteed to contain something, usually
1546 * ONE_LEVEL or at least some default one-level type.
1548 key->kt_index[i] = 0;
1551 /* If the type specifies fewer levels than the key has, shrink the key. */
1552 type = &keymap->types[key->kt_index[i]];
1553 if (type->num_levels < darray_size(groupi->levels)) {
1554 log_vrb(info->keymap->ctx, 1,
1555 "Type \"%s\" has %d levels, but %s has %d levels; "
1556 "Ignoring extra symbols\n",
1557 xkb_atom_text(keymap->ctx, type->name),
1559 LongKeyNameText(keyi->name),
1560 darray_size(groupi->levels));
1561 darray_resize(groupi->levels, type->num_levels);
1565 * Why type->num_levels and not darray_size(groupi->levels)?
1566 * Because the type may have more levels, and each group must
1567 * have at least as many levels as its type. Because the
1568 * key->syms array is indexed by (group * width + level), we
1569 * must take the largest one.
1570 * Maybe we can change it to save some space.
1572 key->width = MAX(key->width, type->num_levels);
1575 /* Find the size of the syms array. */
1577 for (i = 0; i < key->num_groups; i++)
1578 sizeSyms += darray_size(keyi->groups[i].syms);
1580 /* Initialize the xkb_key, now that we know the sizes. */
1581 key->syms = calloc(sizeSyms, sizeof(*key->syms));
1582 key->sym_index = calloc(key->num_groups * key->width,
1583 sizeof(*key->sym_index));
1584 key->num_syms = calloc(key->num_groups * key->width,
1585 sizeof(*key->num_syms));
1586 key->out_of_range_group_number = keyi->out_of_range_group_number;
1587 key->out_of_range_group_action = keyi->out_of_range_group_action;
1589 key->actions = calloc(key->num_groups * key->width,
1590 sizeof(*key->actions));
1591 key->explicit |= EXPLICIT_INTERP;
1593 if (keyi->defined & KEY_FIELD_VMODMAP) {
1594 key->vmodmap = keyi->vmodmap;
1595 key->explicit |= EXPLICIT_VMODMAP;
1598 if (keyi->repeat != KEY_REPEAT_UNDEFINED) {
1599 key->repeats = (keyi->repeat == KEY_REPEAT_YES);
1600 key->explicit |= EXPLICIT_REPEAT;
1603 /* Copy keysyms and actions. */
1605 for (i = 0; i < key->num_groups; i++) {
1606 GroupInfo *groupi = &keyi->groups[i];
1607 xkb_level_index_t j;
1609 /* We rely on calloc having zeroized the arrays up to key->width. */
1610 for (j = 0; j < darray_size(groupi->levels); j++) {
1611 LevelInfo *leveli = &darray_item(groupi->levels, j);
1613 if (leveli->act.type != ACTION_TYPE_NONE)
1614 key->actions[i * key->width + j] = leveli->act;
1616 if (leveli->num_syms <= 0)
1619 memcpy(&key->syms[symIndex],
1620 &darray_item(groupi->syms, leveli->sym_index),
1621 leveli->num_syms * sizeof(*key->syms));
1622 key->sym_index[i * key->width + j] = symIndex;
1623 key->num_syms[i * key->width + j] = leveli->num_syms;
1624 symIndex += key->num_syms[i * key->width + j];
1632 CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
1634 struct xkb_key *key;
1635 struct xkb_keymap *keymap = info->keymap;
1637 if (!entry->haveSymbol) {
1638 key = FindNamedKey(keymap, entry->u.keyName, true);
1640 log_vrb(info->keymap->ctx, 5,
1641 "Key %s not found in keycodes; "
1642 "Modifier map entry for %s not updated\n",
1643 LongKeyNameText(entry->u.keyName),
1644 ModIndexText(entry->modifier));
1649 key = FindKeyForSymbol(keymap, entry->u.keySym);
1651 log_vrb(info->keymap->ctx, 5,
1652 "Key \"%s\" not found in symbol map; "
1653 "Modifier map entry for %s not updated\n",
1654 KeysymText(entry->u.keySym),
1655 ModIndexText(entry->modifier));
1660 key->modmap |= (1 << entry->modifier);
1665 CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
1669 xkb_group_index_t i;
1670 struct xkb_key *key;
1672 keymap->symbols_section_name = strdup_safe(info->name);
1674 for (i = 0; i < XKB_NUM_GROUPS; i++)
1675 if (info->groupNames[i] != XKB_ATOM_NONE)
1676 keymap->group_names[i] = info->groupNames[i];
1678 darray_foreach(keyi, info->keys) {
1679 PrepareKeyDef(keyi);
1680 if (!CopySymbolsDef(info, keyi))
1684 if (xkb_get_log_verbosity(keymap->ctx) > 3) {
1685 xkb_foreach_key(key, keymap) {
1686 if (key->name[0] == '\0')
1689 if (key->num_groups < 1)
1690 log_info(keymap->ctx,
1691 "No symbols defined for %s\n",
1692 KeyNameText(key->name));
1696 darray_foreach(mm, info->modMaps)
1697 if (!CopyModMapDef(info, mm))
1700 /* XXX: If we don't ignore errorCount, things break. */
1705 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
1706 enum merge_mode merge)
1709 ActionsInfo *actions;
1711 actions = NewActionsInfo();
1715 InitSymbolsInfo(&info, keymap, file->id, actions);
1716 info.dflt.merge = merge;
1718 HandleSymbolsFile(&info, file, merge);
1720 if (darray_empty(info.keys))
1723 if (info.errorCount != 0)
1726 if (!CopySymbolsToKeymap(keymap, &info))
1729 ClearSymbolsInfo(&info);
1730 FreeActionsInfo(actions);
1734 FreeActionsInfo(actions);
1735 ClearSymbolsInfo(&info);