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"
64 KEY_REPEAT_UNDEFINED = 0,
70 GROUP_FIELD_SYMS = (1 << 0),
71 GROUP_FIELD_ACTS = (1 << 1),
72 GROUP_FIELD_TYPE = (1 << 2),
76 KEY_FIELD_REPEAT = (1 << 0),
77 KEY_FIELD_TYPE_DFLT = (1 << 1),
78 KEY_FIELD_GROUPINFO = (1 << 2),
79 KEY_FIELD_VMODMAP = (1 << 3),
83 unsigned int num_syms;
84 unsigned int sym_index;
88 typedef darray(xkb_keysym_t) darray_xkb_keysym_t;
91 enum group_field defined;
92 darray_xkb_keysym_t syms;
93 darray(LevelInfo) levels;
97 typedef struct _KeyInfo {
98 enum key_field defined;
100 enum merge_mode merge;
102 unsigned long name; /* the 4 chars of the key name, as long */
104 darray(GroupInfo) groups;
106 enum key_repeat repeat;
107 xkb_mod_mask_t vmodmap;
110 enum xkb_range_exceed_type out_of_range_group_action;
111 xkb_layout_index_t out_of_range_group_number;
115 InitGroupInfo(GroupInfo *groupi)
117 memset(groupi, 0, sizeof(*groupi));
121 ClearGroupInfo(GroupInfo *groupi)
123 darray_free(groupi->syms);
124 darray_free(groupi->levels);
128 InitKeyInfo(KeyInfo *keyi, unsigned file_id)
130 static const char dflt_key_name[XKB_KEY_NAME_LENGTH] = "*";
132 memset(keyi, 0, sizeof(*keyi));
133 keyi->file_id = file_id;
134 keyi->merge = MERGE_OVERRIDE;
135 keyi->name = KeyNameToLong(dflt_key_name);
136 keyi->out_of_range_group_action = RANGE_WRAP;
140 ClearKeyInfo(KeyInfo *keyi)
143 darray_foreach(groupi, keyi->groups)
144 ClearGroupInfo(groupi);
145 darray_free(keyi->groups);
148 /***====================================================================***/
150 typedef struct _ModMapEntry {
151 enum merge_mode merge;
155 unsigned long keyName;
160 typedef struct _SymbolsInfo {
161 char *name; /* e.g. pc+us+inet(evdev) */
164 enum merge_mode merge;
165 xkb_layout_index_t explicit_group;
166 darray(KeyInfo) keys;
169 ActionsInfo *actions;
170 darray_xkb_atom_t group_names;
171 darray(ModMapEntry) modMaps;
173 struct xkb_keymap *keymap;
177 InitSymbolsInfo(SymbolsInfo *info, struct xkb_keymap *keymap,
178 unsigned file_id, ActionsInfo *actions)
180 memset(info, 0, sizeof(*info));
181 info->keymap = keymap;
182 info->file_id = file_id;
183 info->merge = MERGE_OVERRIDE;
184 InitKeyInfo(&info->dflt, file_id);
185 InitVModInfo(&info->vmods, keymap);
186 info->actions = actions;
187 info->explicit_group = XKB_LAYOUT_INVALID;
191 ClearSymbolsInfo(SymbolsInfo * info)
195 darray_foreach(keyi, info->keys)
197 darray_free(info->keys);
198 darray_free(info->group_names);
199 darray_free(info->modMaps);
200 ClearKeyInfo(&info->dflt);
204 MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
205 bool report, xkb_layout_index_t group, unsigned long key_name)
207 xkb_level_index_t i, numLevels;
208 enum { INTO = (1 << 0), FROM = (1 << 1) } using;
210 /* First find the type of the merged group. */
211 if (into->type != from->type) {
212 if (from->type == XKB_ATOM_NONE) {
214 else if (into->type == XKB_ATOM_NONE) {
215 into->type = from->type;
218 xkb_atom_t use = (clobber ? from->type : into->type);
219 xkb_atom_t ignore = (clobber ? into->type : from->type);
222 log_warn(info->keymap->ctx,
223 "Multiple definitions for group %d type of key %s; "
224 "Using %s, ignoring %s\n",
225 group + 1, LongKeyNameText(key_name),
226 xkb_atom_text(info->keymap->ctx, use),
227 xkb_atom_text(info->keymap->ctx, ignore));
232 into->defined |= (from->defined & GROUP_FIELD_TYPE);
234 /* Now look at the levels. */
236 if (darray_empty(from->levels)) {
241 if (darray_empty(into->levels)) {
242 from->type = into->type;
248 /* First we merge the actions and ensure @into has all the levels. */
249 numLevels = MAX(darray_size(into->levels), darray_size(from->levels));
250 for (i = 0; i < numLevels; i++) {
251 union xkb_action *intoAct, *fromAct;
253 if (i >= darray_size(from->levels))
256 if (i >= darray_size(into->levels)) {
257 darray_append(into->levels, darray_item(from->levels, i));
258 darray_item(into->levels, i).num_syms = 0;
259 darray_item(into->levels, i).sym_index = 0;
263 intoAct = &darray_item(into->levels, i).act;
264 fromAct = &darray_item(from->levels, i).act;
266 if (fromAct->type == ACTION_TYPE_NONE) {
268 else if (intoAct->type == ACTION_TYPE_NONE) {
272 union xkb_action *use = (clobber ? fromAct : intoAct);
273 union xkb_action *ignore = (clobber ? intoAct : fromAct);
276 log_warn(info->keymap->ctx,
277 "Multiple actions for level %d/group %u on key %s; "
278 "Using %s, ignoring %s\n",
279 i + 1, group + 1, LongKeyNameText(key_name),
280 ActionTypeText(use->type),
281 ActionTypeText(ignore->type));
286 into->defined |= (from->defined & GROUP_FIELD_ACTS);
288 /* Then merge the keysyms. */
291 * We want to avoid copying and allocating if not necessary. So
292 * here we do a pre-scan of the levels to check if we'll only use
293 * @into's or @from's keysyms, and if so we'll just assign them.
294 * However if one level uses @into's and another uses @from's, we
295 * will need to construct a new syms array.
298 for (i = 0; i < numLevels; i++) {
299 unsigned int intoSize, fromSize;
301 intoSize = darray_item(into->levels, i).num_syms;
302 if (i < darray_size(from->levels))
303 fromSize = darray_item(from->levels, i).num_syms;
307 if (intoSize == 0 && fromSize == 0)
309 else if (intoSize == 0)
311 else if (fromSize == 0)
314 using |= (clobber ? FROM : INTO);
317 if (using == 0 || using == INTO) {
319 else if (using == FROM) {
320 darray_free(into->syms);
321 into->syms = from->syms;
322 darray_init(from->syms);
323 for (i = 0; i < darray_size(from->levels); i++) {
324 darray_item(into->levels, i).num_syms =
325 darray_item(from->levels, i).num_syms;
326 darray_item(into->levels, i).sym_index =
327 darray_item(from->levels, i).sym_index;
331 darray_xkb_keysym_t syms = darray_new();
333 for (i = 0; i < numLevels; i++) {
334 unsigned int intoSize, fromSize;
336 intoSize = darray_item(into->levels, i).num_syms;
337 if (i < darray_size(from->levels))
338 fromSize = darray_item(from->levels, i).num_syms;
343 if (intoSize == 0 && fromSize == 0)
346 if (intoSize != 0 && fromSize != 0 && report)
347 log_info(info->keymap->ctx,
348 "Multiple symbols for group %u, level %d on key %s; "
349 "Using %s, ignoring %s\n",
350 group + 1, i + 1, LongKeyNameText(key_name),
351 (clobber ? "from" : "to"),
352 (clobber ? "to" : "from"));
354 if (intoSize == 0 || (fromSize != 0 && clobber)) {
355 unsigned sym_index = darray_item(from->levels, i).sym_index;
356 darray_item(into->levels, i).sym_index = darray_size(syms);
357 darray_item(into->levels, i).num_syms = fromSize;
358 darray_append_items(syms, &darray_item(from->syms, sym_index),
363 unsigned sym_index = darray_item(into->levels, i).sym_index;
364 darray_item(into->levels, i).sym_index = darray_size(syms);
365 darray_item(into->levels, i).num_syms = intoSize;
366 darray_append_items(syms, &darray_item(into->syms, sym_index),
370 darray_free(into->syms);
373 into->defined |= (from->defined & GROUP_FIELD_SYMS);
379 UseNewKeyField(enum key_field field, enum key_field old, enum key_field new,
380 bool clobber, bool report, enum key_field *collide)
383 return (new & field);
398 MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
400 xkb_layout_index_t i;
401 xkb_layout_index_t groups_in_both;
402 enum key_field collide = 0;
403 bool clobber, report;
404 int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
406 if (from->merge == MERGE_REPLACE) {
409 InitKeyInfo(from, info->file_id);
413 clobber = (from->merge != MERGE_AUGMENT);
414 report = (verbosity > 9 ||
415 (into->file_id == from->file_id && verbosity > 0));
417 groups_in_both = MIN(darray_size(into->groups),
418 darray_size(from->groups));
419 for (i = 0; i < groups_in_both; i++)
421 &darray_item(into->groups, i),
422 &darray_item(from->groups, i),
423 clobber, report, i, into->name);
424 /* If @from has extra groups, just move them to @into. */
425 for (i = groups_in_both; i < darray_size(from->groups); i++) {
426 darray_append(into->groups, darray_item(from->groups, i));
427 InitGroupInfo(&darray_item(from->groups, i));
430 if (UseNewKeyField(KEY_FIELD_VMODMAP, into->defined, from->defined,
431 clobber, report, &collide)) {
432 into->vmodmap = from->vmodmap;
433 into->defined |= KEY_FIELD_VMODMAP;
435 if (UseNewKeyField(KEY_FIELD_REPEAT, into->defined, from->defined,
436 clobber, report, &collide)) {
437 into->repeat = from->repeat;
438 into->defined |= KEY_FIELD_REPEAT;
440 if (UseNewKeyField(KEY_FIELD_TYPE_DFLT, into->defined, from->defined,
441 clobber, report, &collide)) {
442 into->dfltType = from->dfltType;
443 into->defined |= KEY_FIELD_TYPE_DFLT;
445 if (UseNewKeyField(KEY_FIELD_GROUPINFO, into->defined, from->defined,
446 clobber, report, &collide)) {
447 into->out_of_range_group_action = from->out_of_range_group_action;
448 into->out_of_range_group_number = from->out_of_range_group_number;
449 into->defined |= KEY_FIELD_GROUPINFO;
453 log_warn(info->keymap->ctx,
454 "Symbol map for key %s redefined; "
455 "Using %s definition for conflicting fields\n",
456 LongKeyNameText(into->name),
457 (clobber ? "first" : "last"));
460 InitKeyInfo(from, info->file_id);
465 AddKeySymbols(SymbolsInfo *info, KeyInfo *keyi)
467 unsigned long real_name;
471 * Don't keep aliases in the keys array; this guarantees that
472 * searching for keys to merge with by straight comparison (see the
473 * following loop) is enough, and we won't get multiple KeyInfo's
474 * for the same key because of aliases.
476 if (FindKeyNameForAlias(info->keymap, keyi->name, &real_name))
477 keyi->name = real_name;
479 darray_foreach(iter, info->keys)
480 if (iter->name == keyi->name)
481 return MergeKeys(info, iter, keyi);
483 darray_append(info->keys, *keyi);
484 InitKeyInfo(keyi, info->file_id);
489 AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
494 clobber = (new->merge != MERGE_AUGMENT);
495 darray_foreach(mm, info->modMaps) {
496 if (new->haveSymbol && mm->haveSymbol
497 && (new->u.keySym == mm->u.keySym)) {
498 unsigned use, ignore;
499 if (mm->modifier != new->modifier) {
502 ignore = mm->modifier;
506 ignore = new->modifier;
508 log_err(info->keymap->ctx,
509 "%s added to symbol map for multiple modifiers; "
510 "Using %s, ignoring %s.\n",
511 KeysymText(new->u.keySym), ModIndexText(use),
512 ModIndexText(ignore));
517 if ((!new->haveSymbol) && (!mm->haveSymbol) &&
518 (new->u.keyName == mm->u.keyName)) {
519 unsigned use, ignore;
520 if (mm->modifier != new->modifier) {
523 ignore = mm->modifier;
527 ignore = new->modifier;
529 log_err(info->keymap->ctx,
530 "Key %s added to map for multiple modifiers; "
531 "Using %s, ignoring %s.\n",
532 LongKeyNameText(new->u.keyName), ModIndexText(use),
533 ModIndexText(ignore));
540 darray_append(info->modMaps, *new);
544 /***====================================================================***/
547 MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
548 enum merge_mode merge)
553 xkb_atom_t *group_name;
554 xkb_layout_index_t group_names_in_both;
556 if (from->errorCount > 0) {
557 into->errorCount += from->errorCount;
561 if (into->name == NULL) {
562 into->name = from->name;
566 group_names_in_both = MIN(darray_size(into->group_names),
567 darray_size(from->group_names));
568 for (i = 0; i < group_names_in_both; i++) {
569 if (!darray_item(from->group_names, i))
572 if (merge == MERGE_AUGMENT && darray_item(into->group_names, i))
575 darray_item(into->group_names, i) = darray_item(from->group_names, i);
577 /* If @from has more, get them as well. */
578 darray_foreach_from(group_name, from->group_names, group_names_in_both)
579 darray_append(into->group_names, *group_name);
581 darray_foreach(keyi, from->keys) {
582 merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
583 if (!AddKeySymbols(into, keyi))
587 darray_foreach(mm, from->modMaps) {
588 mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
589 if (!AddModMapEntry(into, mm))
595 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge);
598 HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *stmt)
600 enum merge_mode merge = MERGE_DEFAULT;
602 SymbolsInfo included, next_incl;
604 InitSymbolsInfo(&included, info->keymap, info->file_id, info->actions);
607 included.name = stmt->stmt;
611 for (; stmt; stmt = stmt->next_incl) {
612 if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_SYMBOLS,
614 info->errorCount += 10;
615 ClearSymbolsInfo(&included);
619 InitSymbolsInfo(&next_incl, info->keymap, rtrn->id, info->actions);
620 next_incl.merge = next_incl.dflt.merge = MERGE_OVERRIDE;
621 if (stmt->modifier) {
622 next_incl.explicit_group = atoi(stmt->modifier) - 1;
623 if (next_incl.explicit_group >= XKB_NUM_GROUPS) {
624 log_err(info->keymap->ctx,
625 "Cannot set explicit group to %d - must be between 1..%d; "
626 "Ignoring group number\n",
627 next_incl.explicit_group + 1, XKB_NUM_GROUPS);
628 next_incl.explicit_group = info->explicit_group;
632 next_incl.explicit_group = info->explicit_group;
635 HandleSymbolsFile(&next_incl, rtrn, MERGE_OVERRIDE);
637 MergeIncludedSymbols(&included, &next_incl, merge);
639 ClearSymbolsInfo(&next_incl);
643 MergeIncludedSymbols(info, &included, merge);
644 ClearSymbolsInfo(&included);
646 return (info->errorCount == 0);
653 GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
654 unsigned what, xkb_layout_index_t *ndx_rtrn)
656 const char *name = (what == SYMBOLS ? "symbols" : "actions");
658 if (arrayNdx == NULL) {
659 xkb_layout_index_t i;
661 enum group_field field = (what == SYMBOLS ?
662 GROUP_FIELD_SYMS : GROUP_FIELD_ACTS);
664 darray_enumerate(i, groupi, keyi->groups) {
665 if (!(groupi->defined & field)) {
671 if (i >= XKB_NUM_GROUPS) {
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 darray_resize0(keyi->groups, darray_size(keyi->groups) + 1);
680 *ndx_rtrn = darray_size(keyi->groups) - 1;
684 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, ndx_rtrn)) {
685 log_err(info->keymap->ctx,
686 "Illegal group index for %s of key %s\n"
687 "Definition with non-integer array index ignored\n",
688 name, LongKeyNameText(keyi->name));
693 if (*ndx_rtrn >= darray_size(keyi->groups))
694 darray_resize0(keyi->groups, *ndx_rtrn + 1);
700 LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
704 if (!str || istreq(str, "any") || istreq(str, "nosymbol")) {
705 *sym_rtrn = XKB_KEY_NoSymbol;
709 if (istreq(str, "none") || istreq(str, "voidsymbol")) {
710 *sym_rtrn = XKB_KEY_VoidSymbol;
714 sym = xkb_keysym_from_name(str);
715 if (sym != XKB_KEY_NoSymbol) {
724 AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
727 xkb_layout_index_t ndx;
730 xkb_level_index_t nLevels;
734 if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx))
737 groupi = &darray_item(keyi->groups, ndx);
740 groupi->defined |= GROUP_FIELD_SYMS;
744 if (value->op != EXPR_KEYSYM_LIST) {
745 log_err(info->keymap->ctx,
746 "Expected a list of symbols, found %s; "
747 "Ignoring symbols for group %u of %s\n",
748 expr_op_type_to_string(value->op), ndx + 1,
749 LongKeyNameText(keyi->name));
753 if (groupi->defined & GROUP_FIELD_SYMS) {
754 log_err(info->keymap->ctx,
755 "Symbols for key %s, group %u already defined; "
756 "Ignoring duplicate definition\n",
757 LongKeyNameText(keyi->name), ndx + 1);
761 nSyms = darray_size(value->value.list.syms);
762 nLevels = darray_size(value->value.list.symsMapIndex);
764 if (darray_size(groupi->syms) < nSyms)
765 darray_resize0(groupi->syms, nSyms);
767 if (darray_size(groupi->levels) < nLevels)
768 darray_resize0(groupi->levels, nLevels);
770 groupi->defined |= GROUP_FIELD_SYMS;
772 for (i = 0; i < nLevels; i++) {
773 LevelInfo *leveli = &darray_item(groupi->levels, i);
775 leveli->sym_index = darray_item(value->value.list.symsMapIndex, i);
776 leveli->num_syms = darray_item(value->value.list.symsNumEntries, i);
778 for (j = 0; j < leveli->num_syms; j++) {
779 if (!LookupKeysym(darray_item(value->value.list.syms,
780 leveli->sym_index + j),
781 &darray_item(groupi->syms,
782 leveli->sym_index + j))) {
783 const char *group_name = "unnamed";
785 if (ndx < darray_size(info->group_names) &&
786 darray_item(info->group_names, ndx))
787 group_name = xkb_atom_text(info->keymap->ctx,
788 darray_item(info->group_names,
791 log_warn(info->keymap->ctx,
792 "Could not resolve keysym %s for key %s, group %u (%s), level %u\n",
793 darray_item(value->value.list.syms, i),
794 LongKeyNameText(keyi->name),
795 ndx + 1, group_name, nSyms);
797 leveli->sym_index = 0;
798 leveli->num_syms = 0;
802 if (leveli->num_syms == 1 &&
803 darray_item(groupi->syms,
804 leveli->sym_index + j) == XKB_KEY_NoSymbol) {
805 leveli->sym_index = 0;
806 leveli->num_syms = 0;
811 for (j = darray_size(groupi->levels) - 1;
812 j >= 0 && darray_item(groupi->levels, j).num_syms == 0; j--)
813 (void) darray_pop(groupi->levels);
819 AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
823 xkb_layout_index_t ndx;
827 union xkb_action *toAct;
829 if (!GetGroupIndex(info, keyi, arrayNdx, ACTIONS, &ndx))
832 groupi = &darray_item(keyi->groups, ndx);
835 groupi->defined |= GROUP_FIELD_ACTS;
839 if (value->op != EXPR_ACTION_LIST) {
840 log_wsgo(info->keymap->ctx,
841 "Bad expression type (%d) for action list value; "
842 "Ignoring actions for group %u of %s\n",
843 value->op, ndx, LongKeyNameText(keyi->name));
847 if (groupi->defined & GROUP_FIELD_ACTS) {
848 log_wsgo(info->keymap->ctx,
849 "Actions for key %s, group %u already defined\n",
850 LongKeyNameText(keyi->name), ndx);
855 for (act = value->value.child; act; act = (ExprDef *) act->common.next)
858 if (darray_size(groupi->levels) < nActs)
859 darray_resize0(groupi->levels, nActs);
861 groupi->defined |= GROUP_FIELD_ACTS;
863 act = value->value.child;
864 for (i = 0; i < nActs; i++) {
865 toAct = &darray_item(groupi->levels, i).act;
867 if (!HandleActionDef(act, info->keymap, toAct, info->actions))
868 log_err(info->keymap->ctx,
869 "Illegal action definition for %s; "
870 "Action for group %u/level %u ignored\n",
871 LongKeyNameText(keyi->name), ndx + 1, i + 1);
873 act = (ExprDef *) act->common.next;
879 static const LookupEntry repeatEntries[] = {
880 { "true", KEY_REPEAT_YES },
881 { "yes", KEY_REPEAT_YES },
882 { "on", KEY_REPEAT_YES },
883 { "false", KEY_REPEAT_NO },
884 { "no", KEY_REPEAT_NO },
885 { "off", KEY_REPEAT_NO },
886 { "default", KEY_REPEAT_UNDEFINED },
891 SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
892 ExprDef *arrayNdx, ExprDef *value)
895 struct xkb_context *ctx = info->keymap->ctx;
897 if (istreq(field, "type")) {
898 xkb_layout_index_t ndx;
901 if (!ExprResolveString(ctx, value, &val))
903 "The type field of a key symbol map must be a string; "
904 "Ignoring illegal type definition\n");
906 if (arrayNdx == NULL) {
907 keyi->dfltType = val;
908 keyi->defined |= KEY_FIELD_TYPE_DFLT;
910 else if (!ExprResolveGroup(ctx, arrayNdx, &ndx)) {
912 "Illegal group index for type of key %s; "
913 "Definition with non-integer array index ignored\n",
914 LongKeyNameText(keyi->name));
919 if (ndx >= darray_size(keyi->groups))
920 darray_resize0(keyi->groups, ndx + 1);
921 darray_item(keyi->groups, ndx).type = val;
922 darray_item(keyi->groups, ndx).defined |= GROUP_FIELD_TYPE;
925 else if (istreq(field, "symbols"))
926 return AddSymbolsToKey(info, keyi, arrayNdx, value);
927 else if (istreq(field, "actions"))
928 return AddActionsToKey(info, keyi, arrayNdx, value);
929 else if (istreq(field, "vmods") ||
930 istreq(field, "virtualmods") ||
931 istreq(field, "virtualmodifiers")) {
934 ok = ExprResolveVModMask(info->keymap, value, &mask);
936 keyi->vmodmap = (mask >> XKB_NUM_CORE_MODS) & 0xffff;
937 keyi->defined |= KEY_FIELD_VMODMAP;
940 log_err(info->keymap->ctx,
941 "Expected a virtual modifier mask, found %s; "
942 "Ignoring virtual modifiers definition for key %s\n",
943 expr_op_type_to_string(value->op),
944 LongKeyNameText(keyi->name));
947 else if (istreq(field, "locking") ||
948 istreq(field, "lock") ||
949 istreq(field, "locks")) {
950 log_err(info->keymap->ctx,
951 "Key behaviors not supported; "
952 "Ignoring locking specification for key %s\n",
953 LongKeyNameText(keyi->name));
955 else if (istreq(field, "radiogroup") ||
956 istreq(field, "permanentradiogroup") ||
957 istreq(field, "allownone")) {
958 log_err(info->keymap->ctx,
959 "Radio groups not supported; "
960 "Ignoring radio group specification for key %s\n",
961 LongKeyNameText(keyi->name));
963 else if (istreq_prefix("overlay", field) ||
964 istreq_prefix("permanentoverlay", field)) {
965 log_err(info->keymap->ctx,
966 "Overlays not supported; "
967 "Ignoring overlay specification for key %s\n",
968 LongKeyNameText(keyi->name));
970 else if (istreq(field, "repeating") ||
971 istreq(field, "repeats") ||
972 istreq(field, "repeat")) {
975 ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
977 log_err(info->keymap->ctx,
978 "Illegal repeat setting for %s; "
979 "Non-boolean repeat setting ignored\n",
980 LongKeyNameText(keyi->name));
984 keyi->defined |= KEY_FIELD_REPEAT;
986 else if (istreq(field, "groupswrap") ||
987 istreq(field, "wrapgroups")) {
990 if (!ExprResolveBoolean(ctx, value, &set)) {
991 log_err(info->keymap->ctx,
992 "Illegal groupsWrap setting for %s; "
993 "Non-boolean value ignored\n",
994 LongKeyNameText(keyi->name));
999 keyi->out_of_range_group_action = RANGE_WRAP;
1001 keyi->out_of_range_group_action = RANGE_SATURATE;
1003 keyi->defined |= KEY_FIELD_GROUPINFO;
1005 else if (istreq(field, "groupsclamp") ||
1006 istreq(field, "clampgroups")) {
1009 if (!ExprResolveBoolean(ctx, value, &set)) {
1010 log_err(info->keymap->ctx,
1011 "Illegal groupsClamp setting for %s; "
1012 "Non-boolean value ignored\n",
1013 LongKeyNameText(keyi->name));
1018 keyi->out_of_range_group_action = RANGE_SATURATE;
1020 keyi->out_of_range_group_action = RANGE_WRAP;
1022 keyi->defined |= KEY_FIELD_GROUPINFO;
1024 else if (istreq(field, "groupsredirect") ||
1025 istreq(field, "redirectgroups")) {
1026 xkb_layout_index_t grp;
1028 if (!ExprResolveGroup(ctx, value, &grp)) {
1029 log_err(info->keymap->ctx,
1030 "Illegal group index for redirect of key %s; "
1031 "Definition with non-integer group ignored\n",
1032 LongKeyNameText(keyi->name));
1036 keyi->out_of_range_group_action = RANGE_REDIRECT;
1037 keyi->out_of_range_group_number = grp - 1;
1038 keyi->defined |= KEY_FIELD_GROUPINFO;
1041 log_err(info->keymap->ctx,
1042 "Unknown field %s in a symbol interpretation; "
1043 "Definition ignored\n",
1052 SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
1054 xkb_layout_index_t grp, grp_to_use;
1058 log_vrb(info->keymap->ctx, 1,
1059 "You must specify an index when specifying a group name; "
1060 "Group name definition without array subscript ignored\n");
1064 if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, &grp)) {
1065 log_err(info->keymap->ctx,
1066 "Illegal index in group name definition; "
1067 "Definition with non-integer array index ignored\n");
1071 if (!ExprResolveString(info->keymap->ctx, value, &name)) {
1072 log_err(info->keymap->ctx,
1073 "Group name must be a string; "
1074 "Illegal name for group %d ignored\n", grp);
1078 grp_to_use = XKB_LAYOUT_INVALID;
1079 if (info->explicit_group == XKB_LAYOUT_INVALID) {
1080 grp_to_use = grp - 1;
1082 else if (grp - 1 == 0) {
1083 grp_to_use = info->explicit_group;
1086 log_warn(info->keymap->ctx,
1087 "An explicit group was specified for the '%s' map, "
1088 "but it provides a name for a group other than Group1 (%d); "
1089 "Ignoring group name '%s'\n",
1091 xkb_atom_text(info->keymap->ctx, name));
1095 if (grp_to_use >= darray_size(info->group_names))
1096 darray_resize0(info->group_names, grp_to_use + 1);
1097 darray_item(info->group_names, grp_to_use) = name;
1102 HandleGlobalVar(SymbolsInfo *info, VarDef *stmt)
1104 const char *elem, *field;
1108 if (ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field,
1110 return 0; /* internal error, already reported */
1111 if (elem && istreq(elem, "key")) {
1112 ret = SetSymbolsField(info, &info->dflt, field, arrayNdx,
1115 else if (!elem && (istreq(field, "name") ||
1116 istreq(field, "groupname"))) {
1117 ret = SetGroupName(info, arrayNdx, stmt->value);
1119 else if (!elem && (istreq(field, "groupswrap") ||
1120 istreq(field, "wrapgroups"))) {
1121 log_err(info->keymap->ctx,
1122 "Global \"groupswrap\" not supported; Ignored\n");
1125 else if (!elem && (istreq(field, "groupsclamp") ||
1126 istreq(field, "clampgroups"))) {
1127 log_err(info->keymap->ctx,
1128 "Global \"groupsclamp\" not supported; Ignored\n");
1131 else if (!elem && (istreq(field, "groupsredirect") ||
1132 istreq(field, "redirectgroups"))) {
1133 log_err(info->keymap->ctx,
1134 "Global \"groupsredirect\" not supported; Ignored\n");
1137 else if (!elem && istreq(field, "allownone")) {
1138 log_err(info->keymap->ctx,
1139 "Radio groups not supported; "
1140 "Ignoring \"allownone\" specification\n");
1144 ret = SetActionField(info->keymap, elem, field, arrayNdx, stmt->value,
1152 HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
1155 const char *elem, *field;
1158 for (; def; def = (VarDef *) def->common.next) {
1159 if (def->name && def->name->op == EXPR_FIELD_REF) {
1160 log_err(info->keymap->ctx,
1161 "Cannot set a global default value from within a key statement; "
1162 "Move statements to the global file scope\n");
1167 if (!def->value || def->value->op == EXPR_KEYSYM_LIST)
1174 ok = ExprResolveLhs(info->keymap->ctx, def->name, &elem, &field,
1179 ok = SetSymbolsField(info, keyi, field, arrayNdx, def->value);
1186 SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
1188 xkb_layout_index_t i;
1192 if (info->explicit_group == XKB_LAYOUT_INVALID)
1195 darray_enumerate_from(i, groupi, keyi->groups, 1) {
1196 if (groupi->defined) {
1198 ClearGroupInfo(groupi);
1203 log_warn(info->keymap->ctx,
1204 "For the map %s an explicit group specified, "
1205 "but key %s has more than one group defined; "
1206 "All groups except first one will be ignored\n",
1207 info->name, LongKeyNameText(keyi->name));
1209 darray_resize0(keyi->groups, info->explicit_group + 1);
1210 if (info->explicit_group > 0) {
1211 darray_item(keyi->groups, info->explicit_group) =
1212 darray_item(keyi->groups, 0);
1213 InitGroupInfo(&darray_item(keyi->groups, 0));
1220 HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt)
1223 xkb_layout_index_t i;
1226 darray_init(keyi.groups);
1227 darray_copy(keyi.groups, info->dflt.groups);
1228 for (i = 0; i < darray_size(keyi.groups); i++) {
1229 darray_init(darray_item(keyi.groups, i).syms);
1230 darray_copy(darray_item(keyi.groups, i).syms,
1231 darray_item(info->dflt.groups, i).syms);
1232 darray_init(darray_item(keyi.groups, i).levels);
1233 darray_copy(darray_item(keyi.groups, i).levels,
1234 darray_item(info->dflt.groups, i).levels);
1236 keyi.merge = stmt->merge;
1237 keyi.name = KeyNameToLong(stmt->keyName);
1239 if (!HandleSymbolsBody(info, (VarDef *) stmt->symbols, &keyi)) {
1244 if (!SetExplicitGroup(info, &keyi)) {
1249 if (!AddKeySymbols(info, &keyi)) {
1258 HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
1262 xkb_mod_index_t ndx;
1264 struct xkb_context *ctx = info->keymap->ctx;
1266 if (!LookupModIndex(ctx, NULL, def->modifier, EXPR_TYPE_INT, &ndx)) {
1267 log_err(info->keymap->ctx,
1268 "Illegal modifier map definition; "
1269 "Ignoring map for non-modifier \"%s\"\n",
1270 xkb_atom_text(ctx, def->modifier));
1277 for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) {
1280 if (key->op == EXPR_VALUE && key->value_type == EXPR_TYPE_KEYNAME) {
1281 tmp.haveSymbol = false;
1282 tmp.u.keyName = KeyNameToLong(key->value.keyName);
1284 else if (ExprResolveKeySym(ctx, key, &sym)) {
1285 tmp.haveSymbol = true;
1289 log_err(info->keymap->ctx,
1290 "Modmap entries may contain only key names or keysyms; "
1291 "Illegal definition for %s modifier ignored\n",
1292 ModIndexText(tmp.modifier));
1296 ok = AddModMapEntry(info, &tmp) && ok;
1302 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
1308 info->name = strdup_safe(file->name);
1311 for (stmt = file->defs; stmt; stmt = stmt->next) {
1312 switch (stmt->type) {
1314 ok = HandleIncludeSymbols(info, (IncludeStmt *) stmt);
1317 ok = HandleSymbolsDef(info, (SymbolsDef *) stmt);
1320 ok = HandleGlobalVar(info, (VarDef *) stmt);
1323 ok = HandleVModDef((VModDef *) stmt, info->keymap, merge,
1327 ok = HandleModMapDef(info, (ModMapDef *) stmt);
1330 log_err(info->keymap->ctx,
1331 "Interpretation files may not include other types; "
1332 "Ignoring %s\n", stmt_type_to_string(stmt->type));
1340 if (info->errorCount > 10) {
1341 log_err(info->keymap->ctx, "Abandoning symbols file \"%s\"\n",
1349 * Given a keysym @sym, return a key which generates it, or NULL.
1350 * This is used for example in a modifier map definition, such as:
1351 * modifier_map Lock { Caps_Lock };
1352 * where we want to add the Lock modifier to the modmap of the key
1353 * which matches the keysym Caps_Lock.
1354 * Since there can be many keys which generates the keysym, the key
1355 * is chosen first by lowest group in which the keysym appears, than
1356 * by lowest level and than by lowest key code.
1358 static struct xkb_key *
1359 FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
1361 struct xkb_key *key, *ret = NULL;
1362 xkb_layout_index_t group, min_group = UINT32_MAX;
1363 xkb_level_index_t level, min_level = UINT16_MAX;
1365 xkb_foreach_key(key, keymap) {
1366 for (group = 0; group < key->num_groups; group++) {
1367 for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
1369 if (XkbKeyNumSyms(key, group, level) != 1 ||
1370 (XkbKeySymEntry(key, group, level))[0] != sym)
1374 * If the keysym was found in a group or level > 0, we must
1375 * keep looking since we might find a key in which the keysym
1376 * is in a lower group or level.
1378 if (group < min_group ||
1379 (group == min_group && level < min_level)) {
1381 if (group == 0 && level == 0) {
1397 FindNamedType(struct xkb_keymap *keymap, xkb_atom_t name, unsigned *type_rtrn)
1401 for (i = 0; i < keymap->num_types; i++) {
1402 if (keymap->types[i].name == name) {
1412 * Assign a type to the given sym and return the Atom for the type assigned.
1415 * - ONE_LEVEL for width 0/1
1416 * - ALPHABETIC for 2 shift levels, with lower/upercase
1417 * - KEYPAD for keypad keys.
1418 * - TWO_LEVEL for other 2 shift level keys.
1419 * and the same for four level keys.
1421 * @param width Number of sysms in syms.
1422 * @param syms The keysyms for the given key (must be size width).
1423 * @param typeNameRtrn Set to the Atom of the type name.
1425 * @returns true if a type could be found, false otherwise.
1427 * FIXME: I need to take the KeyInfo so I can look at symsMapIndex and
1428 * all that fun stuff rather than just assuming there's always one
1432 FindAutomaticType(struct xkb_context *ctx, xkb_level_index_t width,
1433 const xkb_keysym_t *syms, xkb_atom_t *typeNameRtrn,
1437 if ((width == 1) || (width == 0)) {
1438 *typeNameRtrn = xkb_atom_intern(ctx, "ONE_LEVEL");
1441 else if (width == 2) {
1442 if (syms && xkb_keysym_is_lower(syms[0]) &&
1443 xkb_keysym_is_upper(syms[1])) {
1444 *typeNameRtrn = xkb_atom_intern(ctx, "ALPHABETIC");
1446 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1447 xkb_keysym_is_keypad(syms[1]))) {
1448 *typeNameRtrn = xkb_atom_intern(ctx, "KEYPAD");
1452 *typeNameRtrn = xkb_atom_intern(ctx, "TWO_LEVEL");
1456 else if (width <= 4) {
1457 if (syms && xkb_keysym_is_lower(syms[0]) &&
1458 xkb_keysym_is_upper(syms[1]))
1459 if (xkb_keysym_is_lower(syms[2]) && xkb_keysym_is_upper(syms[3]))
1461 xkb_atom_intern(ctx, "FOUR_LEVEL_ALPHABETIC");
1463 *typeNameRtrn = xkb_atom_intern(ctx,
1464 "FOUR_LEVEL_SEMIALPHABETIC");
1466 else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
1467 xkb_keysym_is_keypad(syms[1])))
1468 *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL_KEYPAD");
1470 *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL");
1471 /* XXX: why not set autoType here? */
1477 CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi)
1479 struct xkb_keymap *keymap = info->keymap;
1480 struct xkb_key *key;
1482 const GroupInfo *group0;
1483 xkb_layout_index_t i;
1485 unsigned int sizeSyms;
1486 unsigned int symIndex;
1489 * The name is guaranteed to be real and not an alias (see
1490 * AddKeySymbols), so 'false' is safe here.
1492 key = FindNamedKey(keymap, keyi->name, false);
1494 log_vrb(info->keymap->ctx, 5,
1495 "Key %s not found in keycodes; Symbols ignored\n",
1496 LongKeyNameText(keyi->name));
1500 /* Find the range of groups we need. */
1501 key->num_groups = 0;
1502 darray_enumerate(i, groupi, keyi->groups)
1503 if (groupi->defined)
1504 key->num_groups = i + 1;
1506 if (key->num_groups <= 0)
1507 return false; /* WSGO */
1509 darray_resize(keyi->groups, key->num_groups);
1512 * If there are empty groups between non-empty ones, fill them with data
1513 * from the first group.
1514 * We can make a wrong assumption here. But leaving gaps is worse.
1516 group0 = &darray_item(keyi->groups, 0);
1517 darray_foreach_from(groupi, keyi->groups, 1) {
1518 if (groupi->defined)
1521 groupi->type = group0->type;
1522 darray_copy(groupi->syms, group0->syms);
1523 darray_copy(groupi->levels, group0->levels);
1524 groupi->defined = group0->defined;
1527 /* See if we need to allocate an actions array. */
1528 haveActions = false;
1529 darray_foreach(groupi, keyi->groups) {
1531 darray_foreach(leveli, groupi->levels) {
1532 if (leveli->act.type != ACTION_TYPE_NONE) {
1541 * Find and assign the groups' types in the keymap. Also find the
1542 * key width according to the largest type.
1544 key->kt_index = calloc(key->num_groups, sizeof(*key->kt_index));
1546 darray_enumerate(i, groupi, keyi->groups) {
1547 struct xkb_key_type *type;
1548 bool autoType = false;
1550 /* Find the type of the group, if it is missing. */
1551 if (groupi->type == XKB_ATOM_NONE) {
1552 if (keyi->dfltType != XKB_ATOM_NONE)
1553 groupi->type = keyi->dfltType;
1554 else if (FindAutomaticType(keymap->ctx,
1555 darray_size(groupi->levels),
1556 darray_mem(groupi->syms, 0),
1557 &groupi->type, &autoType)) { }
1559 log_vrb(info->keymap->ctx, 5,
1560 "No automatic type for %d levels; "
1561 "Using %s for the %s key\n",
1562 (int) darray_size(groupi->levels),
1563 xkb_atom_text(keymap->ctx, groupi->type),
1564 LongKeyNameText(keyi->name));
1567 /* Find the type in the keymap, if it was defined in xkb_types. */
1568 if (FindNamedType(keymap, groupi->type, &key->kt_index[i])) {
1569 if (!autoType || darray_size(groupi->levels) > 2)
1570 key->explicit_groups |= (1 << i);
1573 log_vrb(info->keymap->ctx, 3,
1574 "Type \"%s\" is not defined; "
1575 "Using default type for the %s key\n",
1576 xkb_atom_text(keymap->ctx, groupi->type),
1577 LongKeyNameText(keyi->name));
1579 * Index 0 is guaranteed to contain something, usually
1580 * ONE_LEVEL or at least some default one-level type.
1582 key->kt_index[i] = 0;
1585 /* If the type specifies fewer levels than the key has, shrink the key. */
1586 type = &keymap->types[key->kt_index[i]];
1587 if (type->num_levels < darray_size(groupi->levels)) {
1588 log_vrb(info->keymap->ctx, 1,
1589 "Type \"%s\" has %d levels, but %s has %d levels; "
1590 "Ignoring extra symbols\n",
1591 xkb_atom_text(keymap->ctx, type->name),
1593 LongKeyNameText(keyi->name),
1594 (int) darray_size(groupi->levels));
1595 darray_resize(groupi->levels, type->num_levels);
1599 * Why type->num_levels and not darray_size(groupi->levels)?
1600 * Because the type may have more levels, and each group must
1601 * have at least as many levels as its type. Because the
1602 * key->syms array is indexed by (group * width + level), we
1603 * must take the largest one.
1604 * Maybe we can change it to save some space.
1606 key->width = MAX(key->width, type->num_levels);
1609 /* Find the size of the syms array. */
1611 darray_foreach(groupi, keyi->groups)
1612 sizeSyms += darray_size(groupi->syms);
1614 /* Initialize the xkb_key, now that we know the sizes. */
1615 key->syms = calloc(sizeSyms, sizeof(*key->syms));
1616 key->sym_index = calloc(key->num_groups * key->width,
1617 sizeof(*key->sym_index));
1618 key->num_syms = calloc(key->num_groups * key->width,
1619 sizeof(*key->num_syms));
1620 key->out_of_range_group_number = keyi->out_of_range_group_number;
1621 key->out_of_range_group_action = keyi->out_of_range_group_action;
1623 key->actions = calloc(key->num_groups * key->width,
1624 sizeof(*key->actions));
1625 key->explicit |= EXPLICIT_INTERP;
1627 if (keyi->defined & KEY_FIELD_VMODMAP) {
1628 key->vmodmap = keyi->vmodmap;
1629 key->explicit |= EXPLICIT_VMODMAP;
1632 if (keyi->repeat != KEY_REPEAT_UNDEFINED) {
1633 key->repeats = (keyi->repeat == KEY_REPEAT_YES);
1634 key->explicit |= EXPLICIT_REPEAT;
1637 /* Copy keysyms and actions. */
1639 darray_enumerate(i, groupi, keyi->groups) {
1640 xkb_level_index_t j;
1643 /* We rely on calloc having zeroized the arrays up to key->width. */
1644 darray_enumerate(j, leveli, groupi->levels) {
1645 if (leveli->act.type != ACTION_TYPE_NONE)
1646 key->actions[i * key->width + j] = leveli->act;
1648 if (leveli->num_syms <= 0)
1651 memcpy(&key->syms[symIndex],
1652 &darray_item(groupi->syms, leveli->sym_index),
1653 leveli->num_syms * sizeof(*key->syms));
1654 key->sym_index[i * key->width + j] = symIndex;
1655 key->num_syms[i * key->width + j] = leveli->num_syms;
1656 symIndex += key->num_syms[i * key->width + j];
1664 CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
1666 struct xkb_key *key;
1667 struct xkb_keymap *keymap = info->keymap;
1669 if (!entry->haveSymbol) {
1670 key = FindNamedKey(keymap, entry->u.keyName, true);
1672 log_vrb(info->keymap->ctx, 5,
1673 "Key %s not found in keycodes; "
1674 "Modifier map entry for %s not updated\n",
1675 LongKeyNameText(entry->u.keyName),
1676 ModIndexText(entry->modifier));
1681 key = FindKeyForSymbol(keymap, entry->u.keySym);
1683 log_vrb(info->keymap->ctx, 5,
1684 "Key \"%s\" not found in symbol map; "
1685 "Modifier map entry for %s not updated\n",
1686 KeysymText(entry->u.keySym),
1687 ModIndexText(entry->modifier));
1692 key->modmap |= (1 << entry->modifier);
1697 CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
1701 struct xkb_key *key;
1703 keymap->symbols_section_name = strdup_safe(info->name);
1705 keymap->group_names = info->group_names;
1706 darray_init(info->group_names);
1708 darray_foreach(keyi, info->keys)
1709 if (!CopySymbolsDef(info, keyi))
1712 if (xkb_context_get_log_verbosity(keymap->ctx) > 3) {
1713 xkb_foreach_key(key, keymap) {
1714 if (key->name[0] == '\0')
1717 if (key->num_groups < 1)
1718 log_info(keymap->ctx,
1719 "No symbols defined for %s\n",
1720 KeyNameText(key->name));
1724 darray_foreach(mm, info->modMaps)
1725 if (!CopyModMapDef(info, mm))
1728 /* XXX: If we don't ignore errorCount, things break. */
1733 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
1734 enum merge_mode merge)
1737 ActionsInfo *actions;
1739 actions = NewActionsInfo();
1743 InitSymbolsInfo(&info, keymap, file->id, actions);
1744 info.dflt.merge = merge;
1746 HandleSymbolsFile(&info, file, merge);
1748 if (darray_empty(info.keys))
1751 if (info.errorCount != 0)
1754 if (!CopySymbolsToKeymap(keymap, &info))
1757 ClearSymbolsInfo(&info);
1758 FreeActionsInfo(actions);
1762 FreeActionsInfo(actions);
1763 ClearSymbolsInfo(&info);