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"
65 KEY_REPEAT_UNDEFINED = -1
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);
124 InitGroupInfo(groupi);
128 InitKeyInfo(KeyInfo *keyi, unsigned file_id)
131 static const char dflt[4] = "*";
134 keyi->file_id = file_id;
135 keyi->merge = MERGE_OVERRIDE;
136 keyi->name = KeyNameToLong(dflt);
137 for (i = 0; i < XKB_NUM_GROUPS; i++)
138 InitGroupInfo(&keyi->groups[i]);
139 keyi->dfltType = XKB_ATOM_NONE;
141 keyi->repeat = KEY_REPEAT_UNDEFINED;
142 keyi->out_of_range_group_action = RANGE_WRAP;
143 keyi->out_of_range_group_number = 0;
147 ClearKeyInfo(KeyInfo *keyi)
151 for (i = 0; i < XKB_NUM_GROUPS; i++)
152 ClearGroupInfo(&keyi->groups[i]);
156 CopyKeyInfo(KeyInfo * old, KeyInfo * new, bool clearOld)
163 for (i = 0; i < XKB_NUM_GROUPS; i++) {
164 InitGroupInfo(&old->groups[i]);
168 for (i = 0; i < XKB_NUM_GROUPS; i++) {
169 darray_copy(new->groups[i].syms, old->groups[i].syms);
170 darray_copy(new->groups[i].levels, old->groups[i].levels);
177 /***====================================================================***/
179 typedef struct _ModMapEntry {
180 enum merge_mode merge;
184 unsigned long keyName;
189 typedef struct _SymbolsInfo {
190 char *name; /* e.g. pc+us+inet(evdev) */
193 enum merge_mode merge;
194 xkb_group_index_t explicit_group;
195 darray(KeyInfo) keys;
198 ActionsInfo *actions;
199 xkb_atom_t groupNames[XKB_NUM_GROUPS];
200 darray(ModMapEntry) modMaps;
202 struct xkb_keymap *keymap;
206 InitSymbolsInfo(SymbolsInfo *info, struct xkb_keymap *keymap,
207 unsigned file_id, ActionsInfo *actions)
212 info->explicit_group = 0;
213 info->errorCount = 0;
214 info->file_id = file_id;
215 info->merge = MERGE_OVERRIDE;
216 darray_init(info->keys);
217 darray_growalloc(info->keys, 110);
218 darray_init(info->modMaps);
219 for (i = 0; i < XKB_NUM_GROUPS; i++)
220 info->groupNames[i] = XKB_ATOM_NONE;
221 InitKeyInfo(&info->dflt, file_id);
222 InitVModInfo(&info->vmods, keymap);
223 info->actions = actions;
224 info->keymap = keymap;
228 ClearSymbolsInfo(SymbolsInfo * info)
233 darray_foreach(keyi, info->keys)
235 darray_free(info->keys);
236 darray_free(info->modMaps);
237 memset(info, 0, sizeof(SymbolsInfo));
241 MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
242 bool report, xkb_group_index_t group, unsigned long key_name)
244 xkb_level_index_t i, numLevels;
245 enum { INTO = (1 << 0), FROM = (1 << 1) } using;
247 /* First find the type of the merged group. */
248 if (into->type != from->type) {
249 if (from->type == XKB_ATOM_NONE) {
251 else if (into->type == XKB_ATOM_NONE) {
252 into->type = from->type;
255 xkb_atom_t use = (clobber ? from->type : into->type);
256 xkb_atom_t ignore = (clobber ? into->type : from->type);
259 log_warn(info->keymap->ctx,
260 "Multiple definitions for group %d type of key %s; "
261 "Using %s, ignoring %s\n",
262 group + 1, LongKeyNameText(key_name),
263 xkb_atom_text(info->keymap->ctx, use),
264 xkb_atom_text(info->keymap->ctx, ignore));
269 into->defined |= (from->defined & GROUP_FIELD_TYPE);
271 /* Now look at the levels. */
273 if (darray_empty(from->levels)) {
278 if (darray_empty(into->levels)) {
279 from->type = into->type;
285 /* First we merge the actions and ensure @into has all the levels. */
286 numLevels = MAX(darray_size(into->levels), darray_size(from->levels));
287 for (i = 0; i < numLevels; i++) {
288 union xkb_action *intoAct, *fromAct;
290 if (i >= darray_size(from->levels))
293 if (i >= darray_size(into->levels)) {
294 darray_append(into->levels, darray_item(from->levels, i));
295 darray_item(into->levels, i).num_syms = 0;
296 darray_item(into->levels, i).sym_index = 0;
300 intoAct = &darray_item(into->levels, i).act;
301 fromAct = &darray_item(from->levels, i).act;
303 if (fromAct->type == ACTION_TYPE_NONE) {
305 else if (intoAct->type == ACTION_TYPE_NONE) {
309 union xkb_action *use = (clobber ? fromAct : intoAct);
310 union xkb_action *ignore = (clobber ? intoAct : fromAct);
313 log_warn(info->keymap->ctx,
314 "Multiple actions for level %d/group %u on key %s; "
315 "Using %s, ignoring %s\n",
316 i + 1, group + 1, LongKeyNameText(key_name),
317 ActionTypeText(use->type),
318 ActionTypeText(ignore->type));
323 into->defined |= (from->defined & GROUP_FIELD_ACTS);
325 /* Then merge the keysyms. */
328 * We want to avoid copying and allocating if not necessary. So
329 * here we do a pre-scan of the levels to check if we'll only use
330 * @into's or @from's keysyms, and if so we'll just assign them.
331 * However if one level uses @into's and another uses @from's, we
332 * will need to construct a new syms array.
335 for (i = 0; i < numLevels; i++) {
336 unsigned int intoSize, fromSize;
338 intoSize = darray_item(into->levels, i).num_syms;
339 if (i < darray_size(from->levels))
340 fromSize = darray_item(from->levels, i).num_syms;
344 if (intoSize == 0 && fromSize == 0)
346 else if (intoSize == 0)
348 else if (fromSize == 0)
351 using |= (clobber ? FROM : INTO);
354 if (using == 0 || using == INTO) {
356 else if (using == FROM) {
357 darray_free(into->syms);
358 into->syms = from->syms;
359 darray_init(from->syms);
360 for (i = 0; i < darray_size(from->levels); i++) {
361 darray_item(into->levels, i).num_syms =
362 darray_item(from->levels, i).num_syms;
363 darray_item(into->levels, i).sym_index =
364 darray_item(from->levels, i).sym_index;
368 darray_xkb_keysym_t syms = darray_new();
370 for (i = 0; i < numLevels; i++) {
371 unsigned int intoSize, fromSize;
373 intoSize = darray_item(into->levels, i).num_syms;
374 if (i < darray_size(from->levels))
375 fromSize = darray_item(from->levels, i).num_syms;
380 if (intoSize == 0 && fromSize == 0)
383 if (intoSize != 0 && fromSize != 0 && report)
384 log_info(info->keymap->ctx,
385 "Multiple symbols for group %u, level %d on key %s; "
386 "Using %s, ignoring %s\n",
387 group + 1, i + 1, LongKeyNameText(key_name),
388 (clobber ? "from" : "to"),
389 (clobber ? "to" : "from"));
391 if (intoSize == 0 || (fromSize != 0 && clobber)) {
392 unsigned sym_index = darray_item(from->levels, i).sym_index;
393 darray_item(into->levels, i).sym_index = darray_size(syms);
394 darray_item(into->levels, i).num_syms = fromSize;
395 darray_append_items(syms, &darray_item(from->syms, sym_index),
400 unsigned sym_index = darray_item(into->levels, i).sym_index;
401 darray_item(into->levels, i).sym_index = darray_size(syms);
402 darray_item(into->levels, i).num_syms = intoSize;
403 darray_append_items(syms, &darray_item(into->syms, sym_index),
407 darray_free(into->syms);
410 into->defined |= (from->defined & GROUP_FIELD_SYMS);
416 UseNewKeyField(enum key_field field, enum key_field old, enum key_field new,
417 bool clobber, bool report, enum key_field *collide)
420 return (new & field);
435 MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
438 enum key_field collide = 0;
439 bool clobber, report;
440 int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
442 if (from->merge == MERGE_REPLACE) {
445 InitKeyInfo(from, info->file_id);
449 clobber = (from->merge != MERGE_AUGMENT);
450 report = (verbosity > 9 ||
451 (into->file_id == from->file_id && verbosity > 0));
453 for (i = 0; i < XKB_NUM_GROUPS; i++)
454 MergeGroups(info, &into->groups[i], &from->groups[i], clobber,
455 report, i, into->name);
457 if (UseNewKeyField(KEY_FIELD_VMODMAP, into->defined, from->defined,
458 clobber, report, &collide)) {
459 into->vmodmap = from->vmodmap;
460 into->defined |= KEY_FIELD_VMODMAP;
462 if (UseNewKeyField(KEY_FIELD_REPEAT, into->defined, from->defined,
463 clobber, report, &collide)) {
464 into->repeat = from->repeat;
465 into->defined |= KEY_FIELD_REPEAT;
467 if (UseNewKeyField(KEY_FIELD_TYPE_DFLT, into->defined, from->defined,
468 clobber, report, &collide)) {
469 into->dfltType = from->dfltType;
470 into->defined |= KEY_FIELD_TYPE_DFLT;
472 if (UseNewKeyField(KEY_FIELD_GROUPINFO, into->defined, from->defined,
473 clobber, report, &collide)) {
474 into->out_of_range_group_action = from->out_of_range_group_action;
475 into->out_of_range_group_number = from->out_of_range_group_number;
476 into->defined |= KEY_FIELD_GROUPINFO;
480 log_warn(info->keymap->ctx,
481 "Symbol map for key %s redefined; "
482 "Using %s definition for conflicting fields\n",
483 LongKeyNameText(into->name),
484 (clobber ? "first" : "last"));
491 AddKeySymbols(SymbolsInfo *info, KeyInfo *keyi)
493 unsigned long real_name;
496 darray_foreach(iter, info->keys)
497 if (iter->name == keyi->name)
498 return MergeKeys(info, iter, keyi);
500 if (FindKeyNameForAlias(info->keymap, keyi->name, &real_name))
501 darray_foreach(iter, info->keys)
502 if (iter->name == real_name)
503 return MergeKeys(info, iter, keyi);
505 darray_resize0(info->keys, darray_size(info->keys) + 1);
506 new = &darray_item(info->keys, darray_size(info->keys) - 1);
507 return CopyKeyInfo(keyi, new, true);
511 AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
516 clobber = (new->merge != MERGE_AUGMENT);
517 darray_foreach(mm, info->modMaps) {
518 if (new->haveSymbol && mm->haveSymbol
519 && (new->u.keySym == mm->u.keySym)) {
520 unsigned use, ignore;
521 if (mm->modifier != new->modifier) {
524 ignore = mm->modifier;
528 ignore = new->modifier;
530 log_err(info->keymap->ctx,
531 "%s added to symbol map for multiple modifiers; "
532 "Using %s, ignoring %s.\n",
533 KeysymText(new->u.keySym), ModIndexText(use),
534 ModIndexText(ignore));
539 if ((!new->haveSymbol) && (!mm->haveSymbol) &&
540 (new->u.keyName == mm->u.keyName)) {
541 unsigned use, ignore;
542 if (mm->modifier != new->modifier) {
545 ignore = mm->modifier;
549 ignore = new->modifier;
551 log_err(info->keymap->ctx,
552 "Key %s added to map for multiple modifiers; "
553 "Using %s, ignoring %s.\n",
554 LongKeyNameText(new->u.keyName), ModIndexText(use),
555 ModIndexText(ignore));
562 darray_append(info->modMaps, *new);
566 /***====================================================================***/
569 MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
570 enum merge_mode merge)
576 if (from->errorCount > 0) {
577 into->errorCount += from->errorCount;
580 if (into->name == NULL) {
581 into->name = from->name;
584 for (i = 0; i < XKB_NUM_GROUPS; i++) {
585 if (from->groupNames[i] != XKB_ATOM_NONE) {
586 if ((merge != MERGE_AUGMENT) ||
587 (into->groupNames[i] == XKB_ATOM_NONE))
588 into->groupNames[i] = from->groupNames[i];
592 darray_foreach(keyi, from->keys) {
593 merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
594 if (!AddKeySymbols(into, keyi))
598 darray_foreach(mm, from->modMaps) {
599 mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
600 if (!AddModMapEntry(into, mm))
606 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge);
609 HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *stmt)
611 enum merge_mode merge = MERGE_DEFAULT;
613 SymbolsInfo included, next_incl;
615 InitSymbolsInfo(&included, info->keymap, info->file_id, info->actions);
618 included.name = stmt->stmt;
622 for (; stmt; stmt = stmt->next_incl) {
623 if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_SYMBOLS,
625 info->errorCount += 10;
626 ClearSymbolsInfo(&included);
630 InitSymbolsInfo(&next_incl, info->keymap, rtrn->id, info->actions);
631 next_incl.merge = next_incl.dflt.merge = MERGE_OVERRIDE;
633 next_incl.explicit_group = atoi(stmt->modifier) - 1;
635 next_incl.explicit_group = info->explicit_group;
637 HandleSymbolsFile(&next_incl, rtrn, MERGE_OVERRIDE);
639 MergeIncludedSymbols(&included, &next_incl, merge);
641 ClearSymbolsInfo(&next_incl);
645 MergeIncludedSymbols(info, &included, merge);
646 ClearSymbolsInfo(&included);
648 return (info->errorCount == 0);
655 GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
656 unsigned what, xkb_group_index_t *ndx_rtrn)
658 const char *name = (what == SYMBOLS ? "symbols" : "actions");
660 if (arrayNdx == NULL) {
662 enum group_field field = (what == SYMBOLS ?
663 GROUP_FIELD_SYMS : GROUP_FIELD_ACTS);
665 for (i = 0; i < XKB_NUM_GROUPS; i++) {
666 if (!(keyi->groups[i].defined & field)) {
672 log_err(info->keymap->ctx,
673 "Too many groups of %s for key %s (max %u); "
674 "Ignoring %s defined for extra groups\n",
675 name, LongKeyNameText(keyi->name), XKB_NUM_GROUPS + 1, name);
679 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, ndx_rtrn)) {
680 log_err(info->keymap->ctx,
681 "Illegal group index for %s of key %s\n"
682 "Definition with non-integer array index ignored\n",
683 name, LongKeyNameText(keyi->name));
692 LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
696 if (!str || istreq(str, "any") || istreq(str, "nosymbol")) {
697 *sym_rtrn = XKB_KEY_NoSymbol;
701 if (istreq(str, "none") || istreq(str, "voidsymbol")) {
702 *sym_rtrn = XKB_KEY_VoidSymbol;
706 sym = xkb_keysym_from_name(str);
707 if (sym != XKB_KEY_NoSymbol) {
716 AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
719 xkb_group_index_t ndx;
722 xkb_level_index_t nLevels;
726 if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx))
729 groupi = &keyi->groups[ndx];
732 groupi->defined |= GROUP_FIELD_SYMS;
736 if (value->op != EXPR_KEYSYM_LIST) {
737 log_err(info->keymap->ctx,
738 "Expected a list of symbols, found %s; "
739 "Ignoring symbols for group %u of %s\n",
740 expr_op_type_to_string(value->op), ndx + 1,
741 LongKeyNameText(keyi->name));
745 if (groupi->defined & GROUP_FIELD_SYMS) {
746 log_err(info->keymap->ctx,
747 "Symbols for key %s, group %u already defined; "
748 "Ignoring duplicate definition\n",
749 LongKeyNameText(keyi->name), ndx + 1);
753 nSyms = darray_size(value->value.list.syms);
754 nLevels = darray_size(value->value.list.symsMapIndex);
756 if (darray_size(groupi->syms) < nSyms)
757 darray_resize0(groupi->syms, nSyms);
759 if (darray_size(groupi->levels) < nLevels)
760 darray_resize0(groupi->levels, nLevels);
762 groupi->defined |= GROUP_FIELD_SYMS;
764 for (i = 0; i < nLevels; i++) {
765 LevelInfo *leveli = &darray_item(groupi->levels, i);
767 leveli->sym_index = darray_item(value->value.list.symsMapIndex, i);
768 leveli->num_syms = darray_item(value->value.list.symsNumEntries, i);
770 for (j = 0; j < leveli->num_syms; j++) {
771 if (!LookupKeysym(darray_item(value->value.list.syms,
772 leveli->sym_index + j),
773 &darray_item(groupi->syms,
774 leveli->sym_index + j))) {
775 log_warn(info->keymap->ctx,
776 "Could not resolve keysym %s for key %s, group %u (%s), level %u\n",
777 darray_item(value->value.list.syms, i),
778 LongKeyNameText(keyi->name),
780 xkb_atom_text(info->keymap->ctx,
781 info->groupNames[ndx]),
783 leveli->sym_index = 0;
784 leveli->num_syms = 0;
788 if (leveli->num_syms == 1 &&
789 darray_item(groupi->syms,
790 leveli->sym_index + j) == XKB_KEY_NoSymbol) {
791 leveli->sym_index = 0;
792 leveli->num_syms = 0;
797 for (j = darray_size(groupi->levels) - 1;
798 j >= 0 && darray_item(groupi->levels, j).num_syms == 0; j--)
799 (void) darray_pop(groupi->levels);
805 AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
809 xkb_group_index_t ndx;
813 union xkb_action *toAct;
815 if (!GetGroupIndex(info, keyi, arrayNdx, ACTIONS, &ndx))
818 groupi = &keyi->groups[ndx];
821 groupi->defined |= GROUP_FIELD_ACTS;
825 if (value->op != EXPR_ACTION_LIST) {
826 log_wsgo(info->keymap->ctx,
827 "Bad expression type (%d) for action list value; "
828 "Ignoring actions for group %u of %s\n",
829 value->op, ndx, LongKeyNameText(keyi->name));
833 if (groupi->defined & GROUP_FIELD_ACTS) {
834 log_wsgo(info->keymap->ctx,
835 "Actions for key %s, group %u already defined\n",
836 LongKeyNameText(keyi->name), ndx);
841 for (act = value->value.child; act; act = (ExprDef *) act->common.next)
844 if (darray_size(groupi->levels) < nActs)
845 darray_resize0(groupi->levels, nActs);
847 groupi->defined |= GROUP_FIELD_ACTS;
849 act = value->value.child;
850 for (i = 0; i < nActs; i++) {
851 toAct = &darray_item(groupi->levels, i).act;
853 if (!HandleActionDef(act, info->keymap, toAct, info->actions))
854 log_err(info->keymap->ctx,
855 "Illegal action definition for %s; "
856 "Action for group %u/level %u ignored\n",
857 LongKeyNameText(keyi->name), ndx + 1, i + 1);
859 act = (ExprDef *) act->common.next;
865 static const LookupEntry repeatEntries[] = {
866 { "true", KEY_REPEAT_YES },
867 { "yes", KEY_REPEAT_YES },
868 { "on", KEY_REPEAT_YES },
869 { "false", KEY_REPEAT_NO },
870 { "no", KEY_REPEAT_NO },
871 { "off", KEY_REPEAT_NO },
872 { "default", KEY_REPEAT_UNDEFINED },
877 SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
878 ExprDef *arrayNdx, ExprDef *value)
881 struct xkb_context *ctx = info->keymap->ctx;
883 if (istreq(field, "type")) {
884 xkb_group_index_t ndx;
887 if (!ExprResolveString(ctx, value, &val))
889 "The type field of a key symbol map must be a string; "
890 "Ignoring illegal type definition\n");
892 if (arrayNdx == NULL) {
893 keyi->dfltType = val;
894 keyi->defined |= KEY_FIELD_TYPE_DFLT;
896 else if (!ExprResolveGroup(ctx, arrayNdx, &ndx)) {
898 "Illegal group index for type of key %s; "
899 "Definition with non-integer array index ignored\n",
900 LongKeyNameText(keyi->name));
905 keyi->groups[ndx].type = val;
906 keyi->groups[ndx].defined |= GROUP_FIELD_TYPE;
909 else if (istreq(field, "symbols"))
910 return AddSymbolsToKey(info, keyi, arrayNdx, value);
911 else if (istreq(field, "actions"))
912 return AddActionsToKey(info, keyi, arrayNdx, value);
913 else if (istreq(field, "vmods") ||
914 istreq(field, "virtualmods") ||
915 istreq(field, "virtualmodifiers")) {
918 ok = ExprResolveVModMask(info->keymap, value, &mask);
920 keyi->vmodmap = (mask >> XKB_NUM_CORE_MODS) & 0xffff;
921 keyi->defined |= KEY_FIELD_VMODMAP;
924 log_err(info->keymap->ctx,
925 "Expected a virtual modifier mask, found %s; "
926 "Ignoring virtual modifiers definition for key %s\n",
927 expr_op_type_to_string(value->op),
928 LongKeyNameText(keyi->name));
931 else if (istreq(field, "locking") ||
932 istreq(field, "lock") ||
933 istreq(field, "locks")) {
934 log_err(info->keymap->ctx,
935 "Key behaviors not supported; "
936 "Ignoring locking specification for key %s\n",
937 LongKeyNameText(keyi->name));
939 else if (istreq(field, "radiogroup") ||
940 istreq(field, "permanentradiogroup") ||
941 istreq(field, "allownone")) {
942 log_err(info->keymap->ctx,
943 "Radio groups not supported; "
944 "Ignoring radio group specification for key %s\n",
945 LongKeyNameText(keyi->name));
947 else if (istreq_prefix("overlay", field) ||
948 istreq_prefix("permanentoverlay", field)) {
949 log_err(info->keymap->ctx,
950 "Overlays not supported; "
951 "Ignoring overlay specification for key %s\n",
952 LongKeyNameText(keyi->name));
954 else if (istreq(field, "repeating") ||
955 istreq(field, "repeats") ||
956 istreq(field, "repeat")) {
959 ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
961 log_err(info->keymap->ctx,
962 "Illegal repeat setting for %s; "
963 "Non-boolean repeat setting ignored\n",
964 LongKeyNameText(keyi->name));
968 keyi->defined |= KEY_FIELD_REPEAT;
970 else if (istreq(field, "groupswrap") ||
971 istreq(field, "wrapgroups")) {
974 if (!ExprResolveBoolean(ctx, value, &set)) {
975 log_err(info->keymap->ctx,
976 "Illegal groupsWrap setting for %s; "
977 "Non-boolean value ignored\n",
978 LongKeyNameText(keyi->name));
983 keyi->out_of_range_group_action = RANGE_WRAP;
985 keyi->out_of_range_group_action = RANGE_SATURATE;
987 keyi->defined |= KEY_FIELD_GROUPINFO;
989 else if (istreq(field, "groupsclamp") ||
990 istreq(field, "clampgroups")) {
993 if (!ExprResolveBoolean(ctx, value, &set)) {
994 log_err(info->keymap->ctx,
995 "Illegal groupsClamp setting for %s; "
996 "Non-boolean value ignored\n",
997 LongKeyNameText(keyi->name));
1002 keyi->out_of_range_group_action = RANGE_SATURATE;
1004 keyi->out_of_range_group_action = RANGE_WRAP;
1006 keyi->defined |= KEY_FIELD_GROUPINFO;
1008 else if (istreq(field, "groupsredirect") ||
1009 istreq(field, "redirectgroups")) {
1010 xkb_group_index_t grp;
1012 if (!ExprResolveGroup(ctx, value, &grp)) {
1013 log_err(info->keymap->ctx,
1014 "Illegal group index for redirect of key %s; "
1015 "Definition with non-integer group ignored\n",
1016 LongKeyNameText(keyi->name));
1020 keyi->out_of_range_group_action = RANGE_REDIRECT;
1021 keyi->out_of_range_group_number = grp - 1;
1022 keyi->defined |= KEY_FIELD_GROUPINFO;
1025 log_err(info->keymap->ctx,
1026 "Unknown field %s in a symbol interpretation; "
1027 "Definition ignored\n",
1036 SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
1038 xkb_group_index_t grp;
1042 log_vrb(info->keymap->ctx, 1,
1043 "You must specify an index when specifying a group name; "
1044 "Group name definition without array subscript ignored\n");
1048 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, &grp)) {
1049 log_err(info->keymap->ctx,
1050 "Illegal index in group name definition; "
1051 "Definition with non-integer array index ignored\n");
1055 if (!ExprResolveString(info->keymap->ctx, value, &name)) {
1056 log_err(info->keymap->ctx,
1057 "Group name must be a string; "
1058 "Illegal name for group %d ignored\n", grp);
1062 info->groupNames[grp - 1 + info->explicit_group] = name;
1067 HandleSymbolsVar(SymbolsInfo *info, VarDef *stmt)
1069 const char *elem, *field;
1073 if (ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field,
1075 return 0; /* internal error, already reported */
1076 if (elem && istreq(elem, "key")) {
1077 ret = SetSymbolsField(info, &info->dflt, field, arrayNdx,
1080 else if (!elem && (istreq(field, "name") ||
1081 istreq(field, "groupname"))) {
1082 ret = SetGroupName(info, arrayNdx, stmt->value);
1084 else if (!elem && (istreq(field, "groupswrap") ||
1085 istreq(field, "wrapgroups"))) {
1086 log_err(info->keymap->ctx,
1087 "Global \"groupswrap\" not supported; Ignored\n");
1090 else if (!elem && (istreq(field, "groupsclamp") ||
1091 istreq(field, "clampgroups"))) {
1092 log_err(info->keymap->ctx,
1093 "Global \"groupsclamp\" not supported; Ignored\n");
1096 else if (!elem && (istreq(field, "groupsredirect") ||
1097 istreq(field, "redirectgroups"))) {
1098 log_err(info->keymap->ctx,
1099 "Global \"groupsredirect\" not supported; Ignored\n");
1102 else if (!elem && istreq(field, "allownone")) {
1103 log_err(info->keymap->ctx,
1104 "Radio groups not supported; "
1105 "Ignoring \"allownone\" specification\n");
1109 ret = SetActionField(info->keymap, elem, field, arrayNdx, stmt->value,
1117 HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
1120 const char *elem, *field;
1123 for (; def; def = (VarDef *) def->common.next) {
1124 if (def->name && def->name->op == EXPR_FIELD_REF) {
1125 ok = HandleSymbolsVar(info, def);
1130 if (!def->value || def->value->op == EXPR_KEYSYM_LIST)
1137 ok = ExprResolveLhs(info->keymap->ctx, def->name, &elem, &field,
1142 ok = SetSymbolsField(info, keyi, field, arrayNdx, def->value);
1149 SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
1151 xkb_group_index_t i;
1153 if (info->explicit_group == 0)
1156 for (i = 1; i < XKB_NUM_GROUPS; i++) {
1157 if (keyi->groups[i].defined) {
1158 log_warn(info->keymap->ctx,
1159 "For the map %s an explicit group specified, "
1160 "but key %s has more than one group defined; "
1161 "All groups except first one will be ignored\n",
1162 info->name, LongKeyNameText(keyi->name));
1166 if (i < XKB_NUM_GROUPS)
1167 for (i = 1; i < XKB_NUM_GROUPS; i++)
1168 ClearGroupInfo(&keyi->groups[i]);
1170 keyi->groups[info->explicit_group] = keyi->groups[0];
1171 InitGroupInfo(&keyi->groups[0]);
1176 HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt)
1180 InitKeyInfo(&keyi, info->file_id);
1181 CopyKeyInfo(&info->dflt, &keyi, false);
1182 keyi.merge = stmt->merge;
1183 keyi.name = KeyNameToLong(stmt->keyName);
1184 if (!HandleSymbolsBody(info, (VarDef *) stmt->symbols, &keyi)) {
1189 if (!SetExplicitGroup(info, &keyi)) {
1194 if (!AddKeySymbols(info, &keyi)) {
1202 HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
1206 xkb_mod_index_t ndx;
1208 struct xkb_context *ctx = info->keymap->ctx;
1210 if (!LookupModIndex(ctx, NULL, def->modifier, EXPR_TYPE_INT, &ndx)) {
1211 log_err(info->keymap->ctx,
1212 "Illegal modifier map definition; "
1213 "Ignoring map for non-modifier \"%s\"\n",
1214 xkb_atom_text(ctx, def->modifier));
1221 for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) {
1224 if (key->op == EXPR_VALUE && key->value_type == EXPR_TYPE_KEYNAME) {
1225 tmp.haveSymbol = false;
1226 tmp.u.keyName = KeyNameToLong(key->value.keyName);
1228 else if (ExprResolveKeySym(ctx, key, &sym)) {
1229 tmp.haveSymbol = true;
1233 log_err(info->keymap->ctx,
1234 "Modmap entries may contain only key names or keysyms; "
1235 "Illegal definition for %s modifier ignored\n",
1236 ModIndexText(tmp.modifier));
1240 ok = AddModMapEntry(info, &tmp) && ok;
1246 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
1252 info->name = strdup_safe(file->name);
1255 for (stmt = file->defs; stmt; stmt = stmt->next) {
1256 switch (stmt->type) {
1258 ok = HandleIncludeSymbols(info, (IncludeStmt *) stmt);
1261 ok = HandleSymbolsDef(info, (SymbolsDef *) stmt);
1264 ok = HandleSymbolsVar(info, (VarDef *) stmt);
1267 ok = HandleVModDef((VModDef *) stmt, info->keymap, merge,
1271 ok = HandleModMapDef(info, (ModMapDef *) stmt);
1274 log_err(info->keymap->ctx,
1275 "Interpretation files may not include other types; "
1276 "Ignoring %s\n", stmt_type_to_string(stmt->type));
1284 if (info->errorCount > 10) {
1285 log_err(info->keymap->ctx, "Abandoning symbols file \"%s\"\n",
1293 * Given a keysym @sym, return a key which generates it, or NULL.
1294 * This is used for example in a modifier map definition, such as:
1295 * modifier_map Lock { Caps_Lock };
1296 * where we want to add the Lock modifier to the modmap of the key
1297 * which matches the keysym Caps_Lock.
1298 * Since there can be many keys which generates the keysym, the key
1299 * is chosen first by lowest group in which the keysym appears, than
1300 * by lowest level and than by lowest key code.
1302 static struct xkb_key *
1303 FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
1305 struct xkb_key *key, *ret = NULL;
1306 xkb_group_index_t group, min_group = UINT32_MAX;
1307 xkb_level_index_t level, min_level = UINT16_MAX;
1309 xkb_foreach_key(key, keymap) {
1310 for (group = 0; group < key->num_groups; group++) {
1311 for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
1313 if (XkbKeyNumSyms(key, group, level) != 1 ||
1314 (XkbKeySymEntry(key, group, level))[0] != sym)
1318 * If the keysym was found in a group or level > 0, we must
1319 * keep looking since we might find a key in which the keysym
1320 * is in a lower group or level.
1322 if (group < min_group ||
1323 (group == min_group && level < min_level)) {
1325 if (group == 0 && level == 0) {
1341 FindNamedType(struct xkb_keymap *keymap, xkb_atom_t name, unsigned *type_rtrn)
1345 for (i = 0; i < keymap->num_types; i++) {
1346 if (keymap->types[i].name == name) {
1356 * Assign a type to the given sym and return the Atom for the type assigned.
1359 * - ONE_LEVEL for width 0/1
1360 * - ALPHABETIC for 2 shift levels, with lower/upercase
1361 * - KEYPAD for keypad keys.
1362 * - TWO_LEVEL for other 2 shift level keys.
1363 * and the same for four level keys.
1365 * @param width Number of sysms in syms.
1366 * @param syms The keysyms for the given key (must be size width).
1367 * @param typeNameRtrn Set to the Atom of the type name.
1369 * @returns true if a type could be found, false otherwise.
1371 * FIXME: I need to take the KeyInfo so I can look at symsMapIndex and
1372 * all that fun stuff rather than just assuming there's always one
1376 FindAutomaticType(struct xkb_keymap *keymap, xkb_level_index_t width,
1377 const xkb_keysym_t *syms, xkb_atom_t *typeNameRtrn,
1381 if ((width == 1) || (width == 0)) {
1382 *typeNameRtrn = xkb_atom_intern(keymap->ctx, "ONE_LEVEL");
1385 else if (width == 2) {
1386 if (syms && xkb_keysym_is_lower(syms[0]) &&
1387 xkb_keysym_is_upper(syms[1])) {
1388 *typeNameRtrn = xkb_atom_intern(keymap->ctx, "ALPHABETIC");
1390 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1391 xkb_keysym_is_keypad(syms[1]))) {
1392 *typeNameRtrn = xkb_atom_intern(keymap->ctx, "KEYPAD");
1396 *typeNameRtrn = xkb_atom_intern(keymap->ctx, "TWO_LEVEL");
1400 else if (width <= 4) {
1401 if (syms && xkb_keysym_is_lower(syms[0]) &&
1402 xkb_keysym_is_upper(syms[1]))
1403 if (xkb_keysym_is_lower(syms[2]) && xkb_keysym_is_upper(syms[3]))
1405 xkb_atom_intern(keymap->ctx, "FOUR_LEVEL_ALPHABETIC");
1407 *typeNameRtrn = xkb_atom_intern(keymap->ctx,
1408 "FOUR_LEVEL_SEMIALPHABETIC");
1410 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1411 xkb_keysym_is_keypad(syms[1])))
1412 *typeNameRtrn = xkb_atom_intern(keymap->ctx, "FOUR_LEVEL_KEYPAD");
1414 *typeNameRtrn = xkb_atom_intern(keymap->ctx, "FOUR_LEVEL");
1415 /* XXX: why not set autoType here? */
1421 * Ensure the given KeyInfo is in a coherent state, i.e. no gaps between the
1422 * groups, and reduce to one group if all groups are identical anyway.
1425 PrepareKeyDef(KeyInfo *keyi)
1427 xkb_group_index_t i, lastGroup;
1428 const GroupInfo *group0;
1431 /* get highest group number */
1432 for (i = XKB_NUM_GROUPS - 1; i > 0; i--)
1433 if (keyi->groups[i].defined)
1440 group0 = &keyi->groups[0];
1442 /* If there are empty groups between non-empty ones fill them with data */
1443 /* from the first group. */
1444 /* We can make a wrong assumption here. But leaving gaps is worse. */
1445 for (i = lastGroup; i > 0; i--) {
1446 GroupInfo *groupi = &keyi->groups[i];
1448 if (groupi->defined)
1451 groupi->type = group0->type;
1452 darray_copy(groupi->syms, group0->syms);
1453 darray_copy(groupi->levels, group0->levels);
1454 groupi->defined = group0->defined;
1457 /* If all groups are completely identical remove them all */
1458 /* exept the first one. */
1459 /* XXX: This code needs testing... or removal. */
1461 for (i = lastGroup; i > 0; i--) {
1462 GroupInfo *groupi = &keyi->groups[i];
1464 if (groupi->type != group0->type) {
1468 if (!darray_same(groupi->levels, group0->levels) &&
1469 (darray_empty(groupi->levels) || darray_empty(group0->levels) ||
1470 darray_size(groupi->levels) != darray_size(group0->levels) ||
1471 memcmp(darray_mem(groupi->levels, 0),
1472 darray_mem(group0->levels, 0),
1473 darray_size(group0->levels) * sizeof(LevelInfo)))) {
1477 if (!darray_same(groupi->syms, group0->syms) &&
1478 (darray_empty(groupi->syms) || darray_empty(group0->syms) ||
1479 darray_size(groupi->syms) != darray_size(group0->syms) ||
1480 memcmp(darray_mem(groupi->syms, 0),
1481 darray_mem(group0->syms, 0),
1482 darray_size(group0->syms) * sizeof(xkb_keysym_t)))) {
1489 for (i = lastGroup; i > 0; i--)
1490 ClearGroupInfo(&keyi->groups[i]);
1494 * Copy the KeyInfo into the keyboard description.
1496 * This function recurses.
1499 CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
1500 xkb_keycode_t start_from)
1502 struct xkb_keymap *keymap = info->keymap;
1504 struct xkb_key *key;
1505 unsigned int sizeSyms = 0;
1506 xkb_group_index_t i, nGroups;
1507 xkb_level_index_t width, tmp;
1508 struct xkb_key_type * type;
1509 bool haveActions, autoType, useAlias;
1510 unsigned types[XKB_NUM_GROUPS];
1511 unsigned int symIndex = 0;
1513 useAlias = (start_from == 0);
1515 key = FindNamedKey(keymap, keyi->name, useAlias, start_from);
1517 if (start_from == 0)
1518 log_vrb(info->keymap->ctx, 5,
1519 "Key %s not found in keycodes; Symbols ignored\n",
1520 LongKeyNameText(keyi->name));
1523 kc = XkbKeyGetKeycode(keymap, key);
1525 haveActions = false;
1527 for (i = nGroups = 0; i < XKB_NUM_GROUPS; i++) {
1528 GroupInfo *groupi = &keyi->groups[i];
1530 if (i + 1 > nGroups && groupi->defined)
1537 darray_foreach(leveli, groupi->levels) {
1538 if (leveli->act.type != ACTION_TYPE_NONE) {
1545 /* Assign the type to the key, if it is missing. */
1546 if (groupi->type == XKB_ATOM_NONE) {
1547 if (keyi->dfltType != XKB_ATOM_NONE)
1548 groupi->type = keyi->dfltType;
1549 else if (FindAutomaticType(keymap, darray_size(groupi->levels),
1550 darray_mem(groupi->syms, 0),
1551 &groupi->type, &autoType)) { }
1553 log_vrb(info->keymap->ctx, 5,
1554 "No automatic type for %d levels; "
1555 "Using %s for the %s key (keycode %d)\n",
1556 darray_size(groupi->levels),
1557 xkb_atom_text(keymap->ctx, groupi->type),
1558 LongKeyNameText(keyi->name), kc);
1561 if (FindNamedType(keymap, groupi->type, &types[i])) {
1562 if (!autoType || darray_size(groupi->levels) > 2)
1563 key->explicit_groups |= (1 << i);
1566 log_vrb(info->keymap->ctx, 3,
1567 "Type \"%s\" is not defined; "
1568 "Using default type for the %s key (keycode %d)\n",
1569 xkb_atom_text(keymap->ctx, groupi->type),
1570 LongKeyNameText(keyi->name), kc);
1572 * Index 0 is guaranteed to contain something, usually
1573 * ONE_LEVEL or at least some default one-level type.
1578 /* if the type specifies fewer levels than the key has, shrink the key */
1579 type = &keymap->types[types[i]];
1580 if (type->num_levels < darray_size(groupi->levels)) {
1581 log_vrb(info->keymap->ctx, 1,
1582 "Type \"%s\" has %d levels, but %s has %d levels; "
1583 "Ignoring extra symbols\n",
1584 xkb_atom_text(keymap->ctx, type->name),
1586 LongKeyNameText(keyi->name),
1587 darray_size(groupi->levels));
1588 darray_resize(groupi->levels, type->num_levels);
1591 width = MAX(width, type->num_levels);
1592 sizeSyms += darray_size(groupi->syms);
1595 key->syms = calloc(sizeSyms, sizeof(*key->syms));
1596 key->num_groups = nGroups;
1598 key->sym_index = calloc(nGroups * width, sizeof(*key->sym_index));
1599 key->num_syms = calloc(nGroups * width, sizeof(*key->num_syms));
1602 key->actions = calloc(nGroups * width, sizeof(*key->actions));
1603 key->explicit |= EXPLICIT_INTERP;
1606 key->out_of_range_group_number = keyi->out_of_range_group_number;
1607 key->out_of_range_group_action = keyi->out_of_range_group_action;
1609 for (i = 0; i < nGroups; i++) {
1610 GroupInfo *groupi = &keyi->groups[i];
1612 /* assign kt_index[i] to the index of the type in map->types.
1613 * kt_index[i] may have been set by a previous run (if we have two
1614 * layouts specified). Let's not overwrite it with the ONE_LEVEL
1615 * default group if we dont even have keys for this group anyway.
1617 * FIXME: There should be a better fix for this.
1619 if (!darray_empty(groupi->levels))
1620 key->kt_index[i] = types[i];
1622 if (!darray_empty(groupi->syms)) {
1623 /* fill key to "width" symbols*/
1624 for (tmp = 0; tmp < width; tmp++) {
1625 LevelInfo *leveli = NULL;
1627 if (tmp < darray_size(groupi->levels))
1628 leveli = &darray_item(groupi->levels, tmp);
1630 if (leveli && leveli->num_syms != 0) {
1631 memcpy(&key->syms[symIndex],
1632 &darray_item(groupi->syms, leveli->sym_index),
1633 leveli->num_syms * sizeof(*key->syms));
1634 key->sym_index[(i * width) + tmp] = symIndex;
1635 key->num_syms[(i * width) + tmp] = leveli->num_syms;
1636 symIndex += key->num_syms[(i * width) + tmp];
1639 key->sym_index[(i * width) + tmp] = 0;
1640 key->num_syms[(i * width) + tmp] = 0;
1643 if (key->actions && leveli &&
1644 leveli->act.type != ACTION_TYPE_NONE)
1645 key->actions[tmp] = leveli->act;
1650 if (keyi->defined & KEY_FIELD_VMODMAP) {
1651 key->vmodmap = keyi->vmodmap;
1652 key->explicit |= EXPLICIT_VMODMAP;
1655 if (keyi->repeat != KEY_REPEAT_UNDEFINED) {
1656 key->repeats = (keyi->repeat == KEY_REPEAT_YES);
1657 key->explicit |= EXPLICIT_REPEAT;
1660 /* do the same thing for the next key */
1661 CopySymbolsDef(info, keyi, kc + 1);
1666 CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
1668 struct xkb_key *key;
1669 struct xkb_keymap *keymap = info->keymap;
1671 if (!entry->haveSymbol) {
1672 key = FindNamedKey(keymap, entry->u.keyName, true, 0);
1674 log_vrb(info->keymap->ctx, 5,
1675 "Key %s not found in keycodes; "
1676 "Modifier map entry for %s not updated\n",
1677 LongKeyNameText(entry->u.keyName),
1678 ModIndexText(entry->modifier));
1683 key = FindKeyForSymbol(keymap, entry->u.keySym);
1685 log_vrb(info->keymap->ctx, 5,
1686 "Key \"%s\" not found in symbol map; "
1687 "Modifier map entry for %s not updated\n",
1688 KeysymText(entry->u.keySym),
1689 ModIndexText(entry->modifier));
1694 key->modmap |= (1 << entry->modifier);
1699 * Handle the xkb_symbols section of an xkb file.
1701 * @param file The parsed xkb_symbols section of the xkb file.
1702 * @param keymap Handle to the keyboard description to store the symbols in.
1703 * @param merge Merge strategy (e.g. MERGE_OVERRIDE).
1706 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
1707 enum merge_mode merge)
1709 xkb_group_index_t i;
1710 struct xkb_key *key;
1712 ActionsInfo *actions;
1716 actions = NewActionsInfo();
1720 InitSymbolsInfo(&info, keymap, file->id, actions);
1721 info.dflt.merge = merge;
1723 HandleSymbolsFile(&info, file, merge);
1725 if (darray_empty(info.keys))
1728 if (info.errorCount != 0)
1732 keymap->symbols_section_name = strdup(info.name);
1734 for (i = 0; i < XKB_NUM_GROUPS; i++)
1735 if (info.groupNames[i] != XKB_ATOM_NONE)
1736 keymap->group_names[i] = info.groupNames[i];
1739 darray_foreach(keyi, info.keys)
1740 PrepareKeyDef(keyi);
1743 darray_foreach(keyi, info.keys)
1744 if (!CopySymbolsDef(&info, keyi, 0))
1747 if (xkb_get_log_verbosity(keymap->ctx) > 3) {
1748 xkb_foreach_key(key, keymap) {
1749 if (key->name[0] == '\0')
1752 if (key->num_groups < 1)
1753 log_info(info.keymap->ctx,
1754 "No symbols defined for %s (keycode %d)\n",
1755 KeyNameText(key->name),
1756 XkbKeyGetKeycode(keymap, key));
1760 darray_foreach(mm, info.modMaps)
1761 if (!CopyModMapDef(&info, mm))
1764 ClearSymbolsInfo(&info);
1765 FreeActionsInfo(actions);
1769 FreeActionsInfo(actions);
1770 ClearSymbolsInfo(&info);