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 darray_growalloc(info->keys, 110);
183 InitKeyInfo(&info->dflt, file_id);
184 InitVModInfo(&info->vmods, keymap);
185 info->actions = actions;
189 ClearSymbolsInfo(SymbolsInfo * info)
193 darray_foreach(keyi, info->keys)
195 darray_free(info->keys);
196 darray_free(info->modMaps);
200 MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
201 bool report, xkb_group_index_t group, unsigned long key_name)
203 xkb_level_index_t i, numLevels;
204 enum { INTO = (1 << 0), FROM = (1 << 1) } using;
206 /* First find the type of the merged group. */
207 if (into->type != from->type) {
208 if (from->type == XKB_ATOM_NONE) {
210 else if (into->type == XKB_ATOM_NONE) {
211 into->type = from->type;
214 xkb_atom_t use = (clobber ? from->type : into->type);
215 xkb_atom_t ignore = (clobber ? into->type : from->type);
218 log_warn(info->keymap->ctx,
219 "Multiple definitions for group %d type of key %s; "
220 "Using %s, ignoring %s\n",
221 group + 1, LongKeyNameText(key_name),
222 xkb_atom_text(info->keymap->ctx, use),
223 xkb_atom_text(info->keymap->ctx, ignore));
228 into->defined |= (from->defined & GROUP_FIELD_TYPE);
230 /* Now look at the levels. */
232 if (darray_empty(from->levels)) {
237 if (darray_empty(into->levels)) {
238 from->type = into->type;
244 /* First we merge the actions and ensure @into has all the levels. */
245 numLevels = MAX(darray_size(into->levels), darray_size(from->levels));
246 for (i = 0; i < numLevels; i++) {
247 union xkb_action *intoAct, *fromAct;
249 if (i >= darray_size(from->levels))
252 if (i >= darray_size(into->levels)) {
253 darray_append(into->levels, darray_item(from->levels, i));
254 darray_item(into->levels, i).num_syms = 0;
255 darray_item(into->levels, i).sym_index = 0;
259 intoAct = &darray_item(into->levels, i).act;
260 fromAct = &darray_item(from->levels, i).act;
262 if (fromAct->type == ACTION_TYPE_NONE) {
264 else if (intoAct->type == ACTION_TYPE_NONE) {
268 union xkb_action *use = (clobber ? fromAct : intoAct);
269 union xkb_action *ignore = (clobber ? intoAct : fromAct);
272 log_warn(info->keymap->ctx,
273 "Multiple actions for level %d/group %u on key %s; "
274 "Using %s, ignoring %s\n",
275 i + 1, group + 1, LongKeyNameText(key_name),
276 ActionTypeText(use->type),
277 ActionTypeText(ignore->type));
282 into->defined |= (from->defined & GROUP_FIELD_ACTS);
284 /* Then merge the keysyms. */
287 * We want to avoid copying and allocating if not necessary. So
288 * here we do a pre-scan of the levels to check if we'll only use
289 * @into's or @from's keysyms, and if so we'll just assign them.
290 * However if one level uses @into's and another uses @from's, we
291 * will need to construct a new syms array.
294 for (i = 0; i < numLevels; i++) {
295 unsigned int intoSize, fromSize;
297 intoSize = darray_item(into->levels, i).num_syms;
298 if (i < darray_size(from->levels))
299 fromSize = darray_item(from->levels, i).num_syms;
303 if (intoSize == 0 && fromSize == 0)
305 else if (intoSize == 0)
307 else if (fromSize == 0)
310 using |= (clobber ? FROM : INTO);
313 if (using == 0 || using == INTO) {
315 else if (using == FROM) {
316 darray_free(into->syms);
317 into->syms = from->syms;
318 darray_init(from->syms);
319 for (i = 0; i < darray_size(from->levels); i++) {
320 darray_item(into->levels, i).num_syms =
321 darray_item(from->levels, i).num_syms;
322 darray_item(into->levels, i).sym_index =
323 darray_item(from->levels, i).sym_index;
327 darray_xkb_keysym_t syms = darray_new();
329 for (i = 0; i < numLevels; i++) {
330 unsigned int intoSize, fromSize;
332 intoSize = darray_item(into->levels, i).num_syms;
333 if (i < darray_size(from->levels))
334 fromSize = darray_item(from->levels, i).num_syms;
339 if (intoSize == 0 && fromSize == 0)
342 if (intoSize != 0 && fromSize != 0 && report)
343 log_info(info->keymap->ctx,
344 "Multiple symbols for group %u, level %d on key %s; "
345 "Using %s, ignoring %s\n",
346 group + 1, i + 1, LongKeyNameText(key_name),
347 (clobber ? "from" : "to"),
348 (clobber ? "to" : "from"));
350 if (intoSize == 0 || (fromSize != 0 && clobber)) {
351 unsigned sym_index = darray_item(from->levels, i).sym_index;
352 darray_item(into->levels, i).sym_index = darray_size(syms);
353 darray_item(into->levels, i).num_syms = fromSize;
354 darray_append_items(syms, &darray_item(from->syms, sym_index),
359 unsigned sym_index = darray_item(into->levels, i).sym_index;
360 darray_item(into->levels, i).sym_index = darray_size(syms);
361 darray_item(into->levels, i).num_syms = intoSize;
362 darray_append_items(syms, &darray_item(into->syms, sym_index),
366 darray_free(into->syms);
369 into->defined |= (from->defined & GROUP_FIELD_SYMS);
375 UseNewKeyField(enum key_field field, enum key_field old, enum key_field new,
376 bool clobber, bool report, enum key_field *collide)
379 return (new & field);
394 MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
397 enum key_field collide = 0;
398 bool clobber, report;
399 int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
401 if (from->merge == MERGE_REPLACE) {
404 InitKeyInfo(from, info->file_id);
408 clobber = (from->merge != MERGE_AUGMENT);
409 report = (verbosity > 9 ||
410 (into->file_id == from->file_id && verbosity > 0));
412 for (i = 0; i < XKB_NUM_GROUPS; i++)
413 MergeGroups(info, &into->groups[i], &from->groups[i], clobber,
414 report, i, into->name);
416 if (UseNewKeyField(KEY_FIELD_VMODMAP, into->defined, from->defined,
417 clobber, report, &collide)) {
418 into->vmodmap = from->vmodmap;
419 into->defined |= KEY_FIELD_VMODMAP;
421 if (UseNewKeyField(KEY_FIELD_REPEAT, into->defined, from->defined,
422 clobber, report, &collide)) {
423 into->repeat = from->repeat;
424 into->defined |= KEY_FIELD_REPEAT;
426 if (UseNewKeyField(KEY_FIELD_TYPE_DFLT, into->defined, from->defined,
427 clobber, report, &collide)) {
428 into->dfltType = from->dfltType;
429 into->defined |= KEY_FIELD_TYPE_DFLT;
431 if (UseNewKeyField(KEY_FIELD_GROUPINFO, into->defined, from->defined,
432 clobber, report, &collide)) {
433 into->out_of_range_group_action = from->out_of_range_group_action;
434 into->out_of_range_group_number = from->out_of_range_group_number;
435 into->defined |= KEY_FIELD_GROUPINFO;
439 log_warn(info->keymap->ctx,
440 "Symbol map for key %s redefined; "
441 "Using %s definition for conflicting fields\n",
442 LongKeyNameText(into->name),
443 (clobber ? "first" : "last"));
446 InitKeyInfo(from, info->file_id);
451 AddKeySymbols(SymbolsInfo *info, KeyInfo *keyi)
453 unsigned long real_name;
457 * Don't keep aliases in the keys array; this guarantees that
458 * searching for keys to merge with by straight comparison (see the
459 * following loop) is enough, and we won't get multiple KeyInfo's
460 * for the same key because of aliases.
462 if (FindKeyNameForAlias(info->keymap, keyi->name, &real_name))
463 keyi->name = real_name;
465 darray_foreach(iter, info->keys)
466 if (iter->name == keyi->name)
467 return MergeKeys(info, iter, keyi);
469 darray_append(info->keys, *keyi);
470 InitKeyInfo(keyi, info->file_id);
475 AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
480 clobber = (new->merge != MERGE_AUGMENT);
481 darray_foreach(mm, info->modMaps) {
482 if (new->haveSymbol && mm->haveSymbol
483 && (new->u.keySym == mm->u.keySym)) {
484 unsigned use, ignore;
485 if (mm->modifier != new->modifier) {
488 ignore = mm->modifier;
492 ignore = new->modifier;
494 log_err(info->keymap->ctx,
495 "%s added to symbol map for multiple modifiers; "
496 "Using %s, ignoring %s.\n",
497 KeysymText(new->u.keySym), ModIndexText(use),
498 ModIndexText(ignore));
503 if ((!new->haveSymbol) && (!mm->haveSymbol) &&
504 (new->u.keyName == mm->u.keyName)) {
505 unsigned use, ignore;
506 if (mm->modifier != new->modifier) {
509 ignore = mm->modifier;
513 ignore = new->modifier;
515 log_err(info->keymap->ctx,
516 "Key %s added to map for multiple modifiers; "
517 "Using %s, ignoring %s.\n",
518 LongKeyNameText(new->u.keyName), ModIndexText(use),
519 ModIndexText(ignore));
526 darray_append(info->modMaps, *new);
530 /***====================================================================***/
533 MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
534 enum merge_mode merge)
540 if (from->errorCount > 0) {
541 into->errorCount += from->errorCount;
544 if (into->name == NULL) {
545 into->name = from->name;
548 for (i = 0; i < XKB_NUM_GROUPS; i++) {
549 if (from->groupNames[i] != XKB_ATOM_NONE) {
550 if ((merge != MERGE_AUGMENT) ||
551 (into->groupNames[i] == XKB_ATOM_NONE))
552 into->groupNames[i] = from->groupNames[i];
556 darray_foreach(keyi, from->keys) {
557 merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
558 if (!AddKeySymbols(into, keyi))
562 darray_foreach(mm, from->modMaps) {
563 mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
564 if (!AddModMapEntry(into, mm))
570 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge);
573 HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *stmt)
575 enum merge_mode merge = MERGE_DEFAULT;
577 SymbolsInfo included, next_incl;
579 InitSymbolsInfo(&included, info->keymap, info->file_id, info->actions);
582 included.name = stmt->stmt;
586 for (; stmt; stmt = stmt->next_incl) {
587 if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_SYMBOLS,
589 info->errorCount += 10;
590 ClearSymbolsInfo(&included);
594 InitSymbolsInfo(&next_incl, info->keymap, rtrn->id, info->actions);
595 next_incl.merge = next_incl.dflt.merge = MERGE_OVERRIDE;
597 next_incl.explicit_group = atoi(stmt->modifier) - 1;
599 next_incl.explicit_group = info->explicit_group;
601 HandleSymbolsFile(&next_incl, rtrn, MERGE_OVERRIDE);
603 MergeIncludedSymbols(&included, &next_incl, merge);
605 ClearSymbolsInfo(&next_incl);
609 MergeIncludedSymbols(info, &included, merge);
610 ClearSymbolsInfo(&included);
612 return (info->errorCount == 0);
619 GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
620 unsigned what, xkb_group_index_t *ndx_rtrn)
622 const char *name = (what == SYMBOLS ? "symbols" : "actions");
624 if (arrayNdx == NULL) {
626 enum group_field field = (what == SYMBOLS ?
627 GROUP_FIELD_SYMS : GROUP_FIELD_ACTS);
629 for (i = 0; i < XKB_NUM_GROUPS; i++) {
630 if (!(keyi->groups[i].defined & field)) {
636 log_err(info->keymap->ctx,
637 "Too many groups of %s for key %s (max %u); "
638 "Ignoring %s defined for extra groups\n",
639 name, LongKeyNameText(keyi->name), XKB_NUM_GROUPS + 1, name);
643 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, ndx_rtrn)) {
644 log_err(info->keymap->ctx,
645 "Illegal group index for %s of key %s\n"
646 "Definition with non-integer array index ignored\n",
647 name, LongKeyNameText(keyi->name));
656 LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
660 if (!str || istreq(str, "any") || istreq(str, "nosymbol")) {
661 *sym_rtrn = XKB_KEY_NoSymbol;
665 if (istreq(str, "none") || istreq(str, "voidsymbol")) {
666 *sym_rtrn = XKB_KEY_VoidSymbol;
670 sym = xkb_keysym_from_name(str);
671 if (sym != XKB_KEY_NoSymbol) {
680 AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
683 xkb_group_index_t ndx;
686 xkb_level_index_t nLevels;
690 if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx))
693 groupi = &keyi->groups[ndx];
696 groupi->defined |= GROUP_FIELD_SYMS;
700 if (value->op != EXPR_KEYSYM_LIST) {
701 log_err(info->keymap->ctx,
702 "Expected a list of symbols, found %s; "
703 "Ignoring symbols for group %u of %s\n",
704 expr_op_type_to_string(value->op), ndx + 1,
705 LongKeyNameText(keyi->name));
709 if (groupi->defined & GROUP_FIELD_SYMS) {
710 log_err(info->keymap->ctx,
711 "Symbols for key %s, group %u already defined; "
712 "Ignoring duplicate definition\n",
713 LongKeyNameText(keyi->name), ndx + 1);
717 nSyms = darray_size(value->value.list.syms);
718 nLevels = darray_size(value->value.list.symsMapIndex);
720 if (darray_size(groupi->syms) < nSyms)
721 darray_resize0(groupi->syms, nSyms);
723 if (darray_size(groupi->levels) < nLevels)
724 darray_resize0(groupi->levels, nLevels);
726 groupi->defined |= GROUP_FIELD_SYMS;
728 for (i = 0; i < nLevels; i++) {
729 LevelInfo *leveli = &darray_item(groupi->levels, i);
731 leveli->sym_index = darray_item(value->value.list.symsMapIndex, i);
732 leveli->num_syms = darray_item(value->value.list.symsNumEntries, i);
734 for (j = 0; j < leveli->num_syms; j++) {
735 if (!LookupKeysym(darray_item(value->value.list.syms,
736 leveli->sym_index + j),
737 &darray_item(groupi->syms,
738 leveli->sym_index + j))) {
739 log_warn(info->keymap->ctx,
740 "Could not resolve keysym %s for key %s, group %u (%s), level %u\n",
741 darray_item(value->value.list.syms, i),
742 LongKeyNameText(keyi->name),
744 xkb_atom_text(info->keymap->ctx,
745 info->groupNames[ndx]),
747 leveli->sym_index = 0;
748 leveli->num_syms = 0;
752 if (leveli->num_syms == 1 &&
753 darray_item(groupi->syms,
754 leveli->sym_index + j) == XKB_KEY_NoSymbol) {
755 leveli->sym_index = 0;
756 leveli->num_syms = 0;
761 for (j = darray_size(groupi->levels) - 1;
762 j >= 0 && darray_item(groupi->levels, j).num_syms == 0; j--)
763 (void) darray_pop(groupi->levels);
769 AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
773 xkb_group_index_t ndx;
777 union xkb_action *toAct;
779 if (!GetGroupIndex(info, keyi, arrayNdx, ACTIONS, &ndx))
782 groupi = &keyi->groups[ndx];
785 groupi->defined |= GROUP_FIELD_ACTS;
789 if (value->op != EXPR_ACTION_LIST) {
790 log_wsgo(info->keymap->ctx,
791 "Bad expression type (%d) for action list value; "
792 "Ignoring actions for group %u of %s\n",
793 value->op, ndx, LongKeyNameText(keyi->name));
797 if (groupi->defined & GROUP_FIELD_ACTS) {
798 log_wsgo(info->keymap->ctx,
799 "Actions for key %s, group %u already defined\n",
800 LongKeyNameText(keyi->name), ndx);
805 for (act = value->value.child; act; act = (ExprDef *) act->common.next)
808 if (darray_size(groupi->levels) < nActs)
809 darray_resize0(groupi->levels, nActs);
811 groupi->defined |= GROUP_FIELD_ACTS;
813 act = value->value.child;
814 for (i = 0; i < nActs; i++) {
815 toAct = &darray_item(groupi->levels, i).act;
817 if (!HandleActionDef(act, info->keymap, toAct, info->actions))
818 log_err(info->keymap->ctx,
819 "Illegal action definition for %s; "
820 "Action for group %u/level %u ignored\n",
821 LongKeyNameText(keyi->name), ndx + 1, i + 1);
823 act = (ExprDef *) act->common.next;
829 static const LookupEntry repeatEntries[] = {
830 { "true", KEY_REPEAT_YES },
831 { "yes", KEY_REPEAT_YES },
832 { "on", KEY_REPEAT_YES },
833 { "false", KEY_REPEAT_NO },
834 { "no", KEY_REPEAT_NO },
835 { "off", KEY_REPEAT_NO },
836 { "default", KEY_REPEAT_UNDEFINED },
841 SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
842 ExprDef *arrayNdx, ExprDef *value)
845 struct xkb_context *ctx = info->keymap->ctx;
847 if (istreq(field, "type")) {
848 xkb_group_index_t ndx;
851 if (!ExprResolveString(ctx, value, &val))
853 "The type field of a key symbol map must be a string; "
854 "Ignoring illegal type definition\n");
856 if (arrayNdx == NULL) {
857 keyi->dfltType = val;
858 keyi->defined |= KEY_FIELD_TYPE_DFLT;
860 else if (!ExprResolveGroup(ctx, arrayNdx, &ndx)) {
862 "Illegal group index for type of key %s; "
863 "Definition with non-integer array index ignored\n",
864 LongKeyNameText(keyi->name));
869 keyi->groups[ndx].type = val;
870 keyi->groups[ndx].defined |= GROUP_FIELD_TYPE;
873 else if (istreq(field, "symbols"))
874 return AddSymbolsToKey(info, keyi, arrayNdx, value);
875 else if (istreq(field, "actions"))
876 return AddActionsToKey(info, keyi, arrayNdx, value);
877 else if (istreq(field, "vmods") ||
878 istreq(field, "virtualmods") ||
879 istreq(field, "virtualmodifiers")) {
882 ok = ExprResolveVModMask(info->keymap, value, &mask);
884 keyi->vmodmap = (mask >> XKB_NUM_CORE_MODS) & 0xffff;
885 keyi->defined |= KEY_FIELD_VMODMAP;
888 log_err(info->keymap->ctx,
889 "Expected a virtual modifier mask, found %s; "
890 "Ignoring virtual modifiers definition for key %s\n",
891 expr_op_type_to_string(value->op),
892 LongKeyNameText(keyi->name));
895 else if (istreq(field, "locking") ||
896 istreq(field, "lock") ||
897 istreq(field, "locks")) {
898 log_err(info->keymap->ctx,
899 "Key behaviors not supported; "
900 "Ignoring locking specification for key %s\n",
901 LongKeyNameText(keyi->name));
903 else if (istreq(field, "radiogroup") ||
904 istreq(field, "permanentradiogroup") ||
905 istreq(field, "allownone")) {
906 log_err(info->keymap->ctx,
907 "Radio groups not supported; "
908 "Ignoring radio group specification for key %s\n",
909 LongKeyNameText(keyi->name));
911 else if (istreq_prefix("overlay", field) ||
912 istreq_prefix("permanentoverlay", field)) {
913 log_err(info->keymap->ctx,
914 "Overlays not supported; "
915 "Ignoring overlay specification for key %s\n",
916 LongKeyNameText(keyi->name));
918 else if (istreq(field, "repeating") ||
919 istreq(field, "repeats") ||
920 istreq(field, "repeat")) {
923 ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
925 log_err(info->keymap->ctx,
926 "Illegal repeat setting for %s; "
927 "Non-boolean repeat setting ignored\n",
928 LongKeyNameText(keyi->name));
932 keyi->defined |= KEY_FIELD_REPEAT;
934 else if (istreq(field, "groupswrap") ||
935 istreq(field, "wrapgroups")) {
938 if (!ExprResolveBoolean(ctx, value, &set)) {
939 log_err(info->keymap->ctx,
940 "Illegal groupsWrap setting for %s; "
941 "Non-boolean value ignored\n",
942 LongKeyNameText(keyi->name));
947 keyi->out_of_range_group_action = RANGE_WRAP;
949 keyi->out_of_range_group_action = RANGE_SATURATE;
951 keyi->defined |= KEY_FIELD_GROUPINFO;
953 else if (istreq(field, "groupsclamp") ||
954 istreq(field, "clampgroups")) {
957 if (!ExprResolveBoolean(ctx, value, &set)) {
958 log_err(info->keymap->ctx,
959 "Illegal groupsClamp setting for %s; "
960 "Non-boolean value ignored\n",
961 LongKeyNameText(keyi->name));
966 keyi->out_of_range_group_action = RANGE_SATURATE;
968 keyi->out_of_range_group_action = RANGE_WRAP;
970 keyi->defined |= KEY_FIELD_GROUPINFO;
972 else if (istreq(field, "groupsredirect") ||
973 istreq(field, "redirectgroups")) {
974 xkb_group_index_t grp;
976 if (!ExprResolveGroup(ctx, value, &grp)) {
977 log_err(info->keymap->ctx,
978 "Illegal group index for redirect of key %s; "
979 "Definition with non-integer group ignored\n",
980 LongKeyNameText(keyi->name));
984 keyi->out_of_range_group_action = RANGE_REDIRECT;
985 keyi->out_of_range_group_number = grp - 1;
986 keyi->defined |= KEY_FIELD_GROUPINFO;
989 log_err(info->keymap->ctx,
990 "Unknown field %s in a symbol interpretation; "
991 "Definition ignored\n",
1000 SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
1002 xkb_group_index_t grp;
1006 log_vrb(info->keymap->ctx, 1,
1007 "You must specify an index when specifying a group name; "
1008 "Group name definition without array subscript ignored\n");
1012 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, &grp)) {
1013 log_err(info->keymap->ctx,
1014 "Illegal index in group name definition; "
1015 "Definition with non-integer array index ignored\n");
1019 if (!ExprResolveString(info->keymap->ctx, value, &name)) {
1020 log_err(info->keymap->ctx,
1021 "Group name must be a string; "
1022 "Illegal name for group %d ignored\n", grp);
1026 info->groupNames[grp - 1 + info->explicit_group] = name;
1031 HandleSymbolsVar(SymbolsInfo *info, VarDef *stmt)
1033 const char *elem, *field;
1037 if (ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field,
1039 return 0; /* internal error, already reported */
1040 if (elem && istreq(elem, "key")) {
1041 ret = SetSymbolsField(info, &info->dflt, field, arrayNdx,
1044 else if (!elem && (istreq(field, "name") ||
1045 istreq(field, "groupname"))) {
1046 ret = SetGroupName(info, arrayNdx, stmt->value);
1048 else if (!elem && (istreq(field, "groupswrap") ||
1049 istreq(field, "wrapgroups"))) {
1050 log_err(info->keymap->ctx,
1051 "Global \"groupswrap\" not supported; Ignored\n");
1054 else if (!elem && (istreq(field, "groupsclamp") ||
1055 istreq(field, "clampgroups"))) {
1056 log_err(info->keymap->ctx,
1057 "Global \"groupsclamp\" not supported; Ignored\n");
1060 else if (!elem && (istreq(field, "groupsredirect") ||
1061 istreq(field, "redirectgroups"))) {
1062 log_err(info->keymap->ctx,
1063 "Global \"groupsredirect\" not supported; Ignored\n");
1066 else if (!elem && istreq(field, "allownone")) {
1067 log_err(info->keymap->ctx,
1068 "Radio groups not supported; "
1069 "Ignoring \"allownone\" specification\n");
1073 ret = SetActionField(info->keymap, elem, field, arrayNdx, stmt->value,
1081 HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
1084 const char *elem, *field;
1087 for (; def; def = (VarDef *) def->common.next) {
1088 if (def->name && def->name->op == EXPR_FIELD_REF) {
1089 ok = HandleSymbolsVar(info, def);
1094 if (!def->value || def->value->op == EXPR_KEYSYM_LIST)
1101 ok = ExprResolveLhs(info->keymap->ctx, def->name, &elem, &field,
1106 ok = SetSymbolsField(info, keyi, field, arrayNdx, def->value);
1113 SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
1115 xkb_group_index_t i;
1117 if (info->explicit_group == 0)
1120 for (i = 1; i < XKB_NUM_GROUPS; i++) {
1121 if (keyi->groups[i].defined) {
1122 log_warn(info->keymap->ctx,
1123 "For the map %s an explicit group specified, "
1124 "but key %s has more than one group defined; "
1125 "All groups except first one will be ignored\n",
1126 info->name, LongKeyNameText(keyi->name));
1130 if (i < XKB_NUM_GROUPS)
1131 for (i = 1; i < XKB_NUM_GROUPS; i++)
1132 ClearGroupInfo(&keyi->groups[i]);
1134 keyi->groups[info->explicit_group] = keyi->groups[0];
1135 InitGroupInfo(&keyi->groups[0]);
1140 HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt)
1143 xkb_group_index_t i;
1146 for (i = 0; i < XKB_NUM_GROUPS; i++) {
1147 darray_copy(keyi.groups[i].syms, info->dflt.groups[i].syms);
1148 darray_copy(keyi.groups[i].levels, info->dflt.groups[i].levels);
1150 keyi.merge = stmt->merge;
1151 keyi.name = KeyNameToLong(stmt->keyName);
1153 if (!HandleSymbolsBody(info, (VarDef *) stmt->symbols, &keyi)) {
1158 if (!SetExplicitGroup(info, &keyi)) {
1163 if (!AddKeySymbols(info, &keyi)) {
1172 HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
1176 xkb_mod_index_t ndx;
1178 struct xkb_context *ctx = info->keymap->ctx;
1180 if (!LookupModIndex(ctx, NULL, def->modifier, EXPR_TYPE_INT, &ndx)) {
1181 log_err(info->keymap->ctx,
1182 "Illegal modifier map definition; "
1183 "Ignoring map for non-modifier \"%s\"\n",
1184 xkb_atom_text(ctx, def->modifier));
1191 for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) {
1194 if (key->op == EXPR_VALUE && key->value_type == EXPR_TYPE_KEYNAME) {
1195 tmp.haveSymbol = false;
1196 tmp.u.keyName = KeyNameToLong(key->value.keyName);
1198 else if (ExprResolveKeySym(ctx, key, &sym)) {
1199 tmp.haveSymbol = true;
1203 log_err(info->keymap->ctx,
1204 "Modmap entries may contain only key names or keysyms; "
1205 "Illegal definition for %s modifier ignored\n",
1206 ModIndexText(tmp.modifier));
1210 ok = AddModMapEntry(info, &tmp) && ok;
1216 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
1222 info->name = strdup_safe(file->name);
1225 for (stmt = file->defs; stmt; stmt = stmt->next) {
1226 switch (stmt->type) {
1228 ok = HandleIncludeSymbols(info, (IncludeStmt *) stmt);
1231 ok = HandleSymbolsDef(info, (SymbolsDef *) stmt);
1234 ok = HandleSymbolsVar(info, (VarDef *) stmt);
1237 ok = HandleVModDef((VModDef *) stmt, info->keymap, merge,
1241 ok = HandleModMapDef(info, (ModMapDef *) stmt);
1244 log_err(info->keymap->ctx,
1245 "Interpretation files may not include other types; "
1246 "Ignoring %s\n", stmt_type_to_string(stmt->type));
1254 if (info->errorCount > 10) {
1255 log_err(info->keymap->ctx, "Abandoning symbols file \"%s\"\n",
1263 * Given a keysym @sym, return a key which generates it, or NULL.
1264 * This is used for example in a modifier map definition, such as:
1265 * modifier_map Lock { Caps_Lock };
1266 * where we want to add the Lock modifier to the modmap of the key
1267 * which matches the keysym Caps_Lock.
1268 * Since there can be many keys which generates the keysym, the key
1269 * is chosen first by lowest group in which the keysym appears, than
1270 * by lowest level and than by lowest key code.
1272 static struct xkb_key *
1273 FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
1275 struct xkb_key *key, *ret = NULL;
1276 xkb_group_index_t group, min_group = UINT32_MAX;
1277 xkb_level_index_t level, min_level = UINT16_MAX;
1279 xkb_foreach_key(key, keymap) {
1280 for (group = 0; group < key->num_groups; group++) {
1281 for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
1283 if (XkbKeyNumSyms(key, group, level) != 1 ||
1284 (XkbKeySymEntry(key, group, level))[0] != sym)
1288 * If the keysym was found in a group or level > 0, we must
1289 * keep looking since we might find a key in which the keysym
1290 * is in a lower group or level.
1292 if (group < min_group ||
1293 (group == min_group && level < min_level)) {
1295 if (group == 0 && level == 0) {
1311 FindNamedType(struct xkb_keymap *keymap, xkb_atom_t name, unsigned *type_rtrn)
1315 for (i = 0; i < keymap->num_types; i++) {
1316 if (keymap->types[i].name == name) {
1326 * Assign a type to the given sym and return the Atom for the type assigned.
1329 * - ONE_LEVEL for width 0/1
1330 * - ALPHABETIC for 2 shift levels, with lower/upercase
1331 * - KEYPAD for keypad keys.
1332 * - TWO_LEVEL for other 2 shift level keys.
1333 * and the same for four level keys.
1335 * @param width Number of sysms in syms.
1336 * @param syms The keysyms for the given key (must be size width).
1337 * @param typeNameRtrn Set to the Atom of the type name.
1339 * @returns true if a type could be found, false otherwise.
1341 * FIXME: I need to take the KeyInfo so I can look at symsMapIndex and
1342 * all that fun stuff rather than just assuming there's always one
1346 FindAutomaticType(struct xkb_context *ctx, xkb_level_index_t width,
1347 const xkb_keysym_t *syms, xkb_atom_t *typeNameRtrn,
1351 if ((width == 1) || (width == 0)) {
1352 *typeNameRtrn = xkb_atom_intern(ctx, "ONE_LEVEL");
1355 else if (width == 2) {
1356 if (syms && xkb_keysym_is_lower(syms[0]) &&
1357 xkb_keysym_is_upper(syms[1])) {
1358 *typeNameRtrn = xkb_atom_intern(ctx, "ALPHABETIC");
1360 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1361 xkb_keysym_is_keypad(syms[1]))) {
1362 *typeNameRtrn = xkb_atom_intern(ctx, "KEYPAD");
1366 *typeNameRtrn = xkb_atom_intern(ctx, "TWO_LEVEL");
1370 else if (width <= 4) {
1371 if (syms && xkb_keysym_is_lower(syms[0]) &&
1372 xkb_keysym_is_upper(syms[1]))
1373 if (xkb_keysym_is_lower(syms[2]) && xkb_keysym_is_upper(syms[3]))
1375 xkb_atom_intern(ctx, "FOUR_LEVEL_ALPHABETIC");
1377 *typeNameRtrn = xkb_atom_intern(ctx,
1378 "FOUR_LEVEL_SEMIALPHABETIC");
1380 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1381 xkb_keysym_is_keypad(syms[1])))
1382 *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL_KEYPAD");
1384 *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL");
1385 /* XXX: why not set autoType here? */
1391 * Ensure the given KeyInfo is in a coherent state, i.e. no gaps between the
1392 * groups, and reduce to one group if all groups are identical anyway.
1395 PrepareKeyDef(KeyInfo *keyi)
1397 xkb_group_index_t i, lastGroup;
1398 const GroupInfo *group0;
1401 /* get highest group number */
1402 for (i = XKB_NUM_GROUPS - 1; i > 0; i--)
1403 if (keyi->groups[i].defined)
1410 group0 = &keyi->groups[0];
1412 /* If there are empty groups between non-empty ones fill them with data */
1413 /* from the first group. */
1414 /* We can make a wrong assumption here. But leaving gaps is worse. */
1415 for (i = lastGroup; i > 0; i--) {
1416 GroupInfo *groupi = &keyi->groups[i];
1418 if (groupi->defined)
1421 groupi->type = group0->type;
1422 darray_copy(groupi->syms, group0->syms);
1423 darray_copy(groupi->levels, group0->levels);
1424 groupi->defined = group0->defined;
1427 /* If all groups are completely identical remove them all */
1428 /* exept the first one. */
1429 /* XXX: This code needs testing... or removal. */
1431 for (i = lastGroup; i > 0; i--) {
1432 GroupInfo *groupi = &keyi->groups[i];
1434 if (groupi->type != group0->type) {
1438 if (!darray_same(groupi->levels, group0->levels) &&
1439 (darray_empty(groupi->levels) || darray_empty(group0->levels) ||
1440 darray_size(groupi->levels) != darray_size(group0->levels) ||
1441 memcmp(darray_mem(groupi->levels, 0),
1442 darray_mem(group0->levels, 0),
1443 darray_size(group0->levels) * sizeof(LevelInfo)))) {
1447 if (!darray_same(groupi->syms, group0->syms) &&
1448 (darray_empty(groupi->syms) || darray_empty(group0->syms) ||
1449 darray_size(groupi->syms) != darray_size(group0->syms) ||
1450 memcmp(darray_mem(groupi->syms, 0),
1451 darray_mem(group0->syms, 0),
1452 darray_size(group0->syms) * sizeof(xkb_keysym_t)))) {
1459 for (i = lastGroup; i > 0; i--)
1460 ClearGroupInfo(&keyi->groups[i]);
1464 CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi)
1466 struct xkb_keymap *keymap = info->keymap;
1467 struct xkb_key *key;
1468 xkb_group_index_t i;
1470 unsigned int sizeSyms;
1471 unsigned int symIndex;
1474 * The name is guaranteed to be real and not an alias (see
1475 * AddKeySymbols), so 'false' is safe here.
1477 key = FindNamedKey(keymap, keyi->name, false);
1479 log_vrb(info->keymap->ctx, 5,
1480 "Key %s not found in keycodes; Symbols ignored\n",
1481 LongKeyNameText(keyi->name));
1486 * Find the range of groups we need. (There shouldn't be any gaps,
1487 * see PrepareKeyDef).
1489 key->num_groups = 0;
1490 for (i = 0; i < XKB_NUM_GROUPS; i++)
1491 if (keyi->groups[i].defined)
1492 key->num_groups = i + 1;
1494 /* See if we need to allocate an actions array. */
1495 haveActions = false;
1496 for (i = 0; i < key->num_groups; i++) {
1498 darray_foreach(leveli, keyi->groups[i].levels) {
1499 if (leveli->act.type != ACTION_TYPE_NONE) {
1508 * Find and assign the groups' types in the keymap. Also find the
1509 * key width according to the largest type.
1512 for (i = 0; i < key->num_groups; i++) {
1513 struct xkb_key_type *type;
1514 GroupInfo *groupi = &keyi->groups[i];
1515 bool autoType = false;
1517 /* Find the type of the group, if it is missing. */
1518 if (groupi->type == XKB_ATOM_NONE) {
1519 if (keyi->dfltType != XKB_ATOM_NONE)
1520 groupi->type = keyi->dfltType;
1521 else if (FindAutomaticType(keymap->ctx,
1522 darray_size(groupi->levels),
1523 darray_mem(groupi->syms, 0),
1524 &groupi->type, &autoType)) { }
1526 log_vrb(info->keymap->ctx, 5,
1527 "No automatic type for %d levels; "
1528 "Using %s for the %s key\n",
1529 darray_size(groupi->levels),
1530 xkb_atom_text(keymap->ctx, groupi->type),
1531 LongKeyNameText(keyi->name));
1534 /* Find the type in the keymap, if it was defined in xkb_types. */
1535 if (FindNamedType(keymap, groupi->type, &key->kt_index[i])) {
1536 if (!autoType || darray_size(groupi->levels) > 2)
1537 key->explicit_groups |= (1 << i);
1540 log_vrb(info->keymap->ctx, 3,
1541 "Type \"%s\" is not defined; "
1542 "Using default type for the %s key\n",
1543 xkb_atom_text(keymap->ctx, groupi->type),
1544 LongKeyNameText(keyi->name));
1546 * Index 0 is guaranteed to contain something, usually
1547 * ONE_LEVEL or at least some default one-level type.
1549 key->kt_index[i] = 0;
1552 /* If the type specifies fewer levels than the key has, shrink the key. */
1553 type = &keymap->types[key->kt_index[i]];
1554 if (type->num_levels < darray_size(groupi->levels)) {
1555 log_vrb(info->keymap->ctx, 1,
1556 "Type \"%s\" has %d levels, but %s has %d levels; "
1557 "Ignoring extra symbols\n",
1558 xkb_atom_text(keymap->ctx, type->name),
1560 LongKeyNameText(keyi->name),
1561 darray_size(groupi->levels));
1562 darray_resize(groupi->levels, type->num_levels);
1566 * Why type->num_levels and not darray_size(groupi->levels)?
1567 * Because the type may have more levels, and each group must
1568 * have at least as many levels as its type. Because the
1569 * key->syms array is indexed by (group * width + level), we
1570 * must take the largest one.
1571 * Maybe we can change it to save some space.
1573 key->width = MAX(key->width, type->num_levels);
1576 /* Find the size of the syms array. */
1578 for (i = 0; i < key->num_groups; i++)
1579 sizeSyms += darray_size(keyi->groups[i].syms);
1581 /* Initialize the xkb_key, now that we know the sizes. */
1582 key->syms = calloc(sizeSyms, sizeof(*key->syms));
1583 key->sym_index = calloc(key->num_groups * key->width,
1584 sizeof(*key->sym_index));
1585 key->num_syms = calloc(key->num_groups * key->width,
1586 sizeof(*key->num_syms));
1587 key->out_of_range_group_number = keyi->out_of_range_group_number;
1588 key->out_of_range_group_action = keyi->out_of_range_group_action;
1590 key->actions = calloc(key->num_groups * key->width,
1591 sizeof(*key->actions));
1592 key->explicit |= EXPLICIT_INTERP;
1594 if (keyi->defined & KEY_FIELD_VMODMAP) {
1595 key->vmodmap = keyi->vmodmap;
1596 key->explicit |= EXPLICIT_VMODMAP;
1599 if (keyi->repeat != KEY_REPEAT_UNDEFINED) {
1600 key->repeats = (keyi->repeat == KEY_REPEAT_YES);
1601 key->explicit |= EXPLICIT_REPEAT;
1604 /* Copy keysyms and actions. */
1606 for (i = 0; i < key->num_groups; i++) {
1607 GroupInfo *groupi = &keyi->groups[i];
1608 xkb_level_index_t j;
1610 /* We rely on calloc having zeroized the arrays up to key->width. */
1611 for (j = 0; j < darray_size(groupi->levels); j++) {
1612 LevelInfo *leveli = &darray_item(groupi->levels, j);
1614 if (leveli->act.type != ACTION_TYPE_NONE)
1615 key->actions[i * key->width + j] = leveli->act;
1617 if (leveli->num_syms <= 0)
1620 memcpy(&key->syms[symIndex],
1621 &darray_item(groupi->syms, leveli->sym_index),
1622 leveli->num_syms * sizeof(*key->syms));
1623 key->sym_index[i * key->width + j] = symIndex;
1624 key->num_syms[i * key->width + j] = leveli->num_syms;
1625 symIndex += key->num_syms[i * key->width + j];
1633 CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
1635 struct xkb_key *key;
1636 struct xkb_keymap *keymap = info->keymap;
1638 if (!entry->haveSymbol) {
1639 key = FindNamedKey(keymap, entry->u.keyName, true);
1641 log_vrb(info->keymap->ctx, 5,
1642 "Key %s not found in keycodes; "
1643 "Modifier map entry for %s not updated\n",
1644 LongKeyNameText(entry->u.keyName),
1645 ModIndexText(entry->modifier));
1650 key = FindKeyForSymbol(keymap, entry->u.keySym);
1652 log_vrb(info->keymap->ctx, 5,
1653 "Key \"%s\" not found in symbol map; "
1654 "Modifier map entry for %s not updated\n",
1655 KeysymText(entry->u.keySym),
1656 ModIndexText(entry->modifier));
1661 key->modmap |= (1 << entry->modifier);
1666 CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
1670 xkb_group_index_t i;
1671 struct xkb_key *key;
1673 keymap->symbols_section_name = strdup_safe(info->name);
1675 for (i = 0; i < XKB_NUM_GROUPS; i++)
1676 if (info->groupNames[i] != XKB_ATOM_NONE)
1677 keymap->group_names[i] = info->groupNames[i];
1679 darray_foreach(keyi, info->keys) {
1680 PrepareKeyDef(keyi);
1681 if (!CopySymbolsDef(info, keyi))
1685 if (xkb_get_log_verbosity(keymap->ctx) > 3) {
1686 xkb_foreach_key(key, keymap) {
1687 if (key->name[0] == '\0')
1690 if (key->num_groups < 1)
1691 log_info(keymap->ctx,
1692 "No symbols defined for %s\n",
1693 KeyNameText(key->name));
1697 darray_foreach(mm, info->modMaps)
1698 if (!CopyModMapDef(info, mm))
1701 /* XXX: If we don't ignore errorCount, things break. */
1706 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
1707 enum merge_mode merge)
1710 ActionsInfo *actions;
1712 actions = NewActionsInfo();
1716 InitSymbolsInfo(&info, keymap, file->id, actions);
1717 info.dflt.merge = merge;
1719 HandleSymbolsFile(&info, file, merge);
1721 if (darray_empty(info.keys))
1724 if (info.errorCount != 0)
1727 if (!CopySymbolsToKeymap(keymap, &info))
1730 ClearSymbolsInfo(&info);
1731 FreeActionsInfo(actions);
1735 FreeActionsInfo(actions);
1736 ClearSymbolsInfo(&info);