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]);
155 /***====================================================================***/
157 typedef struct _ModMapEntry {
158 enum merge_mode merge;
162 unsigned long keyName;
167 typedef struct _SymbolsInfo {
168 char *name; /* e.g. pc+us+inet(evdev) */
171 enum merge_mode merge;
172 xkb_group_index_t explicit_group;
173 darray(KeyInfo) keys;
176 ActionsInfo *actions;
177 xkb_atom_t groupNames[XKB_NUM_GROUPS];
178 darray(ModMapEntry) modMaps;
180 struct xkb_keymap *keymap;
184 InitSymbolsInfo(SymbolsInfo *info, struct xkb_keymap *keymap,
185 unsigned file_id, ActionsInfo *actions)
190 info->explicit_group = 0;
191 info->errorCount = 0;
192 info->file_id = file_id;
193 info->merge = MERGE_OVERRIDE;
194 darray_init(info->keys);
195 darray_growalloc(info->keys, 110);
196 darray_init(info->modMaps);
197 for (i = 0; i < XKB_NUM_GROUPS; i++)
198 info->groupNames[i] = XKB_ATOM_NONE;
199 InitKeyInfo(&info->dflt, file_id);
200 InitVModInfo(&info->vmods, keymap);
201 info->actions = actions;
202 info->keymap = keymap;
206 ClearSymbolsInfo(SymbolsInfo * info)
211 darray_foreach(keyi, info->keys)
213 darray_free(info->keys);
214 darray_free(info->modMaps);
215 memset(info, 0, sizeof(SymbolsInfo));
219 MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
220 bool report, xkb_group_index_t group, unsigned long key_name)
222 xkb_level_index_t i, numLevels;
223 enum { INTO = (1 << 0), FROM = (1 << 1) } using;
225 /* First find the type of the merged group. */
226 if (into->type != from->type) {
227 if (from->type == XKB_ATOM_NONE) {
229 else if (into->type == XKB_ATOM_NONE) {
230 into->type = from->type;
233 xkb_atom_t use = (clobber ? from->type : into->type);
234 xkb_atom_t ignore = (clobber ? into->type : from->type);
237 log_warn(info->keymap->ctx,
238 "Multiple definitions for group %d type of key %s; "
239 "Using %s, ignoring %s\n",
240 group + 1, LongKeyNameText(key_name),
241 xkb_atom_text(info->keymap->ctx, use),
242 xkb_atom_text(info->keymap->ctx, ignore));
247 into->defined |= (from->defined & GROUP_FIELD_TYPE);
249 /* Now look at the levels. */
251 if (darray_empty(from->levels)) {
256 if (darray_empty(into->levels)) {
257 from->type = into->type;
263 /* First we merge the actions and ensure @into has all the levels. */
264 numLevels = MAX(darray_size(into->levels), darray_size(from->levels));
265 for (i = 0; i < numLevels; i++) {
266 union xkb_action *intoAct, *fromAct;
268 if (i >= darray_size(from->levels))
271 if (i >= darray_size(into->levels)) {
272 darray_append(into->levels, darray_item(from->levels, i));
273 darray_item(into->levels, i).num_syms = 0;
274 darray_item(into->levels, i).sym_index = 0;
278 intoAct = &darray_item(into->levels, i).act;
279 fromAct = &darray_item(from->levels, i).act;
281 if (fromAct->type == ACTION_TYPE_NONE) {
283 else if (intoAct->type == ACTION_TYPE_NONE) {
287 union xkb_action *use = (clobber ? fromAct : intoAct);
288 union xkb_action *ignore = (clobber ? intoAct : fromAct);
291 log_warn(info->keymap->ctx,
292 "Multiple actions for level %d/group %u on key %s; "
293 "Using %s, ignoring %s\n",
294 i + 1, group + 1, LongKeyNameText(key_name),
295 ActionTypeText(use->type),
296 ActionTypeText(ignore->type));
301 into->defined |= (from->defined & GROUP_FIELD_ACTS);
303 /* Then merge the keysyms. */
306 * We want to avoid copying and allocating if not necessary. So
307 * here we do a pre-scan of the levels to check if we'll only use
308 * @into's or @from's keysyms, and if so we'll just assign them.
309 * However if one level uses @into's and another uses @from's, we
310 * will need to construct a new syms array.
313 for (i = 0; i < numLevels; i++) {
314 unsigned int intoSize, fromSize;
316 intoSize = darray_item(into->levels, i).num_syms;
317 if (i < darray_size(from->levels))
318 fromSize = darray_item(from->levels, i).num_syms;
322 if (intoSize == 0 && fromSize == 0)
324 else if (intoSize == 0)
326 else if (fromSize == 0)
329 using |= (clobber ? FROM : INTO);
332 if (using == 0 || using == INTO) {
334 else if (using == FROM) {
335 darray_free(into->syms);
336 into->syms = from->syms;
337 darray_init(from->syms);
338 for (i = 0; i < darray_size(from->levels); i++) {
339 darray_item(into->levels, i).num_syms =
340 darray_item(from->levels, i).num_syms;
341 darray_item(into->levels, i).sym_index =
342 darray_item(from->levels, i).sym_index;
346 darray_xkb_keysym_t syms = darray_new();
348 for (i = 0; i < numLevels; i++) {
349 unsigned int intoSize, fromSize;
351 intoSize = darray_item(into->levels, i).num_syms;
352 if (i < darray_size(from->levels))
353 fromSize = darray_item(from->levels, i).num_syms;
358 if (intoSize == 0 && fromSize == 0)
361 if (intoSize != 0 && fromSize != 0 && report)
362 log_info(info->keymap->ctx,
363 "Multiple symbols for group %u, level %d on key %s; "
364 "Using %s, ignoring %s\n",
365 group + 1, i + 1, LongKeyNameText(key_name),
366 (clobber ? "from" : "to"),
367 (clobber ? "to" : "from"));
369 if (intoSize == 0 || (fromSize != 0 && clobber)) {
370 unsigned sym_index = darray_item(from->levels, i).sym_index;
371 darray_item(into->levels, i).sym_index = darray_size(syms);
372 darray_item(into->levels, i).num_syms = fromSize;
373 darray_append_items(syms, &darray_item(from->syms, sym_index),
378 unsigned sym_index = darray_item(into->levels, i).sym_index;
379 darray_item(into->levels, i).sym_index = darray_size(syms);
380 darray_item(into->levels, i).num_syms = intoSize;
381 darray_append_items(syms, &darray_item(into->syms, sym_index),
385 darray_free(into->syms);
388 into->defined |= (from->defined & GROUP_FIELD_SYMS);
394 UseNewKeyField(enum key_field field, enum key_field old, enum key_field new,
395 bool clobber, bool report, enum key_field *collide)
398 return (new & field);
413 MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
416 enum key_field collide = 0;
417 bool clobber, report;
418 int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
420 if (from->merge == MERGE_REPLACE) {
423 InitKeyInfo(from, info->file_id);
427 clobber = (from->merge != MERGE_AUGMENT);
428 report = (verbosity > 9 ||
429 (into->file_id == from->file_id && verbosity > 0));
431 for (i = 0; i < XKB_NUM_GROUPS; i++)
432 MergeGroups(info, &into->groups[i], &from->groups[i], clobber,
433 report, i, into->name);
435 if (UseNewKeyField(KEY_FIELD_VMODMAP, into->defined, from->defined,
436 clobber, report, &collide)) {
437 into->vmodmap = from->vmodmap;
438 into->defined |= KEY_FIELD_VMODMAP;
440 if (UseNewKeyField(KEY_FIELD_REPEAT, into->defined, from->defined,
441 clobber, report, &collide)) {
442 into->repeat = from->repeat;
443 into->defined |= KEY_FIELD_REPEAT;
445 if (UseNewKeyField(KEY_FIELD_TYPE_DFLT, into->defined, from->defined,
446 clobber, report, &collide)) {
447 into->dfltType = from->dfltType;
448 into->defined |= KEY_FIELD_TYPE_DFLT;
450 if (UseNewKeyField(KEY_FIELD_GROUPINFO, into->defined, from->defined,
451 clobber, report, &collide)) {
452 into->out_of_range_group_action = from->out_of_range_group_action;
453 into->out_of_range_group_number = from->out_of_range_group_number;
454 into->defined |= KEY_FIELD_GROUPINFO;
458 log_warn(info->keymap->ctx,
459 "Symbol map for key %s redefined; "
460 "Using %s definition for conflicting fields\n",
461 LongKeyNameText(into->name),
462 (clobber ? "first" : "last"));
469 AddKeySymbols(SymbolsInfo *info, KeyInfo *keyi)
471 unsigned long real_name;
475 * Don't keep aliases in the keys array; this guarantees that
476 * searching for keys to merge with by straight comparison (see the
477 * following loop) is enough, and we won't get multiple KeyInfo's
478 * for the same key because of aliases.
480 if (FindKeyNameForAlias(info->keymap, keyi->name, &real_name))
481 keyi->name = real_name;
483 darray_foreach(iter, info->keys)
484 if (iter->name == keyi->name)
485 return MergeKeys(info, iter, keyi);
487 darray_append(info->keys, *keyi);
488 InitKeyInfo(keyi, info->file_id);
493 AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
498 clobber = (new->merge != MERGE_AUGMENT);
499 darray_foreach(mm, info->modMaps) {
500 if (new->haveSymbol && mm->haveSymbol
501 && (new->u.keySym == mm->u.keySym)) {
502 unsigned use, ignore;
503 if (mm->modifier != new->modifier) {
506 ignore = mm->modifier;
510 ignore = new->modifier;
512 log_err(info->keymap->ctx,
513 "%s added to symbol map for multiple modifiers; "
514 "Using %s, ignoring %s.\n",
515 KeysymText(new->u.keySym), ModIndexText(use),
516 ModIndexText(ignore));
521 if ((!new->haveSymbol) && (!mm->haveSymbol) &&
522 (new->u.keyName == mm->u.keyName)) {
523 unsigned use, ignore;
524 if (mm->modifier != new->modifier) {
527 ignore = mm->modifier;
531 ignore = new->modifier;
533 log_err(info->keymap->ctx,
534 "Key %s added to map for multiple modifiers; "
535 "Using %s, ignoring %s.\n",
536 LongKeyNameText(new->u.keyName), ModIndexText(use),
537 ModIndexText(ignore));
544 darray_append(info->modMaps, *new);
548 /***====================================================================***/
551 MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
552 enum merge_mode merge)
558 if (from->errorCount > 0) {
559 into->errorCount += from->errorCount;
562 if (into->name == NULL) {
563 into->name = from->name;
566 for (i = 0; i < XKB_NUM_GROUPS; i++) {
567 if (from->groupNames[i] != XKB_ATOM_NONE) {
568 if ((merge != MERGE_AUGMENT) ||
569 (into->groupNames[i] == XKB_ATOM_NONE))
570 into->groupNames[i] = from->groupNames[i];
574 darray_foreach(keyi, from->keys) {
575 merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
576 if (!AddKeySymbols(into, keyi))
580 darray_foreach(mm, from->modMaps) {
581 mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
582 if (!AddModMapEntry(into, mm))
588 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge);
591 HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *stmt)
593 enum merge_mode merge = MERGE_DEFAULT;
595 SymbolsInfo included, next_incl;
597 InitSymbolsInfo(&included, info->keymap, info->file_id, info->actions);
600 included.name = stmt->stmt;
604 for (; stmt; stmt = stmt->next_incl) {
605 if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_SYMBOLS,
607 info->errorCount += 10;
608 ClearSymbolsInfo(&included);
612 InitSymbolsInfo(&next_incl, info->keymap, rtrn->id, info->actions);
613 next_incl.merge = next_incl.dflt.merge = MERGE_OVERRIDE;
615 next_incl.explicit_group = atoi(stmt->modifier) - 1;
617 next_incl.explicit_group = info->explicit_group;
619 HandleSymbolsFile(&next_incl, rtrn, MERGE_OVERRIDE);
621 MergeIncludedSymbols(&included, &next_incl, merge);
623 ClearSymbolsInfo(&next_incl);
627 MergeIncludedSymbols(info, &included, merge);
628 ClearSymbolsInfo(&included);
630 return (info->errorCount == 0);
637 GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
638 unsigned what, xkb_group_index_t *ndx_rtrn)
640 const char *name = (what == SYMBOLS ? "symbols" : "actions");
642 if (arrayNdx == NULL) {
644 enum group_field field = (what == SYMBOLS ?
645 GROUP_FIELD_SYMS : GROUP_FIELD_ACTS);
647 for (i = 0; i < XKB_NUM_GROUPS; i++) {
648 if (!(keyi->groups[i].defined & field)) {
654 log_err(info->keymap->ctx,
655 "Too many groups of %s for key %s (max %u); "
656 "Ignoring %s defined for extra groups\n",
657 name, LongKeyNameText(keyi->name), XKB_NUM_GROUPS + 1, name);
661 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, ndx_rtrn)) {
662 log_err(info->keymap->ctx,
663 "Illegal group index for %s of key %s\n"
664 "Definition with non-integer array index ignored\n",
665 name, LongKeyNameText(keyi->name));
674 LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
678 if (!str || istreq(str, "any") || istreq(str, "nosymbol")) {
679 *sym_rtrn = XKB_KEY_NoSymbol;
683 if (istreq(str, "none") || istreq(str, "voidsymbol")) {
684 *sym_rtrn = XKB_KEY_VoidSymbol;
688 sym = xkb_keysym_from_name(str);
689 if (sym != XKB_KEY_NoSymbol) {
698 AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
701 xkb_group_index_t ndx;
704 xkb_level_index_t nLevels;
708 if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx))
711 groupi = &keyi->groups[ndx];
714 groupi->defined |= GROUP_FIELD_SYMS;
718 if (value->op != EXPR_KEYSYM_LIST) {
719 log_err(info->keymap->ctx,
720 "Expected a list of symbols, found %s; "
721 "Ignoring symbols for group %u of %s\n",
722 expr_op_type_to_string(value->op), ndx + 1,
723 LongKeyNameText(keyi->name));
727 if (groupi->defined & GROUP_FIELD_SYMS) {
728 log_err(info->keymap->ctx,
729 "Symbols for key %s, group %u already defined; "
730 "Ignoring duplicate definition\n",
731 LongKeyNameText(keyi->name), ndx + 1);
735 nSyms = darray_size(value->value.list.syms);
736 nLevels = darray_size(value->value.list.symsMapIndex);
738 if (darray_size(groupi->syms) < nSyms)
739 darray_resize0(groupi->syms, nSyms);
741 if (darray_size(groupi->levels) < nLevels)
742 darray_resize0(groupi->levels, nLevels);
744 groupi->defined |= GROUP_FIELD_SYMS;
746 for (i = 0; i < nLevels; i++) {
747 LevelInfo *leveli = &darray_item(groupi->levels, i);
749 leveli->sym_index = darray_item(value->value.list.symsMapIndex, i);
750 leveli->num_syms = darray_item(value->value.list.symsNumEntries, i);
752 for (j = 0; j < leveli->num_syms; j++) {
753 if (!LookupKeysym(darray_item(value->value.list.syms,
754 leveli->sym_index + j),
755 &darray_item(groupi->syms,
756 leveli->sym_index + j))) {
757 log_warn(info->keymap->ctx,
758 "Could not resolve keysym %s for key %s, group %u (%s), level %u\n",
759 darray_item(value->value.list.syms, i),
760 LongKeyNameText(keyi->name),
762 xkb_atom_text(info->keymap->ctx,
763 info->groupNames[ndx]),
765 leveli->sym_index = 0;
766 leveli->num_syms = 0;
770 if (leveli->num_syms == 1 &&
771 darray_item(groupi->syms,
772 leveli->sym_index + j) == XKB_KEY_NoSymbol) {
773 leveli->sym_index = 0;
774 leveli->num_syms = 0;
779 for (j = darray_size(groupi->levels) - 1;
780 j >= 0 && darray_item(groupi->levels, j).num_syms == 0; j--)
781 (void) darray_pop(groupi->levels);
787 AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
791 xkb_group_index_t ndx;
795 union xkb_action *toAct;
797 if (!GetGroupIndex(info, keyi, arrayNdx, ACTIONS, &ndx))
800 groupi = &keyi->groups[ndx];
803 groupi->defined |= GROUP_FIELD_ACTS;
807 if (value->op != EXPR_ACTION_LIST) {
808 log_wsgo(info->keymap->ctx,
809 "Bad expression type (%d) for action list value; "
810 "Ignoring actions for group %u of %s\n",
811 value->op, ndx, LongKeyNameText(keyi->name));
815 if (groupi->defined & GROUP_FIELD_ACTS) {
816 log_wsgo(info->keymap->ctx,
817 "Actions for key %s, group %u already defined\n",
818 LongKeyNameText(keyi->name), ndx);
823 for (act = value->value.child; act; act = (ExprDef *) act->common.next)
826 if (darray_size(groupi->levels) < nActs)
827 darray_resize0(groupi->levels, nActs);
829 groupi->defined |= GROUP_FIELD_ACTS;
831 act = value->value.child;
832 for (i = 0; i < nActs; i++) {
833 toAct = &darray_item(groupi->levels, i).act;
835 if (!HandleActionDef(act, info->keymap, toAct, info->actions))
836 log_err(info->keymap->ctx,
837 "Illegal action definition for %s; "
838 "Action for group %u/level %u ignored\n",
839 LongKeyNameText(keyi->name), ndx + 1, i + 1);
841 act = (ExprDef *) act->common.next;
847 static const LookupEntry repeatEntries[] = {
848 { "true", KEY_REPEAT_YES },
849 { "yes", KEY_REPEAT_YES },
850 { "on", KEY_REPEAT_YES },
851 { "false", KEY_REPEAT_NO },
852 { "no", KEY_REPEAT_NO },
853 { "off", KEY_REPEAT_NO },
854 { "default", KEY_REPEAT_UNDEFINED },
859 SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
860 ExprDef *arrayNdx, ExprDef *value)
863 struct xkb_context *ctx = info->keymap->ctx;
865 if (istreq(field, "type")) {
866 xkb_group_index_t ndx;
869 if (!ExprResolveString(ctx, value, &val))
871 "The type field of a key symbol map must be a string; "
872 "Ignoring illegal type definition\n");
874 if (arrayNdx == NULL) {
875 keyi->dfltType = val;
876 keyi->defined |= KEY_FIELD_TYPE_DFLT;
878 else if (!ExprResolveGroup(ctx, arrayNdx, &ndx)) {
880 "Illegal group index for type of key %s; "
881 "Definition with non-integer array index ignored\n",
882 LongKeyNameText(keyi->name));
887 keyi->groups[ndx].type = val;
888 keyi->groups[ndx].defined |= GROUP_FIELD_TYPE;
891 else if (istreq(field, "symbols"))
892 return AddSymbolsToKey(info, keyi, arrayNdx, value);
893 else if (istreq(field, "actions"))
894 return AddActionsToKey(info, keyi, arrayNdx, value);
895 else if (istreq(field, "vmods") ||
896 istreq(field, "virtualmods") ||
897 istreq(field, "virtualmodifiers")) {
900 ok = ExprResolveVModMask(info->keymap, value, &mask);
902 keyi->vmodmap = (mask >> XKB_NUM_CORE_MODS) & 0xffff;
903 keyi->defined |= KEY_FIELD_VMODMAP;
906 log_err(info->keymap->ctx,
907 "Expected a virtual modifier mask, found %s; "
908 "Ignoring virtual modifiers definition for key %s\n",
909 expr_op_type_to_string(value->op),
910 LongKeyNameText(keyi->name));
913 else if (istreq(field, "locking") ||
914 istreq(field, "lock") ||
915 istreq(field, "locks")) {
916 log_err(info->keymap->ctx,
917 "Key behaviors not supported; "
918 "Ignoring locking specification for key %s\n",
919 LongKeyNameText(keyi->name));
921 else if (istreq(field, "radiogroup") ||
922 istreq(field, "permanentradiogroup") ||
923 istreq(field, "allownone")) {
924 log_err(info->keymap->ctx,
925 "Radio groups not supported; "
926 "Ignoring radio group specification for key %s\n",
927 LongKeyNameText(keyi->name));
929 else if (istreq_prefix("overlay", field) ||
930 istreq_prefix("permanentoverlay", field)) {
931 log_err(info->keymap->ctx,
932 "Overlays not supported; "
933 "Ignoring overlay specification for key %s\n",
934 LongKeyNameText(keyi->name));
936 else if (istreq(field, "repeating") ||
937 istreq(field, "repeats") ||
938 istreq(field, "repeat")) {
941 ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
943 log_err(info->keymap->ctx,
944 "Illegal repeat setting for %s; "
945 "Non-boolean repeat setting ignored\n",
946 LongKeyNameText(keyi->name));
950 keyi->defined |= KEY_FIELD_REPEAT;
952 else if (istreq(field, "groupswrap") ||
953 istreq(field, "wrapgroups")) {
956 if (!ExprResolveBoolean(ctx, value, &set)) {
957 log_err(info->keymap->ctx,
958 "Illegal groupsWrap setting for %s; "
959 "Non-boolean value ignored\n",
960 LongKeyNameText(keyi->name));
965 keyi->out_of_range_group_action = RANGE_WRAP;
967 keyi->out_of_range_group_action = RANGE_SATURATE;
969 keyi->defined |= KEY_FIELD_GROUPINFO;
971 else if (istreq(field, "groupsclamp") ||
972 istreq(field, "clampgroups")) {
975 if (!ExprResolveBoolean(ctx, value, &set)) {
976 log_err(info->keymap->ctx,
977 "Illegal groupsClamp setting for %s; "
978 "Non-boolean value ignored\n",
979 LongKeyNameText(keyi->name));
984 keyi->out_of_range_group_action = RANGE_SATURATE;
986 keyi->out_of_range_group_action = RANGE_WRAP;
988 keyi->defined |= KEY_FIELD_GROUPINFO;
990 else if (istreq(field, "groupsredirect") ||
991 istreq(field, "redirectgroups")) {
992 xkb_group_index_t grp;
994 if (!ExprResolveGroup(ctx, value, &grp)) {
995 log_err(info->keymap->ctx,
996 "Illegal group index for redirect of key %s; "
997 "Definition with non-integer group ignored\n",
998 LongKeyNameText(keyi->name));
1002 keyi->out_of_range_group_action = RANGE_REDIRECT;
1003 keyi->out_of_range_group_number = grp - 1;
1004 keyi->defined |= KEY_FIELD_GROUPINFO;
1007 log_err(info->keymap->ctx,
1008 "Unknown field %s in a symbol interpretation; "
1009 "Definition ignored\n",
1018 SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
1020 xkb_group_index_t grp;
1024 log_vrb(info->keymap->ctx, 1,
1025 "You must specify an index when specifying a group name; "
1026 "Group name definition without array subscript ignored\n");
1030 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, &grp)) {
1031 log_err(info->keymap->ctx,
1032 "Illegal index in group name definition; "
1033 "Definition with non-integer array index ignored\n");
1037 if (!ExprResolveString(info->keymap->ctx, value, &name)) {
1038 log_err(info->keymap->ctx,
1039 "Group name must be a string; "
1040 "Illegal name for group %d ignored\n", grp);
1044 info->groupNames[grp - 1 + info->explicit_group] = name;
1049 HandleSymbolsVar(SymbolsInfo *info, VarDef *stmt)
1051 const char *elem, *field;
1055 if (ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field,
1057 return 0; /* internal error, already reported */
1058 if (elem && istreq(elem, "key")) {
1059 ret = SetSymbolsField(info, &info->dflt, field, arrayNdx,
1062 else if (!elem && (istreq(field, "name") ||
1063 istreq(field, "groupname"))) {
1064 ret = SetGroupName(info, arrayNdx, stmt->value);
1066 else if (!elem && (istreq(field, "groupswrap") ||
1067 istreq(field, "wrapgroups"))) {
1068 log_err(info->keymap->ctx,
1069 "Global \"groupswrap\" not supported; Ignored\n");
1072 else if (!elem && (istreq(field, "groupsclamp") ||
1073 istreq(field, "clampgroups"))) {
1074 log_err(info->keymap->ctx,
1075 "Global \"groupsclamp\" not supported; Ignored\n");
1078 else if (!elem && (istreq(field, "groupsredirect") ||
1079 istreq(field, "redirectgroups"))) {
1080 log_err(info->keymap->ctx,
1081 "Global \"groupsredirect\" not supported; Ignored\n");
1084 else if (!elem && istreq(field, "allownone")) {
1085 log_err(info->keymap->ctx,
1086 "Radio groups not supported; "
1087 "Ignoring \"allownone\" specification\n");
1091 ret = SetActionField(info->keymap, elem, field, arrayNdx, stmt->value,
1099 HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
1102 const char *elem, *field;
1105 for (; def; def = (VarDef *) def->common.next) {
1106 if (def->name && def->name->op == EXPR_FIELD_REF) {
1107 ok = HandleSymbolsVar(info, def);
1112 if (!def->value || def->value->op == EXPR_KEYSYM_LIST)
1119 ok = ExprResolveLhs(info->keymap->ctx, def->name, &elem, &field,
1124 ok = SetSymbolsField(info, keyi, field, arrayNdx, def->value);
1131 SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
1133 xkb_group_index_t i;
1135 if (info->explicit_group == 0)
1138 for (i = 1; i < XKB_NUM_GROUPS; i++) {
1139 if (keyi->groups[i].defined) {
1140 log_warn(info->keymap->ctx,
1141 "For the map %s an explicit group specified, "
1142 "but key %s has more than one group defined; "
1143 "All groups except first one will be ignored\n",
1144 info->name, LongKeyNameText(keyi->name));
1148 if (i < XKB_NUM_GROUPS)
1149 for (i = 1; i < XKB_NUM_GROUPS; i++)
1150 ClearGroupInfo(&keyi->groups[i]);
1152 keyi->groups[info->explicit_group] = keyi->groups[0];
1153 InitGroupInfo(&keyi->groups[0]);
1158 HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt)
1161 xkb_group_index_t i;
1164 for (i = 0; i < XKB_NUM_GROUPS; i++) {
1165 darray_copy(keyi.groups[i].syms, info->dflt.groups[i].syms);
1166 darray_copy(keyi.groups[i].levels, info->dflt.groups[i].levels);
1168 keyi.merge = stmt->merge;
1169 keyi.name = KeyNameToLong(stmt->keyName);
1171 if (!HandleSymbolsBody(info, (VarDef *) stmt->symbols, &keyi)) {
1176 if (!SetExplicitGroup(info, &keyi)) {
1181 if (!AddKeySymbols(info, &keyi)) {
1190 HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
1194 xkb_mod_index_t ndx;
1196 struct xkb_context *ctx = info->keymap->ctx;
1198 if (!LookupModIndex(ctx, NULL, def->modifier, EXPR_TYPE_INT, &ndx)) {
1199 log_err(info->keymap->ctx,
1200 "Illegal modifier map definition; "
1201 "Ignoring map for non-modifier \"%s\"\n",
1202 xkb_atom_text(ctx, def->modifier));
1209 for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) {
1212 if (key->op == EXPR_VALUE && key->value_type == EXPR_TYPE_KEYNAME) {
1213 tmp.haveSymbol = false;
1214 tmp.u.keyName = KeyNameToLong(key->value.keyName);
1216 else if (ExprResolveKeySym(ctx, key, &sym)) {
1217 tmp.haveSymbol = true;
1221 log_err(info->keymap->ctx,
1222 "Modmap entries may contain only key names or keysyms; "
1223 "Illegal definition for %s modifier ignored\n",
1224 ModIndexText(tmp.modifier));
1228 ok = AddModMapEntry(info, &tmp) && ok;
1234 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
1240 info->name = strdup_safe(file->name);
1243 for (stmt = file->defs; stmt; stmt = stmt->next) {
1244 switch (stmt->type) {
1246 ok = HandleIncludeSymbols(info, (IncludeStmt *) stmt);
1249 ok = HandleSymbolsDef(info, (SymbolsDef *) stmt);
1252 ok = HandleSymbolsVar(info, (VarDef *) stmt);
1255 ok = HandleVModDef((VModDef *) stmt, info->keymap, merge,
1259 ok = HandleModMapDef(info, (ModMapDef *) stmt);
1262 log_err(info->keymap->ctx,
1263 "Interpretation files may not include other types; "
1264 "Ignoring %s\n", stmt_type_to_string(stmt->type));
1272 if (info->errorCount > 10) {
1273 log_err(info->keymap->ctx, "Abandoning symbols file \"%s\"\n",
1281 * Given a keysym @sym, return a key which generates it, or NULL.
1282 * This is used for example in a modifier map definition, such as:
1283 * modifier_map Lock { Caps_Lock };
1284 * where we want to add the Lock modifier to the modmap of the key
1285 * which matches the keysym Caps_Lock.
1286 * Since there can be many keys which generates the keysym, the key
1287 * is chosen first by lowest group in which the keysym appears, than
1288 * by lowest level and than by lowest key code.
1290 static struct xkb_key *
1291 FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
1293 struct xkb_key *key, *ret = NULL;
1294 xkb_group_index_t group, min_group = UINT32_MAX;
1295 xkb_level_index_t level, min_level = UINT16_MAX;
1297 xkb_foreach_key(key, keymap) {
1298 for (group = 0; group < key->num_groups; group++) {
1299 for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
1301 if (XkbKeyNumSyms(key, group, level) != 1 ||
1302 (XkbKeySymEntry(key, group, level))[0] != sym)
1306 * If the keysym was found in a group or level > 0, we must
1307 * keep looking since we might find a key in which the keysym
1308 * is in a lower group or level.
1310 if (group < min_group ||
1311 (group == min_group && level < min_level)) {
1313 if (group == 0 && level == 0) {
1329 FindNamedType(struct xkb_keymap *keymap, xkb_atom_t name, unsigned *type_rtrn)
1333 for (i = 0; i < keymap->num_types; i++) {
1334 if (keymap->types[i].name == name) {
1344 * Assign a type to the given sym and return the Atom for the type assigned.
1347 * - ONE_LEVEL for width 0/1
1348 * - ALPHABETIC for 2 shift levels, with lower/upercase
1349 * - KEYPAD for keypad keys.
1350 * - TWO_LEVEL for other 2 shift level keys.
1351 * and the same for four level keys.
1353 * @param width Number of sysms in syms.
1354 * @param syms The keysyms for the given key (must be size width).
1355 * @param typeNameRtrn Set to the Atom of the type name.
1357 * @returns true if a type could be found, false otherwise.
1359 * FIXME: I need to take the KeyInfo so I can look at symsMapIndex and
1360 * all that fun stuff rather than just assuming there's always one
1364 FindAutomaticType(struct xkb_context *ctx, xkb_level_index_t width,
1365 const xkb_keysym_t *syms, xkb_atom_t *typeNameRtrn,
1369 if ((width == 1) || (width == 0)) {
1370 *typeNameRtrn = xkb_atom_intern(ctx, "ONE_LEVEL");
1373 else if (width == 2) {
1374 if (syms && xkb_keysym_is_lower(syms[0]) &&
1375 xkb_keysym_is_upper(syms[1])) {
1376 *typeNameRtrn = xkb_atom_intern(ctx, "ALPHABETIC");
1378 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1379 xkb_keysym_is_keypad(syms[1]))) {
1380 *typeNameRtrn = xkb_atom_intern(ctx, "KEYPAD");
1384 *typeNameRtrn = xkb_atom_intern(ctx, "TWO_LEVEL");
1388 else if (width <= 4) {
1389 if (syms && xkb_keysym_is_lower(syms[0]) &&
1390 xkb_keysym_is_upper(syms[1]))
1391 if (xkb_keysym_is_lower(syms[2]) && xkb_keysym_is_upper(syms[3]))
1393 xkb_atom_intern(ctx, "FOUR_LEVEL_ALPHABETIC");
1395 *typeNameRtrn = xkb_atom_intern(ctx,
1396 "FOUR_LEVEL_SEMIALPHABETIC");
1398 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1399 xkb_keysym_is_keypad(syms[1])))
1400 *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL_KEYPAD");
1402 *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL");
1403 /* XXX: why not set autoType here? */
1409 * Ensure the given KeyInfo is in a coherent state, i.e. no gaps between the
1410 * groups, and reduce to one group if all groups are identical anyway.
1413 PrepareKeyDef(KeyInfo *keyi)
1415 xkb_group_index_t i, lastGroup;
1416 const GroupInfo *group0;
1419 /* get highest group number */
1420 for (i = XKB_NUM_GROUPS - 1; i > 0; i--)
1421 if (keyi->groups[i].defined)
1428 group0 = &keyi->groups[0];
1430 /* If there are empty groups between non-empty ones fill them with data */
1431 /* from the first group. */
1432 /* We can make a wrong assumption here. But leaving gaps is worse. */
1433 for (i = lastGroup; i > 0; i--) {
1434 GroupInfo *groupi = &keyi->groups[i];
1436 if (groupi->defined)
1439 groupi->type = group0->type;
1440 darray_copy(groupi->syms, group0->syms);
1441 darray_copy(groupi->levels, group0->levels);
1442 groupi->defined = group0->defined;
1445 /* If all groups are completely identical remove them all */
1446 /* exept the first one. */
1447 /* XXX: This code needs testing... or removal. */
1449 for (i = lastGroup; i > 0; i--) {
1450 GroupInfo *groupi = &keyi->groups[i];
1452 if (groupi->type != group0->type) {
1456 if (!darray_same(groupi->levels, group0->levels) &&
1457 (darray_empty(groupi->levels) || darray_empty(group0->levels) ||
1458 darray_size(groupi->levels) != darray_size(group0->levels) ||
1459 memcmp(darray_mem(groupi->levels, 0),
1460 darray_mem(group0->levels, 0),
1461 darray_size(group0->levels) * sizeof(LevelInfo)))) {
1465 if (!darray_same(groupi->syms, group0->syms) &&
1466 (darray_empty(groupi->syms) || darray_empty(group0->syms) ||
1467 darray_size(groupi->syms) != darray_size(group0->syms) ||
1468 memcmp(darray_mem(groupi->syms, 0),
1469 darray_mem(group0->syms, 0),
1470 darray_size(group0->syms) * sizeof(xkb_keysym_t)))) {
1477 for (i = lastGroup; i > 0; i--)
1478 ClearGroupInfo(&keyi->groups[i]);
1482 CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi)
1484 struct xkb_keymap *keymap = info->keymap;
1485 struct xkb_key *key;
1486 xkb_group_index_t i;
1488 unsigned int sizeSyms;
1489 unsigned int symIndex;
1492 * The name is guaranteed to be real and not an alias (see
1493 * AddKeySymbols), so 'false' is safe here.
1495 key = FindNamedKey(keymap, keyi->name, false);
1497 log_vrb(info->keymap->ctx, 5,
1498 "Key %s not found in keycodes; Symbols ignored\n",
1499 LongKeyNameText(keyi->name));
1504 * Find the range of groups we need. (There shouldn't be any gaps,
1505 * see PrepareKeyDef).
1507 key->num_groups = 0;
1508 for (i = 0; i < XKB_NUM_GROUPS; i++)
1509 if (keyi->groups[i].defined)
1510 key->num_groups = i + 1;
1512 /* See if we need to allocate an actions array. */
1513 haveActions = false;
1514 for (i = 0; i < key->num_groups; i++) {
1516 darray_foreach(leveli, keyi->groups[i].levels) {
1517 if (leveli->act.type != ACTION_TYPE_NONE) {
1526 * Find and assign the groups' types in the keymap. Also find the
1527 * key width according to the largest type.
1530 for (i = 0; i < key->num_groups; i++) {
1531 struct xkb_key_type *type;
1532 GroupInfo *groupi = &keyi->groups[i];
1533 bool autoType = false;
1535 /* Find the type of the group, if it is missing. */
1536 if (groupi->type == XKB_ATOM_NONE) {
1537 if (keyi->dfltType != XKB_ATOM_NONE)
1538 groupi->type = keyi->dfltType;
1539 else if (FindAutomaticType(keymap->ctx,
1540 darray_size(groupi->levels),
1541 darray_mem(groupi->syms, 0),
1542 &groupi->type, &autoType)) { }
1544 log_vrb(info->keymap->ctx, 5,
1545 "No automatic type for %d levels; "
1546 "Using %s for the %s key\n",
1547 darray_size(groupi->levels),
1548 xkb_atom_text(keymap->ctx, groupi->type),
1549 LongKeyNameText(keyi->name));
1552 /* Find the type in the keymap, if it was defined in xkb_types. */
1553 if (FindNamedType(keymap, groupi->type, &key->kt_index[i])) {
1554 if (!autoType || darray_size(groupi->levels) > 2)
1555 key->explicit_groups |= (1 << i);
1558 log_vrb(info->keymap->ctx, 3,
1559 "Type \"%s\" is not defined; "
1560 "Using default type for the %s key\n",
1561 xkb_atom_text(keymap->ctx, groupi->type),
1562 LongKeyNameText(keyi->name));
1564 * Index 0 is guaranteed to contain something, usually
1565 * ONE_LEVEL or at least some default one-level type.
1567 key->kt_index[i] = 0;
1570 /* If the type specifies fewer levels than the key has, shrink the key. */
1571 type = &keymap->types[key->kt_index[i]];
1572 if (type->num_levels < darray_size(groupi->levels)) {
1573 log_vrb(info->keymap->ctx, 1,
1574 "Type \"%s\" has %d levels, but %s has %d levels; "
1575 "Ignoring extra symbols\n",
1576 xkb_atom_text(keymap->ctx, type->name),
1578 LongKeyNameText(keyi->name),
1579 darray_size(groupi->levels));
1580 darray_resize(groupi->levels, type->num_levels);
1584 * Why type->num_levels and not darray_size(groupi->levels)?
1585 * Because the type may have more levels, and each group must
1586 * have at least as many levels as its type. Because the
1587 * key->syms array is indexed by (group * width + level), we
1588 * must take the largest one.
1589 * Maybe we can change it to save some space.
1591 key->width = MAX(key->width, type->num_levels);
1594 /* Find the size of the syms array. */
1596 for (i = 0; i < key->num_groups; i++)
1597 sizeSyms += darray_size(keyi->groups[i].syms);
1599 /* Initialize the xkb_key, now that we know the sizes. */
1600 key->syms = calloc(sizeSyms, sizeof(*key->syms));
1601 key->sym_index = calloc(key->num_groups * key->width,
1602 sizeof(*key->sym_index));
1603 key->num_syms = calloc(key->num_groups * key->width,
1604 sizeof(*key->num_syms));
1605 key->out_of_range_group_number = keyi->out_of_range_group_number;
1606 key->out_of_range_group_action = keyi->out_of_range_group_action;
1608 key->actions = calloc(key->num_groups * key->width,
1609 sizeof(*key->actions));
1610 key->explicit |= EXPLICIT_INTERP;
1612 if (keyi->defined & KEY_FIELD_VMODMAP) {
1613 key->vmodmap = keyi->vmodmap;
1614 key->explicit |= EXPLICIT_VMODMAP;
1617 if (keyi->repeat != KEY_REPEAT_UNDEFINED) {
1618 key->repeats = (keyi->repeat == KEY_REPEAT_YES);
1619 key->explicit |= EXPLICIT_REPEAT;
1622 /* Copy keysyms and actions. */
1624 for (i = 0; i < key->num_groups; i++) {
1625 GroupInfo *groupi = &keyi->groups[i];
1626 xkb_level_index_t j;
1628 /* We rely on calloc having zeroized the arrays up to key->width. */
1629 for (j = 0; j < darray_size(groupi->levels); j++) {
1630 LevelInfo *leveli = &darray_item(groupi->levels, j);
1632 if (leveli->act.type != ACTION_TYPE_NONE)
1633 key->actions[i * key->width + j] = leveli->act;
1635 if (leveli->num_syms <= 0)
1638 memcpy(&key->syms[symIndex],
1639 &darray_item(groupi->syms, leveli->sym_index),
1640 leveli->num_syms * sizeof(*key->syms));
1641 key->sym_index[i * key->width + j] = symIndex;
1642 key->num_syms[i * key->width + j] = leveli->num_syms;
1643 symIndex += key->num_syms[i * key->width + j];
1651 CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
1653 struct xkb_key *key;
1654 struct xkb_keymap *keymap = info->keymap;
1656 if (!entry->haveSymbol) {
1657 key = FindNamedKey(keymap, entry->u.keyName, true);
1659 log_vrb(info->keymap->ctx, 5,
1660 "Key %s not found in keycodes; "
1661 "Modifier map entry for %s not updated\n",
1662 LongKeyNameText(entry->u.keyName),
1663 ModIndexText(entry->modifier));
1668 key = FindKeyForSymbol(keymap, entry->u.keySym);
1670 log_vrb(info->keymap->ctx, 5,
1671 "Key \"%s\" not found in symbol map; "
1672 "Modifier map entry for %s not updated\n",
1673 KeysymText(entry->u.keySym),
1674 ModIndexText(entry->modifier));
1679 key->modmap |= (1 << entry->modifier);
1684 CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
1688 xkb_group_index_t i;
1689 struct xkb_key *key;
1691 keymap->symbols_section_name = strdup_safe(info->name);
1693 for (i = 0; i < XKB_NUM_GROUPS; i++)
1694 if (info->groupNames[i] != XKB_ATOM_NONE)
1695 keymap->group_names[i] = info->groupNames[i];
1697 darray_foreach(keyi, info->keys) {
1698 PrepareKeyDef(keyi);
1699 if (!CopySymbolsDef(info, keyi))
1703 if (xkb_get_log_verbosity(keymap->ctx) > 3) {
1704 xkb_foreach_key(key, keymap) {
1705 if (key->name[0] == '\0')
1708 if (key->num_groups < 1)
1709 log_info(keymap->ctx,
1710 "No symbols defined for %s\n",
1711 KeyNameText(key->name));
1715 darray_foreach(mm, info->modMaps)
1716 if (!CopyModMapDef(info, mm))
1719 /* XXX: If we don't ignore errorCount, things break. */
1724 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
1725 enum merge_mode merge)
1728 ActionsInfo *actions;
1730 actions = NewActionsInfo();
1734 InitSymbolsInfo(&info, keymap, file->id, actions);
1735 info.dflt.merge = merge;
1737 HandleSymbolsFile(&info, file, merge);
1739 if (darray_empty(info.keys))
1742 if (info.errorCount != 0)
1745 if (!CopySymbolsToKeymap(keymap, &info))
1748 ClearSymbolsInfo(&info);
1749 FreeActionsInfo(actions);
1753 FreeActionsInfo(actions);
1754 ClearSymbolsInfo(&info);